Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
4ce2a984
Unverified
提交
4ce2a984
authored
7月 30, 2018
作者:
Evgenij Ryazanov
提交者:
GitHub
7月 30, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1341 from katzyn/misc
Optimize MVSecondaryIndex.convertToKey()
上级
9288feb5
2f2ccd38
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
11 行增加
和
18 行删除
+11
-18
MVSecondaryIndex.java
h2/src/main/org/h2/mvstore/db/MVSecondaryIndex.java
+11
-18
没有找到文件。
h2/src/main/org/h2/mvstore/db/MVSecondaryIndex.java
浏览文件 @
4ce2a984
...
@@ -79,7 +79,7 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
...
@@ -79,7 +79,7 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
public
void
addRowsToBuffer
(
List
<
Row
>
rows
,
String
bufferName
)
{
public
void
addRowsToBuffer
(
List
<
Row
>
rows
,
String
bufferName
)
{
MVMap
<
ValueArray
,
Value
>
map
=
openMap
(
bufferName
);
MVMap
<
ValueArray
,
Value
>
map
=
openMap
(
bufferName
);
for
(
Row
row
:
rows
)
{
for
(
Row
row
:
rows
)
{
ValueArray
key
=
convertToKey
(
row
);
ValueArray
key
=
convertToKey
(
row
,
null
);
map
.
append
(
key
,
ValueNull
.
INSTANCE
);
map
.
append
(
key
,
ValueNull
.
INSTANCE
);
}
}
}
}
...
@@ -185,7 +185,7 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
...
@@ -185,7 +185,7 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
@Override
@Override
public
void
add
(
Session
session
,
Row
row
)
{
public
void
add
(
Session
session
,
Row
row
)
{
TransactionMap
<
Value
,
Value
>
map
=
getMap
(
session
);
TransactionMap
<
Value
,
Value
>
map
=
getMap
(
session
);
ValueArray
array
=
convertToKey
(
row
);
ValueArray
array
=
convertToKey
(
row
,
null
);
boolean
checkRequired
=
indexType
.
isUnique
()
&&
!
mayHaveNullDuplicates
(
row
);
boolean
checkRequired
=
indexType
.
isUnique
()
&&
!
mayHaveNullDuplicates
(
row
);
if
(
checkRequired
)
{
if
(
checkRequired
)
{
checkUnique
(
map
,
array
,
Long
.
MIN_VALUE
);
checkUnique
(
map
,
array
,
Long
.
MIN_VALUE
);
...
@@ -203,7 +203,7 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
...
@@ -203,7 +203,7 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
}
}
private
void
checkUnique
(
TransactionMap
<
Value
,
Value
>
map
,
ValueArray
row
,
long
newKey
)
{
private
void
checkUnique
(
TransactionMap
<
Value
,
Value
>
map
,
ValueArray
row
,
long
newKey
)
{
Iterator
<
Value
>
it
=
map
.
keyIterator
(
convertToKey
(
row
,
Boolean
.
FALSE
),
convertToKey
(
row
,
Boolean
.
TRUE
),
true
);
Iterator
<
Value
>
it
=
map
.
keyIterator
(
convertToKey
(
row
,
ValueLong
.
MIN
),
convertToKey
(
row
,
ValueLong
.
MAX
),
true
);
while
(
it
.
hasNext
())
{
while
(
it
.
hasNext
())
{
ValueArray
rowData
=
(
ValueArray
)
it
.
next
();
ValueArray
rowData
=
(
ValueArray
)
it
.
next
();
Value
[]
array
=
rowData
.
getList
();
Value
[]
array
=
rowData
.
getList
();
...
@@ -221,7 +221,7 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
...
@@ -221,7 +221,7 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
@Override
@Override
public
void
remove
(
Session
session
,
Row
row
)
{
public
void
remove
(
Session
session
,
Row
row
)
{
ValueArray
array
=
convertToKey
(
row
);
ValueArray
array
=
convertToKey
(
row
,
null
);
TransactionMap
<
Value
,
Value
>
map
=
getMap
(
session
);
TransactionMap
<
Value
,
Value
>
map
=
getMap
(
session
);
try
{
try
{
Value
old
=
map
.
remove
(
array
);
Value
old
=
map
.
remove
(
array
);
...
@@ -261,26 +261,19 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
...
@@ -261,26 +261,19 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
}
}
private
Cursor
find
(
Session
session
,
SearchRow
first
,
boolean
bigger
,
SearchRow
last
)
{
private
Cursor
find
(
Session
session
,
SearchRow
first
,
boolean
bigger
,
SearchRow
last
)
{
ValueArray
min
=
convertToKey
(
convertToKey
(
first
),
bigger
);
ValueArray
min
=
convertToKey
(
first
,
bigger
?
ValueLong
.
MAX
:
ValueLong
.
MIN
);
ValueArray
max
=
convertToKey
(
convertToKey
(
last
),
Boolean
.
TRUE
);
ValueArray
max
=
convertToKey
(
last
,
ValueLong
.
MAX
);
TransactionMap
<
Value
,
Value
>
map
=
getMap
(
session
);
TransactionMap
<
Value
,
Value
>
map
=
getMap
(
session
);
return
new
MVStoreCursor
(
session
,
map
.
keyIterator
(
min
,
max
,
false
));
return
new
MVStoreCursor
(
session
,
map
.
keyIterator
(
min
,
max
,
false
));
}
}
private
static
ValueArray
convertToKey
(
ValueArray
r
,
Boolean
minmax
)
{
private
static
ValueArray
convertToKey
(
ValueArray
r
,
ValueLong
key
)
{
if
(
r
==
null
)
{
return
null
;
}
Value
[]
values
=
r
.
getList
().
clone
();
Value
[]
values
=
r
.
getList
().
clone
();
ValueArray
row
=
ValueArray
.
get
(
values
);
values
[
values
.
length
-
1
]
=
key
;
if
(
minmax
!=
null
)
{
return
ValueArray
.
get
(
values
);
values
[
values
.
length
-
1
]
=
ValueLong
.
get
(
minmax
?
Long
.
MAX_VALUE
:
Long
.
MIN_VALUE
);
}
return
row
;
}
}
private
ValueArray
convertToKey
(
SearchRow
r
)
{
private
ValueArray
convertToKey
(
SearchRow
r
,
ValueLong
key
)
{
if
(
r
==
null
)
{
if
(
r
==
null
)
{
return
null
;
return
null
;
}
}
...
@@ -293,7 +286,7 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
...
@@ -293,7 +286,7 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
array
[
i
]
=
v
.
convertTo
(
c
.
getType
(),
-
1
,
database
.
getMode
(),
null
,
c
.
getEnumerators
());
array
[
i
]
=
v
.
convertTo
(
c
.
getType
(),
-
1
,
database
.
getMode
(),
null
,
c
.
getEnumerators
());
}
}
}
}
array
[
keyColumns
-
1
]
=
ValueLong
.
get
(
r
.
getKey
());
array
[
keyColumns
-
1
]
=
key
!=
null
?
key
:
ValueLong
.
get
(
r
.
getKey
());
return
ValueArray
.
get
(
array
);
return
ValueArray
.
get
(
array
);
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论