Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
07e67c2d
Unverified
提交
07e67c2d
authored
5月 19, 2018
作者:
Evgenij Ryazanov
提交者:
GitHub
5月 19, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1145 from katzyn/misc
Reduce code duplication
上级
e2aa57fa
dc6f6f5f
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
30 行增加
和
93 行删除
+30
-93
Parser.java
h2/src/main/org/h2/command/Parser.java
+5
-35
Database.java
h2/src/main/org/h2/engine/Database.java
+1
-4
MVSecondaryIndex.java
h2/src/main/org/h2/mvstore/db/MVSecondaryIndex.java
+1
-2
Schema.java
h2/src/main/org/h2/schema/Schema.java
+1
-2
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
浏览文件 @
07e67c2d
...
@@ -208,7 +208,10 @@ public class Parser {
...
@@ -208,7 +208,10 @@ public class Parser {
new
Comparator
<
TableFilter
>()
{
new
Comparator
<
TableFilter
>()
{
@Override
@Override
public
int
compare
(
TableFilter
o1
,
TableFilter
o2
)
{
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
;
}
}
};
};
...
@@ -2160,41 +2163,8 @@ public class Parser {
...
@@ -2160,41 +2163,8 @@ public class Parser {
// Parser can reorder joined table filters, need to explicitly sort them
// Parser can reorder joined table filters, need to explicitly sort them
// to get the order as it was in the original query.
// to get the order as it was in the original query.
if
(
session
.
isForceJoinOrder
())
{
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
)
{
private
void
parseJoinTableFilter
(
TableFilter
top
,
final
Select
command
)
{
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
07e67c2d
...
@@ -73,7 +73,6 @@ import org.h2.util.SourceCompiler;
...
@@ -73,7 +73,6 @@ import org.h2.util.SourceCompiler;
import
org.h2.util.StringUtils
;
import
org.h2.util.StringUtils
;
import
org.h2.util.TempFileDeleter
;
import
org.h2.util.TempFileDeleter
;
import
org.h2.util.Utils
;
import
org.h2.util.Utils
;
import
org.h2.value.CaseInsensitiveConcurrentMap
;
import
org.h2.value.CaseInsensitiveMap
;
import
org.h2.value.CaseInsensitiveMap
;
import
org.h2.value.CompareMode
;
import
org.h2.value.CompareMode
;
import
org.h2.value.NullableKeyConcurrentMap
;
import
org.h2.value.NullableKeyConcurrentMap
;
...
@@ -2860,9 +2859,7 @@ public class Database implements DataHandler {
...
@@ -2860,9 +2859,7 @@ public class Database implements DataHandler {
* @return the hash map
* @return the hash map
*/
*/
public
<
V
>
ConcurrentHashMap
<
String
,
V
>
newConcurrentStringMap
()
{
public
<
V
>
ConcurrentHashMap
<
String
,
V
>
newConcurrentStringMap
()
{
return
dbSettings
.
databaseToUpper
?
return
new
NullableKeyConcurrentMap
<>(!
dbSettings
.
databaseToUpper
);
new
NullableKeyConcurrentMap
<
V
>()
:
new
CaseInsensitiveConcurrentMap
<
V
>();
}
}
/**
/**
...
...
h2/src/main/org/h2/mvstore/db/MVSecondaryIndex.java
浏览文件 @
07e67c2d
...
@@ -121,7 +121,6 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
...
@@ -121,7 +121,6 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
@Override
@Override
public
void
addBufferedRows
(
List
<
String
>
bufferNames
)
{
public
void
addBufferedRows
(
List
<
String
>
bufferNames
)
{
ArrayList
<
String
>
mapNames
=
new
ArrayList
<>(
bufferNames
);
CompareMode
compareMode
=
database
.
getCompareMode
();
CompareMode
compareMode
=
database
.
getCompareMode
();
int
buffersCount
=
bufferNames
.
size
();
int
buffersCount
=
bufferNames
.
size
();
Queue
<
Source
>
queue
=
new
PriorityQueue
<>(
buffersCount
,
new
Source
.
Comparator
(
compareMode
));
Queue
<
Source
>
queue
=
new
PriorityQueue
<>(
buffersCount
,
new
Source
.
Comparator
(
compareMode
));
...
@@ -156,7 +155,7 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
...
@@ -156,7 +155,7 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
}
}
}
}
}
finally
{
}
finally
{
for
(
String
tempMapName
:
map
Names
)
{
for
(
String
tempMapName
:
buffer
Names
)
{
MVMap
<
ValueArray
,
Value
>
map
=
openMap
(
tempMapName
);
MVMap
<
ValueArray
,
Value
>
map
=
openMap
(
tempMapName
);
map
.
getStore
().
removeMap
(
map
);
map
.
getStore
().
removeMap
(
map
);
}
}
...
...
h2/src/main/org/h2/schema/Schema.java
浏览文件 @
07e67c2d
...
@@ -672,10 +672,9 @@ public class Schema extends DbObjectBase {
...
@@ -672,10 +672,9 @@ public class Schema extends DbObjectBase {
public
void
remove
(
SchemaObject
obj
)
{
public
void
remove
(
SchemaObject
obj
)
{
String
objName
=
obj
.
getName
();
String
objName
=
obj
.
getName
();
Map
<
String
,
SchemaObject
>
map
=
getMap
(
obj
.
getType
());
Map
<
String
,
SchemaObject
>
map
=
getMap
(
obj
.
getType
());
if
(
SysProperties
.
CHECK
&&
!
map
.
containsKey
(
objName
)
)
{
if
(
map
.
remove
(
objName
)
==
null
)
{
DbException
.
throwInternalError
(
"not found: "
+
objName
);
DbException
.
throwInternalError
(
"not found: "
+
objName
);
}
}
map
.
remove
(
objName
);
freeUniqueName
(
objName
);
freeUniqueName
(
objName
);
}
}
...
...
h2/src/main/org/h2/value/CaseInsensitiveConcurrentMap.java
deleted
100644 → 0
浏览文件 @
e2aa57fa
/*
* 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
浏览文件 @
07e67c2d
...
@@ -7,15 +7,29 @@ package org.h2.value;
...
@@ -7,15 +7,29 @@ package org.h2.value;
import
java.util.concurrent.ConcurrentHashMap
;
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
* @param <V> the value type
*/
*/
public
class
NullableKeyConcurrentMap
<
V
>
extends
ConcurrentHashMap
<
String
,
V
>
{
public
class
NullableKeyConcurrentMap
<
V
>
extends
ConcurrentHashMap
<
String
,
V
>
{
private
static
final
long
serialVersionUID
=
1L
;
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
@Override
public
V
get
(
Object
key
)
{
public
V
get
(
Object
key
)
{
...
@@ -37,8 +51,12 @@ public class NullableKeyConcurrentMap<V> extends ConcurrentHashMap<String, V> {
...
@@ -37,8 +51,12 @@ public class NullableKeyConcurrentMap<V> extends ConcurrentHashMap<String, V> {
return
super
.
remove
(
toUpper
(
key
));
return
super
.
remove
(
toUpper
(
key
));
}
}
private
static
String
toUpper
(
Object
key
)
{
private
String
toUpper
(
Object
key
)
{
return
key
==
null
?
NULL
:
key
.
toString
();
if
(
key
==
null
)
{
return
NULL
;
}
String
s
=
key
.
toString
();
return
toUpper
?
StringUtils
.
toUpperEnglish
(
s
)
:
s
;
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论