Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
e9cebe85
提交
e9cebe85
authored
7 年前
作者:
andrei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code review comments addressed
上级
a4a52a3e
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
21 行增加
和
12 行删除
+21
-12
MVMap.java
h2/src/main/org/h2/mvstore/MVMap.java
+20
-11
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+1
-1
没有找到文件。
h2/src/main/org/h2/mvstore/MVMap.java
浏览文件 @
e9cebe85
...
...
@@ -28,7 +28,8 @@ import org.h2.mvstore.type.StringDataType;
* @param <V> the value class
*/
public
class
MVMap
<
K
,
V
>
extends
AbstractMap
<
K
,
V
>
implements
ConcurrentMap
<
K
,
V
>,
Cloneable
{
implements
ConcurrentMap
<
K
,
V
>
{
/**
* The store.
...
...
@@ -53,7 +54,15 @@ public class MVMap<K, V> extends AbstractMap<K, V>
private
boolean
readOnly
;
private
boolean
isVolatile
;
/**
* This is a magic number for a version parameter in setNewRoot() call
* which meens "keep version the same it is now".
*/
private
static
final
long
KEEP_CURRENT
=
-
2
;
/**
* This designates the "last stored" version for a store which was
* just open for the first time.
*/
public
static
final
long
INITIAL_VERSION
=
-
1
;
protected
MVMap
(
Map
<
String
,
Object
>
config
)
{
...
...
@@ -814,7 +823,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
RootReference
previous
=
currentRoot
;
long
updateCounter
=
1
;
if
(
currentRoot
!=
null
)
{
if
(
obeyLock
&&
currentRoot
.
semaphor
e
)
{
if
(
obeyLock
&&
currentRoot
.
lockedForUpdat
e
)
{
return
null
;
}
...
...
@@ -1184,7 +1193,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
/**
* Indicator that map is locked for update.
*/
public
final
boolean
semaphor
e
;
public
final
boolean
lockedForUpdat
e
;
/**
* Reference to the previous root in the chain.
*/
...
...
@@ -1200,13 +1209,13 @@ public class MVMap<K, V> extends AbstractMap<K, V>
private
RootReference
(
Page
root
,
long
version
,
RootReference
previous
,
long
updateCounter
,
long
updateAttemptCounter
,
boolean
semaphor
e
)
{
boolean
lockedForUpdat
e
)
{
this
.
root
=
root
;
this
.
version
=
version
;
this
.
previous
=
previous
;
this
.
updateCounter
=
updateCounter
;
this
.
updateAttemptCounter
=
updateAttemptCounter
;
this
.
semaphore
=
semaphor
e
;
this
.
lockedForUpdate
=
lockedForUpdat
e
;
}
// This one is used for locking
...
...
@@ -1216,7 +1225,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
this
.
previous
=
r
.
previous
;
this
.
updateCounter
=
r
.
updateCounter
;
this
.
updateAttemptCounter
=
r
.
updateAttemptCounter
;
this
.
semaphor
e
=
true
;
this
.
lockedForUpdat
e
=
true
;
}
// This one is used for unlocking
...
...
@@ -1226,7 +1235,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
this
.
previous
=
r
.
previous
;
this
.
updateCounter
=
r
.
updateCounter
+
1
;
this
.
updateAttemptCounter
=
r
.
updateAttemptCounter
+
attempt
;
this
.
semaphor
e
=
false
;
this
.
lockedForUpdat
e
=
false
;
}
// This one is used for version change
...
...
@@ -1241,7 +1250,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
this
.
previous
=
previous
;
this
.
updateCounter
=
r
.
updateCounter
+
1
;
this
.
updateAttemptCounter
=
r
.
updateAttemptCounter
+
attempt
;
this
.
semaphore
=
r
.
semaphor
e
;
this
.
lockedForUpdate
=
r
.
lockedForUpdat
e
;
}
// This one is used for r/o snapshots
...
...
@@ -1251,12 +1260,12 @@ public class MVMap<K, V> extends AbstractMap<K, V>
this
.
previous
=
null
;
this
.
updateCounter
=
1
;
this
.
updateAttemptCounter
=
1
;
this
.
semaphor
e
=
false
;
this
.
lockedForUpdat
e
=
false
;
}
@Override
public
String
toString
()
{
return
"RootReference("
+
System
.
identityHashCode
(
root
)+
","
+
version
+
","
+
semaphor
e
+
")"
;
return
"RootReference("
+
System
.
identityHashCode
(
root
)+
","
+
version
+
","
+
lockedForUpdat
e
+
")"
;
}
}
...
...
@@ -1652,7 +1661,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
}
private
boolean
lockRoot
(
RootReference
rootReference
)
{
return
!
rootReference
.
semaphor
e
return
!
rootReference
.
lockedForUpdat
e
&&
root
.
compareAndSet
(
rootReference
,
new
RootReference
(
rootReference
));
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
e9cebe85
...
...
@@ -2758,7 +2758,7 @@ public final class MVStore {
return
fileStore
!=
null
&&
fileStore
.
isReadOnly
();
}
public
synchronized
double
getUpdateFailureRatio
()
{
public
double
getUpdateFailureRatio
()
{
long
updateCounter
=
this
.
updateCounter
;
long
updateAttemptCounter
=
this
.
updateAttemptCounter
;
MVMap
.
RootReference
rootReference
=
meta
.
getRoot
();
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论