Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
e2bf1a8c
提交
e2bf1a8c
authored
6月 28, 2018
作者:
Andrei Tokar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
properly convert appendCounter
上级
97709e50
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
21 行增加
和
14 行删除
+21
-14
MVMap.java
h2/src/main/org/h2/mvstore/MVMap.java
+20
-13
TransactionMap.java
h2/src/main/org/h2/mvstore/tx/TransactionMap.java
+1
-1
没有找到文件。
h2/src/main/org/h2/mvstore/MVMap.java
浏览文件 @
e2bf1a8c
...
@@ -962,14 +962,14 @@ public class MVMap<K, V> extends AbstractMap<K, V>
...
@@ -962,14 +962,14 @@ public class MVMap<K, V> extends AbstractMap<K, V>
*/
*/
public
final
long
sizeAsLong
()
{
public
final
long
sizeAsLong
()
{
RootReference
rootReference
=
getRoot
();
RootReference
rootReference
=
getRoot
();
return
rootReference
.
root
.
getTotalCount
()
+
rootReference
.
appendCounter
;
return
rootReference
.
root
.
getTotalCount
()
+
rootReference
.
getAppendCounter
()
;
}
}
@Override
@Override
public
boolean
isEmpty
()
{
public
boolean
isEmpty
()
{
RootReference
rootReference
=
getRoot
();
RootReference
rootReference
=
getRoot
();
Page
rootPage
=
rootReference
.
root
;
Page
rootPage
=
rootReference
.
root
;
return
rootPage
.
isLeaf
()
&&
rootPage
.
getKeyCount
()
==
0
&&
rootReference
.
appendCounter
==
0
;
return
rootPage
.
isLeaf
()
&&
rootPage
.
getKeyCount
()
==
0
&&
rootReference
.
getAppendCounter
()
==
0
;
}
}
public
final
long
getCreateVersion
()
{
public
final
long
getCreateVersion
()
{
...
@@ -1179,7 +1179,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
...
@@ -1179,7 +1179,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
if
(
rootReference
==
null
)
{
if
(
rootReference
==
null
)
{
rootReference
=
getRoot
();
rootReference
=
getRoot
();
}
}
byte
keyCount
=
rootReference
.
appendCounter
;
int
keyCount
=
rootReference
.
getAppendCounter
()
;
if
(
keyCount
==
0
)
{
if
(
keyCount
==
0
)
{
break
;
break
;
}
}
...
@@ -1192,7 +1192,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
...
@@ -1192,7 +1192,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
break
;
break
;
}
}
}
}
assert
rootReference
.
appendCounter
==
0
;
assert
rootReference
.
getAppendCounter
()
==
0
;
return
rootReference
;
return
rootReference
;
}
}
...
@@ -1274,14 +1274,16 @@ public class MVMap<K, V> extends AbstractMap<K, V>
...
@@ -1274,14 +1274,16 @@ public class MVMap<K, V> extends AbstractMap<K, V>
boolean
success
=
false
;
boolean
success
=
false
;
while
(!
success
)
{
while
(!
success
)
{
RootReference
rootReference
=
getRoot
();
RootReference
rootReference
=
getRoot
();
if
(
rootReference
.
appendCounter
>=
keysPerPage
)
{
int
appendCounter
=
rootReference
.
getAppendCounter
();
if
(
appendCounter
>=
keysPerPage
)
{
rootReference
=
flushAppendBuffer
(
rootReference
);
rootReference
=
flushAppendBuffer
(
rootReference
);
assert
rootReference
.
appendCounter
<
keysPerPage
;
appendCounter
=
rootReference
.
getAppendCounter
();
assert
appendCounter
<
keysPerPage
;
}
}
keysBuffer
[
rootReference
.
appendCounter
]
=
key
;
keysBuffer
[
appendCounter
]
=
key
;
valuesBuffer
[
rootReference
.
appendCounter
]
=
value
;
valuesBuffer
[
appendCounter
]
=
value
;
RootReference
updatedRootReference
=
new
RootReference
(
rootReference
,
(
byte
)
(
rootReference
.
appendCounter
+
1
)
,
++
attempt
);
RootReference
updatedRootReference
=
new
RootReference
(
rootReference
,
appendCounter
+
1
,
++
attempt
);
success
=
root
.
compareAndSet
(
rootReference
,
updatedRootReference
);
success
=
root
.
compareAndSet
(
rootReference
,
updatedRootReference
);
}
}
}
}
...
@@ -1296,8 +1298,9 @@ public class MVMap<K, V> extends AbstractMap<K, V>
...
@@ -1296,8 +1298,9 @@ public class MVMap<K, V> extends AbstractMap<K, V>
boolean
success
;
boolean
success
;
do
{
do
{
RootReference
rootReference
=
getRoot
();
RootReference
rootReference
=
getRoot
();
if
(
rootReference
.
appendCounter
>
0
)
{
int
appendCounter
=
rootReference
.
getAppendCounter
();
RootReference
updatedRootReference
=
new
RootReference
(
rootReference
,
(
byte
)
(
rootReference
.
appendCounter
-
1
),
++
attempt
);
if
(
appendCounter
>
0
)
{
RootReference
updatedRootReference
=
new
RootReference
(
rootReference
,
appendCounter
-
1
,
++
attempt
);
success
=
root
.
compareAndSet
(
rootReference
,
updatedRootReference
);
success
=
root
.
compareAndSet
(
rootReference
,
updatedRootReference
);
}
else
{
}
else
{
assert
rootReference
.
root
.
getKeyCount
()
>
0
;
assert
rootReference
.
root
.
getKeyCount
()
>
0
;
...
@@ -1409,14 +1412,18 @@ public class MVMap<K, V> extends AbstractMap<K, V>
...
@@ -1409,14 +1412,18 @@ public class MVMap<K, V> extends AbstractMap<K, V>
}
}
// This one is used for append buffer maintance
// This one is used for append buffer maintance
RootReference
(
RootReference
r
,
byte
appendCounter
,
int
attempt
)
{
RootReference
(
RootReference
r
,
int
appendCounter
,
int
attempt
)
{
this
.
root
=
r
.
root
;
this
.
root
=
r
.
root
;
this
.
version
=
r
.
version
;
this
.
version
=
r
.
version
;
this
.
previous
=
r
.
previous
;
this
.
previous
=
r
.
previous
;
this
.
updateCounter
=
r
.
updateCounter
+
1
;
this
.
updateCounter
=
r
.
updateCounter
+
1
;
this
.
updateAttemptCounter
=
r
.
updateAttemptCounter
+
attempt
;
this
.
updateAttemptCounter
=
r
.
updateAttemptCounter
+
attempt
;
this
.
lockedForUpdate
=
r
.
lockedForUpdate
;
this
.
lockedForUpdate
=
r
.
lockedForUpdate
;
this
.
appendCounter
=
appendCounter
;
this
.
appendCounter
=
(
byte
)
appendCounter
;
}
public
int
getAppendCounter
()
{
return
appendCounter
&
0xff
;
}
}
@Override
@Override
...
...
h2/src/main/org/h2/mvstore/tx/TransactionMap.java
浏览文件 @
e2bf1a8c
...
@@ -90,7 +90,7 @@ public class TransactionMap<K, V> {
...
@@ -90,7 +90,7 @@ public class TransactionMap<K, V> {
if
(
undoLog
!=
null
)
{
if
(
undoLog
!=
null
)
{
MVMap
.
RootReference
rootReference
=
undoLog
.
flushAppendBuffer
();
MVMap
.
RootReference
rootReference
=
undoLog
.
flushAppendBuffer
();
undoLogRootReferences
[
i
]
=
rootReference
;
undoLogRootReferences
[
i
]
=
rootReference
;
undoLogSize
+=
rootReference
.
root
.
getTotalCount
()
+
rootReference
.
appendCounter
;
undoLogSize
+=
rootReference
.
root
.
getTotalCount
()
+
rootReference
.
getAppendCounter
()
;
}
}
}
}
}
while
(
committingTransactions
!=
store
.
committingTransactions
.
get
()
||
}
while
(
committingTransactions
!=
store
.
committingTransactions
.
get
()
||
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论