Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
f91fa5c2
提交
f91fa5c2
authored
5月 19, 2018
作者:
Noel Grandin
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'upstream/master' into 1091_new
上级
bd752cd4
07e67c2d
隐藏空白字符变更
内嵌
并排
正在显示
24 个修改的文件
包含
65 行增加
和
137 行删除
+65
-137
Parser.java
h2/src/main/org/h2/command/Parser.java
+5
-35
AlterIndexRename.java
h2/src/main/org/h2/command/ddl/AlterIndexRename.java
+1
-2
CreateTable.java
h2/src/main/org/h2/command/ddl/CreateTable.java
+0
-1
Database.java
h2/src/main/org/h2/engine/Database.java
+1
-4
Session.java
h2/src/main/org/h2/engine/Session.java
+1
-1
PageBtreeIndex.java
h2/src/main/org/h2/index/PageBtreeIndex.java
+2
-2
PageDataIndex.java
h2/src/main/org/h2/index/PageDataIndex.java
+1
-1
PageDataLeaf.java
h2/src/main/org/h2/index/PageDataLeaf.java
+1
-1
PageDelegateIndex.java
h2/src/main/org/h2/index/PageDelegateIndex.java
+1
-1
JdbcConnection.java
h2/src/main/org/h2/jdbc/JdbcConnection.java
+1
-1
MVDelegateIndex.java
h2/src/main/org/h2/mvstore/db/MVDelegateIndex.java
+1
-1
MVPrimaryIndex.java
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
+1
-1
MVSecondaryIndex.java
h2/src/main/org/h2/mvstore/db/MVSecondaryIndex.java
+1
-2
MVSpatialIndex.java
h2/src/main/org/h2/mvstore/db/MVSpatialIndex.java
+1
-2
Schema.java
h2/src/main/org/h2/schema/Schema.java
+1
-2
WebApp.java
h2/src/main/org/h2/server/web/WebApp.java
+5
-5
FileLock.java
h2/src/main/org/h2/store/FileLock.java
+2
-2
LobStorageMap.java
h2/src/main/org/h2/store/LobStorageMap.java
+8
-11
MetaTable.java
h2/src/main/org/h2/table/MetaTable.java
+2
-2
SimpleResultSet.java
h2/src/main/org/h2/tools/SimpleResultSet.java
+1
-2
ColumnNamer.java
h2/src/main/org/h2/util/ColumnNamer.java
+2
-4
ThreadDeadlockDetector.java
h2/src/main/org/h2/util/ThreadDeadlockDetector.java
+4
-4
CaseInsensitiveConcurrentMap.java
h2/src/main/org/h2/value/CaseInsensitiveConcurrentMap.java
+0
-46
NullableKeyConcurrentMap.java
h2/src/main/org/h2/value/NullableKeyConcurrentMap.java
+22
-4
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
f91fa5c2
...
...
@@ -208,7 +208,10 @@ public class Parser {
new
Comparator
<
TableFilter
>()
{
@Override
public
int
compare
(
TableFilter
o1
,
TableFilter
o2
)
{
return
o1
==
o2
?
0
:
compareTableFilters
(
o1
,
o2
);
if
(
o1
==
o2
)
return
0
;
assert
o1
.
getOrderInFrom
()
!=
o2
.
getOrderInFrom
();
return
o1
.
getOrderInFrom
()
>
o2
.
getOrderInFrom
()
?
1
:
-
1
;
}
};
...
...
@@ -2162,43 +2165,10 @@ public class Parser {
// Parser can reorder joined table filters, need to explicitly sort them
// to get the order as it was in the original query.
if
(
session
.
isForceJoinOrder
())
{
sortTableFilters
(
command
.
getTopFilters
()
);
Collections
.
sort
(
command
.
getTopFilters
(),
TABLE_FILTER_COMPARATOR
);
}
}
private
static
void
sortTableFilters
(
ArrayList
<
TableFilter
>
filters
)
{
if
(
filters
.
size
()
<
2
)
{
return
;
}
// Most probably we are already sorted correctly.
boolean
sorted
=
true
;
TableFilter
prev
=
filters
.
get
(
0
);
for
(
int
i
=
1
;
i
<
filters
.
size
();
i
++)
{
TableFilter
next
=
filters
.
get
(
i
);
if
(
compareTableFilters
(
prev
,
next
)
>
0
)
{
sorted
=
false
;
break
;
}
prev
=
next
;
}
// If not, then sort manually.
if
(!
sorted
)
{
Collections
.
sort
(
filters
,
TABLE_FILTER_COMPARATOR
);
}
}
/**
* Find out which of the table filters appears first in the "from" clause.
*
* @param o1 the first table filter
* @param o2 the second table filter
* @return -1 if o1 appears first, and 1 if o2 appears first
*/
static
int
compareTableFilters
(
TableFilter
o1
,
TableFilter
o2
)
{
assert
o1
.
getOrderInFrom
()
!=
o2
.
getOrderInFrom
();
return
o1
.
getOrderInFrom
()
>
o2
.
getOrderInFrom
()
?
1
:
-
1
;
}
private
void
parseJoinTableFilter
(
TableFilter
top
,
final
Select
command
)
{
top
=
readJoin
(
top
);
command
.
addTableFilter
(
top
,
true
);
...
...
h2/src/main/org/h2/command/ddl/AlterIndexRename.java
浏览文件 @
f91fa5c2
...
...
@@ -23,7 +23,6 @@ public class AlterIndexRename extends DefineCommand {
private
boolean
ifExists
;
private
Schema
oldSchema
;
private
String
oldIndexName
;
private
Index
oldIndex
;
private
String
newIndexName
;
public
AlterIndexRename
(
Session
session
)
{
...
...
@@ -50,7 +49,7 @@ public class AlterIndexRename extends DefineCommand {
public
int
update
()
{
session
.
commit
(
true
);
Database
db
=
session
.
getDatabase
();
oldIndex
=
oldSchema
.
findIndex
(
session
,
oldIndexName
);
Index
oldIndex
=
oldSchema
.
findIndex
(
session
,
oldIndexName
);
if
(
oldIndex
==
null
)
{
if
(!
ifExists
)
{
throw
DbException
.
get
(
ErrorCode
.
INDEX_NOT_FOUND_1
,
...
...
h2/src/main/org/h2/command/ddl/CreateTable.java
浏览文件 @
f91fa5c2
...
...
@@ -137,7 +137,6 @@ public class CreateTable extends CommandWithColumns {
}
}
HashSet
<
DbObject
>
set
=
new
HashSet
<>();
set
.
clear
();
table
.
addDependencies
(
set
);
for
(
DbObject
obj
:
set
)
{
if
(
obj
==
table
)
{
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
f91fa5c2
...
...
@@ -73,7 +73,6 @@ import org.h2.util.SourceCompiler;
import
org.h2.util.StringUtils
;
import
org.h2.util.TempFileDeleter
;
import
org.h2.util.Utils
;
import
org.h2.value.CaseInsensitiveConcurrentMap
;
import
org.h2.value.CaseInsensitiveMap
;
import
org.h2.value.CompareMode
;
import
org.h2.value.NullableKeyConcurrentMap
;
...
...
@@ -2860,9 +2859,7 @@ public class Database implements DataHandler {
* @return the hash map
*/
public
<
V
>
ConcurrentHashMap
<
String
,
V
>
newConcurrentStringMap
()
{
return
dbSettings
.
databaseToUpper
?
new
NullableKeyConcurrentMap
<
V
>()
:
new
CaseInsensitiveConcurrentMap
<
V
>();
return
new
NullableKeyConcurrentMap
<>(!
dbSettings
.
databaseToUpper
);
}
/**
...
...
h2/src/main/org/h2/engine/Session.java
浏览文件 @
f91fa5c2
...
...
@@ -924,7 +924,7 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
if
(!
locks
.
contains
(
log
.
getTable
())
&&
TableType
.
TABLE_LINK
!=
tableType
&&
TableType
.
EXTERNAL_TABLE_ENGINE
!=
tableType
)
{
DbException
.
throwInternalError
(
""
+
tableType
);
DbException
.
throwInternalError
(
String
.
valueOf
(
tableType
)
);
}
}
}
...
...
h2/src/main/org/h2/index/PageBtreeIndex.java
浏览文件 @
f91fa5c2
...
...
@@ -51,7 +51,7 @@ public class PageBtreeIndex extends PageIndex {
// trace.setLevel(TraceSystem.DEBUG);
tableData
=
table
;
if
(!
database
.
isPersistent
()
||
id
<
0
)
{
throw
DbException
.
throwInternalError
(
""
+
indexName
);
throw
DbException
.
throwInternalError
(
indexName
);
}
this
.
store
=
database
.
getPageStore
();
store
.
addIndex
(
this
);
...
...
@@ -154,7 +154,7 @@ public class PageBtreeIndex extends PageIndex {
store
.
update
(
empty
);
return
empty
;
}
else
if
(!(
p
instanceof
PageBtree
))
{
throw
DbException
.
get
(
ErrorCode
.
FILE_CORRUPTED_1
,
""
+
p
);
throw
DbException
.
get
(
ErrorCode
.
FILE_CORRUPTED_1
,
String
.
valueOf
(
p
)
);
}
return
(
PageBtree
)
p
;
}
...
...
h2/src/main/org/h2/index/PageDataIndex.java
浏览文件 @
f91fa5c2
...
...
@@ -237,7 +237,7 @@ public class PageDataIndex extends PageIndex {
store
.
update
(
empty
);
return
empty
;
}
else
if
(!(
pd
instanceof
PageData
))
{
throw
DbException
.
get
(
ErrorCode
.
FILE_CORRUPTED_1
,
""
+
pd
);
throw
DbException
.
get
(
ErrorCode
.
FILE_CORRUPTED_1
,
String
.
valueOf
(
pd
)
);
}
PageData
p
=
(
PageData
)
pd
;
if
(
parent
!=
-
1
)
{
...
...
h2/src/main/org/h2/index/PageDataLeaf.java
浏览文件 @
f91fa5c2
...
...
@@ -153,7 +153,7 @@ public class PageDataLeaf extends PageData {
private
int
findInsertionPoint
(
long
key
)
{
int
x
=
find
(
key
);
if
(
x
<
entryCount
&&
keys
[
x
]
==
key
)
{
throw
index
.
getDuplicateKeyException
(
""
+
key
);
throw
index
.
getDuplicateKeyException
(
String
.
valueOf
(
key
)
);
}
return
x
;
}
...
...
h2/src/main/org/h2/index/PageDelegateIndex.java
浏览文件 @
f91fa5c2
...
...
@@ -32,7 +32,7 @@ public class PageDelegateIndex extends PageIndex {
this
.
initBaseIndex
(
table
,
id
,
name
,
cols
,
indexType
);
this
.
mainIndex
=
mainIndex
;
if
(!
database
.
isPersistent
()
||
id
<
0
)
{
throw
DbException
.
throwInternalError
(
""
+
name
);
throw
DbException
.
throwInternalError
(
name
);
}
PageStore
store
=
database
.
getPageStore
();
store
.
addIndex
(
this
);
...
...
h2/src/main/org/h2/jdbc/JdbcConnection.java
浏览文件 @
f91fa5c2
...
...
@@ -1098,7 +1098,7 @@ public class JdbcConnection extends TraceObject
private
static
JdbcSavepoint
convertSavepoint
(
Savepoint
savepoint
)
{
if
(!(
savepoint
instanceof
JdbcSavepoint
))
{
throw
DbException
.
get
(
ErrorCode
.
SAVEPOINT_IS_INVALID_1
,
""
+
savepoint
);
String
.
valueOf
(
savepoint
)
);
}
return
(
JdbcSavepoint
)
savepoint
;
}
...
...
h2/src/main/org/h2/mvstore/db/MVDelegateIndex.java
浏览文件 @
f91fa5c2
...
...
@@ -35,7 +35,7 @@ public class MVDelegateIndex extends BaseIndex implements MVIndex {
this
.
initBaseIndex
(
table
,
id
,
name
,
cols
,
indexType
);
this
.
mainIndex
=
mainIndex
;
if
(
id
<
0
)
{
throw
DbException
.
throwInternalError
(
""
+
name
);
throw
DbException
.
throwInternalError
(
name
);
}
}
...
...
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
浏览文件 @
f91fa5c2
...
...
@@ -368,7 +368,7 @@ public class MVPrimaryIndex extends BaseIndex {
/**
* A cursor.
*/
class
MVStoreCursor
implements
Cursor
{
static
class
MVStoreCursor
implements
Cursor
{
private
final
Session
session
;
private
final
Iterator
<
Entry
<
Value
,
Value
>>
it
;
...
...
h2/src/main/org/h2/mvstore/db/MVSecondaryIndex.java
浏览文件 @
f91fa5c2
...
...
@@ -120,7 +120,6 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
@Override
public
void
addBufferedRows
(
List
<
String
>
bufferNames
)
{
ArrayList
<
String
>
mapNames
=
new
ArrayList
<>(
bufferNames
);
CompareMode
compareMode
=
database
.
getCompareMode
();
int
buffersCount
=
bufferNames
.
size
();
Queue
<
Source
>
queue
=
new
PriorityQueue
<>(
buffersCount
,
new
Source
.
Comparator
(
compareMode
));
...
...
@@ -155,7 +154,7 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
}
}
}
finally
{
for
(
String
tempMapName
:
map
Names
)
{
for
(
String
tempMapName
:
buffer
Names
)
{
MVMap
<
ValueArray
,
Value
>
map
=
openMap
(
tempMapName
);
map
.
getStore
().
removeMap
(
map
);
}
...
...
h2/src/main/org/h2/mvstore/db/MVSpatialIndex.java
浏览文件 @
f91fa5c2
...
...
@@ -49,7 +49,6 @@ public class MVSpatialIndex extends BaseIndex implements SpatialIndex, MVIndex {
*/
final
MVTable
mvTable
;
private
final
String
mapName
;
private
final
TransactionMap
<
SpatialKey
,
Value
>
dataMap
;
private
final
MVRTreeMap
<
VersionedValue
>
spatialMap
;
...
...
@@ -93,7 +92,7 @@ public class MVSpatialIndex extends BaseIndex implements SpatialIndex, MVIndex {
if
(!
database
.
isStarting
())
{
checkIndexColumnTypes
(
columns
);
}
mapName
=
"index."
+
getId
();
String
mapName
=
"index."
+
getId
();
ValueDataType
vt
=
new
ValueDataType
(
null
,
null
,
null
);
VersionedValue
.
Type
valueType
=
new
VersionedValue
.
Type
(
vt
);
MVRTreeMap
.
Builder
<
VersionedValue
>
mapBuilder
=
...
...
h2/src/main/org/h2/schema/Schema.java
浏览文件 @
f91fa5c2
...
...
@@ -672,10 +672,9 @@ public class Schema extends DbObjectBase {
public
void
remove
(
SchemaObject
obj
)
{
String
objName
=
obj
.
getName
();
Map
<
String
,
SchemaObject
>
map
=
getMap
(
obj
.
getType
());
if
(
SysProperties
.
CHECK
&&
!
map
.
containsKey
(
objName
)
)
{
if
(
map
.
remove
(
objName
)
==
null
)
{
DbException
.
throwInternalError
(
"not found: "
+
objName
);
}
map
.
remove
(
objName
);
freeUniqueName
(
objName
);
}
...
...
h2/src/main/org/h2/server/web/WebApp.java
浏览文件 @
f91fa5c2
...
...
@@ -301,7 +301,7 @@ public class WebApp {
for
(
Map
.
Entry
<
String
,
String
>
entry
:
map
.
entrySet
())
{
String
key
=
entry
.
getKey
();
String
value
=
entry
.
getValue
();
String
type
=
""
+
key
.
charAt
(
0
);
String
type
=
String
.
valueOf
(
key
.
charAt
(
0
)
);
if
(
Integer
.
parseInt
(
type
)
>
2
)
{
continue
;
}
...
...
@@ -1182,14 +1182,14 @@ public class WebApp {
rs
.
addRow
(
"conn.getCatalog"
,
conn
.
getCatalog
());
rs
.
addRow
(
"conn.getAutoCommit"
,
Boolean
.
toString
(
conn
.
getAutoCommit
()));
rs
.
addRow
(
"conn.getTransactionIsolation"
,
Integer
.
toString
(
conn
.
getTransactionIsolation
()));
rs
.
addRow
(
"conn.getWarnings"
,
""
+
conn
.
getWarnings
(
));
rs
.
addRow
(
"conn.getWarnings"
,
String
.
valueOf
(
conn
.
getWarnings
()
));
String
map
;
try
{
map
=
""
+
conn
.
getTypeMap
(
);
map
=
String
.
valueOf
(
conn
.
getTypeMap
()
);
}
catch
(
SQLException
e
)
{
map
=
e
.
toString
();
}
rs
.
addRow
(
"conn.getTypeMap"
,
""
+
map
);
rs
.
addRow
(
"conn.getTypeMap"
,
map
);
rs
.
addRow
(
"conn.isReadOnly"
,
Boolean
.
toString
(
conn
.
isReadOnly
()));
rs
.
addRow
(
"conn.getHoldability"
,
Integer
.
toString
(
conn
.
getHoldability
()));
addDatabaseMetaData
(
rs
,
meta
);
...
...
@@ -1229,7 +1229,7 @@ public class WebApp {
if
(
m
.
getParameterTypes
().
length
==
0
)
{
try
{
Object
o
=
m
.
invoke
(
meta
);
rs
.
addRow
(
"meta."
+
m
.
getName
(),
""
+
o
);
rs
.
addRow
(
"meta."
+
m
.
getName
(),
String
.
valueOf
(
o
)
);
}
catch
(
InvocationTargetException
e
)
{
rs
.
addRow
(
"meta."
+
m
.
getName
(),
e
.
getTargetException
().
toString
());
}
catch
(
Exception
e
)
{
...
...
h2/src/main/org/h2/store/FileLock.java
浏览文件 @
f91fa5c2
...
...
@@ -73,7 +73,7 @@ public class FileLock implements Runnable {
*/
private
long
lastWrite
;
private
String
method
,
ipAddress
;
private
String
method
;
private
Properties
properties
;
private
String
uniqueId
;
private
Thread
watchdog
;
...
...
@@ -350,7 +350,7 @@ public class FileLock implements Runnable {
setUniqueId
();
// if this returns 127.0.0.1,
// the computer is probably not networked
ipAddress
=
NetUtils
.
getLocalAddress
();
String
ipAddress
=
NetUtils
.
getLocalAddress
();
FileUtils
.
createDirectories
(
FileUtils
.
getParent
(
fileName
));
if
(!
FileUtils
.
createFile
(
fileName
))
{
waitUntilOld
();
...
...
h2/src/main/org/h2/store/LobStorageMap.java
浏览文件 @
f91fa5c2
...
...
@@ -60,14 +60,6 @@ public class LobStorageMap implements LobStorageInterface {
*/
private
MVMap
<
Object
[],
Boolean
>
refMap
;
/**
* The stream store data map.
*
* Key: stream store block id (long).
* Value: data (byte[]).
*/
private
MVMap
<
Long
,
byte
[]>
dataMap
;
private
StreamStore
streamStore
;
public
LobStorageMap
(
Database
database
)
{
...
...
@@ -90,7 +82,13 @@ public class LobStorageMap implements LobStorageInterface {
}
lobMap
=
mvStore
.
openMap
(
"lobMap"
);
refMap
=
mvStore
.
openMap
(
"lobRef"
);
dataMap
=
mvStore
.
openMap
(
"lobData"
);
/* The stream store data map.
*
* Key: stream store block id (long).
* Value: data (byte[]).
*/
MVMap
<
Long
,
byte
[]>
dataMap
=
mvStore
.
openMap
(
"lobData"
);
streamStore
=
new
StreamStore
(
dataMap
);
// garbage collection of the last blocks
if
(
database
.
isReadOnly
())
{
...
...
@@ -279,8 +277,7 @@ public class LobStorageMap implements LobStorageInterface {
if
(
lob
.
getTableId
()
==
LobStorageFrontend
.
TABLE_RESULT
||
lob
.
getTableId
()
==
LobStorageFrontend
.
TABLE_ID_SESSION_VARIABLE
)
{
throw
DbException
.
get
(
ErrorCode
.
LOB_CLOSED_ON_TIMEOUT_1
,
""
+
lob
.
getLobId
()
+
"/"
+
lob
.
getTableId
());
ErrorCode
.
LOB_CLOSED_ON_TIMEOUT_1
,
lob
.
getLobId
()
+
"/"
+
lob
.
getTableId
());
}
throw
DbException
.
throwInternalError
(
"Lob not found: "
+
lob
.
getLobId
()
+
"/"
+
lob
.
getTableId
());
...
...
h2/src/main/org/h2/table/MetaTable.java
浏览文件 @
f91fa5c2
...
...
@@ -1764,11 +1764,11 @@ public class MetaTable extends Table {
// SELECTIVITY INT
Integer
.
toString
(
col
.
getSelectivity
()),
// CHECK_CONSTRAINT
""
+
col
.
getCheckConstraintSQL
(
session
,
"VALUE"
),
col
.
getCheckConstraintSQL
(
session
,
"VALUE"
),
// REMARKS
replaceNullWithEmpty
(
dt
.
getComment
()),
// SQL
""
+
dt
.
getCreateSQL
(),
dt
.
getCreateSQL
(),
// ID
Integer
.
toString
(
dt
.
getId
())
);
...
...
h2/src/main/org/h2/tools/SimpleResultSet.java
浏览文件 @
f91fa5c2
...
...
@@ -606,8 +606,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData,
*/
@Override
public
Clob
getClob
(
int
columnIndex
)
throws
SQLException
{
Clob
c
=
(
Clob
)
get
(
columnIndex
);
return
c
==
null
?
null
:
c
;
return
(
Clob
)
get
(
columnIndex
);
}
/**
...
...
h2/src/main/org/h2/util/ColumnNamer.java
浏览文件 @
f91fa5c2
...
...
@@ -18,14 +18,12 @@ public class ColumnNamer {
private
static
final
String
DEFAULT_COLUMN_NAME
=
"DEFAULT"
;
private
final
ColumnNamerConfiguration
configuration
;
private
final
Session
session
;
private
final
Set
<
String
>
existingColumnNames
=
new
HashSet
<>();
public
ColumnNamer
(
Session
session
)
{
this
.
session
=
session
;
if
(
this
.
session
!=
null
&&
this
.
session
.
getColumnNamerConfiguration
()
!=
null
)
{
if
(
session
!=
null
&&
session
.
getColumnNamerConfiguration
()
!=
null
)
{
// use original from session
this
.
configuration
=
this
.
session
.
getColumnNamerConfiguration
();
this
.
configuration
=
session
.
getColumnNamerConfiguration
();
}
else
{
// detached namer, create new
this
.
configuration
=
ColumnNamerConfiguration
.
getDefault
();
...
...
h2/src/main/org/h2/util/ThreadDeadlockDetector.java
浏览文件 @
f91fa5c2
...
...
@@ -32,13 +32,13 @@ public class ThreadDeadlockDetector {
private
final
ThreadMXBean
threadBean
;
// a daemon thread
private
final
Timer
threadCheck
=
new
Timer
(
"ThreadDeadlockDetector"
,
true
);
private
ThreadDeadlockDetector
()
{
this
.
threadBean
=
ManagementFactory
.
getThreadMXBean
();
// a daemon thread
// delay: 10 ms
// period: 10000 ms (100 seconds)
Timer
threadCheck
=
new
Timer
(
"ThreadDeadlockDetector"
,
true
);
threadCheck
.
schedule
(
new
TimerTask
()
{
@Override
public
void
run
()
{
...
...
@@ -194,4 +194,4 @@ public class ThreadDeadlockDetector {
print
.
println
();
}
}
\ No newline at end of file
}
h2/src/main/org/h2/value/CaseInsensitiveConcurrentMap.java
deleted
100644 → 0
浏览文件 @
bd752cd4
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
value
;
import
java.util.concurrent.ConcurrentHashMap
;
import
org.h2.util.StringUtils
;
/**
* A concurrent hash map with a case-insensitive string key, that also allows
* NULL as a key.
*
* @param <V> the value type
*/
public
class
CaseInsensitiveConcurrentMap
<
V
>
extends
ConcurrentHashMap
<
String
,
V
>
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
String
NULL
=
new
String
(
new
byte
[
0
]);
@Override
public
V
get
(
Object
key
)
{
return
super
.
get
(
toUpper
(
key
));
}
@Override
public
V
put
(
String
key
,
V
value
)
{
return
super
.
put
(
toUpper
(
key
),
value
);
}
@Override
public
boolean
containsKey
(
Object
key
)
{
return
super
.
containsKey
(
toUpper
(
key
));
}
@Override
public
V
remove
(
Object
key
)
{
return
super
.
remove
(
toUpper
(
key
));
}
private
static
String
toUpper
(
Object
key
)
{
return
key
==
null
?
NULL
:
StringUtils
.
toUpperEnglish
(
key
.
toString
());
}
}
h2/src/main/org/h2/value/NullableKeyConcurrentMap.java
浏览文件 @
f91fa5c2
...
...
@@ -7,15 +7,29 @@ package org.h2.value;
import
java.util.concurrent.ConcurrentHashMap
;
import
org.h2.util.StringUtils
;
/**
* A concurrent hash map
that allows null keys
* A concurrent hash map
with string keys that allows null keys.
*
* @param <V> the value type
*/
public
class
NullableKeyConcurrentMap
<
V
>
extends
ConcurrentHashMap
<
String
,
V
>
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
String
NULL
=
new
String
(
new
byte
[
0
]);
private
static
final
String
NULL
=
new
String
();
private
final
boolean
toUpper
;
/**
* Create new instance of map.
*
* @param toUpper
* whether keys should be converted to upper case
*/
public
NullableKeyConcurrentMap
(
boolean
toUpper
)
{
this
.
toUpper
=
toUpper
;
}
@Override
public
V
get
(
Object
key
)
{
...
...
@@ -37,8 +51,12 @@ public class NullableKeyConcurrentMap<V> extends ConcurrentHashMap<String, V> {
return
super
.
remove
(
toUpper
(
key
));
}
private
static
String
toUpper
(
Object
key
)
{
return
key
==
null
?
NULL
:
key
.
toString
();
private
String
toUpper
(
Object
key
)
{
if
(
key
==
null
)
{
return
NULL
;
}
String
s
=
key
.
toString
();
return
toUpper
?
StringUtils
.
toUpperEnglish
(
s
)
:
s
;
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论