Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
a7221d4a
提交
a7221d4a
authored
1月 05, 2019
作者:
Noel Grandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
javadoc for MVMap
上级
86777f9f
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
66 行增加
和
1 行删除
+66
-1
MVMap.java
h2/src/main/org/h2/mvstore/MVMap.java
+66
-1
没有找到文件。
h2/src/main/org/h2/mvstore/MVMap.java
浏览文件 @
a7221d4a
...
@@ -109,6 +109,11 @@ public class MVMap<K, V> extends AbstractMap<K, V>
...
@@ -109,6 +109,11 @@ public class MVMap<K, V> extends AbstractMap<K, V>
this
.
singleWriter
=
singleWriter
;
this
.
singleWriter
=
singleWriter
;
}
}
/**
* Clone the current map.
*
* @return clone of this.
*/
protected
MVMap
<
K
,
V
>
cloneIt
()
{
protected
MVMap
<
K
,
V
>
cloneIt
()
{
return
new
MVMap
<>(
this
);
return
new
MVMap
<>(
this
);
}
}
...
@@ -786,6 +791,11 @@ public class MVMap<K, V> extends AbstractMap<K, V>
...
@@ -786,6 +791,11 @@ public class MVMap<K, V> extends AbstractMap<K, V>
return
root
.
get
();
return
root
.
get
();
}
}
/**
* Get the root reference, flushing any current append buffer.
*
* @return current root reference
*/
public
RootReference
flushAndGetRoot
()
{
public
RootReference
flushAndGetRoot
()
{
RootReference
rootReference
=
getRoot
();
RootReference
rootReference
=
getRoot
();
if
(
singleWriter
&&
rootReference
.
getAppendCounter
()
>
0
)
{
if
(
singleWriter
&&
rootReference
.
getAppendCounter
()
>
0
)
{
...
@@ -799,6 +809,12 @@ public class MVMap<K, V> extends AbstractMap<K, V>
...
@@ -799,6 +809,12 @@ public class MVMap<K, V> extends AbstractMap<K, V>
while
(
setNewRoot
(
null
,
rootPage
,
++
attempt
,
false
)
==
null
)
{
/**/
}
while
(
setNewRoot
(
null
,
rootPage
,
++
attempt
,
false
)
==
null
)
{
/**/
}
}
}
/**
* Set the initial root.
*
* @param rootPage root page
* @param version initial version
*/
final
void
setInitialRoot
(
Page
rootPage
,
long
version
)
{
final
void
setInitialRoot
(
Page
rootPage
,
long
version
)
{
root
.
set
(
new
RootReference
(
rootPage
,
version
));
root
.
set
(
new
RootReference
(
rootPage
,
version
));
}
}
...
@@ -860,6 +876,11 @@ public class MVMap<K, V> extends AbstractMap<K, V>
...
@@ -860,6 +876,11 @@ public class MVMap<K, V> extends AbstractMap<K, V>
}
}
}
}
/**
* Roll the root back to the specified version.
*
* @param version to rollback to
*/
void
rollbackRoot
(
long
version
)
void
rollbackRoot
(
long
version
)
{
{
RootReference
rootReference
=
flushAndGetRoot
();
RootReference
rootReference
=
flushAndGetRoot
();
...
@@ -1071,6 +1092,12 @@ public class MVMap<K, V> extends AbstractMap<K, V>
...
@@ -1071,6 +1092,12 @@ public class MVMap<K, V> extends AbstractMap<K, V>
rootReference
.
version
:
previous
.
version
;
rootReference
.
version
:
previous
.
version
;
}
}
/**
* Does the root have changes since the specified version?
*
* @param version root version
* @return true if has changes
*/
final
boolean
hasChangesSince
(
long
version
)
{
final
boolean
hasChangesSince
(
long
version
)
{
RootReference
rootReference
=
getRoot
();
RootReference
rootReference
=
getRoot
();
Page
root
=
rootReference
.
root
;
Page
root
=
rootReference
.
root
;
...
@@ -1144,10 +1171,20 @@ public class MVMap<K, V> extends AbstractMap<K, V>
...
@@ -1144,10 +1171,20 @@ public class MVMap<K, V> extends AbstractMap<K, V>
}
}
}
}
/**
* Create empty leaf node page.
*
* @return new page
*/
public
Page
createEmptyLeaf
()
{
public
Page
createEmptyLeaf
()
{
return
Page
.
createEmptyLeaf
(
this
);
return
Page
.
createEmptyLeaf
(
this
);
}
}
/**
* Create empty internal node page.
*
* @return new page
*/
protected
Page
createEmptyNode
()
{
protected
Page
createEmptyNode
()
{
return
Page
.
createEmptyNode
(
this
);
return
Page
.
createEmptyNode
(
this
);
}
}
...
@@ -1601,6 +1638,11 @@ public class MVMap<K, V> extends AbstractMap<K, V>
...
@@ -1601,6 +1638,11 @@ public class MVMap<K, V> extends AbstractMap<K, V>
return
create
(
config
);
return
create
(
config
);
}
}
/**
* Create map from config.
* @param config config map
* @return new map
*/
protected
abstract
M
create
(
Map
<
String
,
Object
>
config
);
protected
abstract
M
create
(
Map
<
String
,
Object
>
config
);
}
}
...
@@ -1665,6 +1707,9 @@ public class MVMap<K, V> extends AbstractMap<K, V>
...
@@ -1665,6 +1707,9 @@ public class MVMap<K, V> extends AbstractMap<K, V>
*/
*/
public
abstract
static
class
DecisionMaker
<
V
>
public
abstract
static
class
DecisionMaker
<
V
>
{
{
/**
* Decision maker for transaction rollback.
*/
public
static
final
DecisionMaker
<
Object
>
DEFAULT
=
new
DecisionMaker
<
Object
>()
{
public
static
final
DecisionMaker
<
Object
>
DEFAULT
=
new
DecisionMaker
<
Object
>()
{
@Override
@Override
public
Decision
decide
(
Object
existingValue
,
Object
providedValue
)
{
public
Decision
decide
(
Object
existingValue
,
Object
providedValue
)
{
...
@@ -1677,6 +1722,9 @@ public class MVMap<K, V> extends AbstractMap<K, V>
...
@@ -1677,6 +1722,9 @@ public class MVMap<K, V> extends AbstractMap<K, V>
}
}
};
};
/**
* Decision maker for put().
*/
public
static
final
DecisionMaker
<
Object
>
PUT
=
new
DecisionMaker
<
Object
>()
{
public
static
final
DecisionMaker
<
Object
>
PUT
=
new
DecisionMaker
<
Object
>()
{
@Override
@Override
public
Decision
decide
(
Object
existingValue
,
Object
providedValue
)
{
public
Decision
decide
(
Object
existingValue
,
Object
providedValue
)
{
...
@@ -1689,6 +1737,9 @@ public class MVMap<K, V> extends AbstractMap<K, V>
...
@@ -1689,6 +1737,9 @@ public class MVMap<K, V> extends AbstractMap<K, V>
}
}
};
};
/**
* Decision maker for remove().
*/
public
static
final
DecisionMaker
<
Object
>
REMOVE
=
new
DecisionMaker
<
Object
>()
{
public
static
final
DecisionMaker
<
Object
>
REMOVE
=
new
DecisionMaker
<
Object
>()
{
@Override
@Override
public
Decision
decide
(
Object
existingValue
,
Object
providedValue
)
{
public
Decision
decide
(
Object
existingValue
,
Object
providedValue
)
{
...
@@ -1701,6 +1752,9 @@ public class MVMap<K, V> extends AbstractMap<K, V>
...
@@ -1701,6 +1752,9 @@ public class MVMap<K, V> extends AbstractMap<K, V>
}
}
};
};
/**
* Decision maker for putIfAbsent() key/value.
*/
static
final
DecisionMaker
<
Object
>
IF_ABSENT
=
new
DecisionMaker
<
Object
>()
{
static
final
DecisionMaker
<
Object
>
IF_ABSENT
=
new
DecisionMaker
<
Object
>()
{
@Override
@Override
public
Decision
decide
(
Object
existingValue
,
Object
providedValue
)
{
public
Decision
decide
(
Object
existingValue
,
Object
providedValue
)
{
...
@@ -1713,7 +1767,10 @@ public class MVMap<K, V> extends AbstractMap<K, V>
...
@@ -1713,7 +1767,10 @@ public class MVMap<K, V> extends AbstractMap<K, V>
}
}
};
};
static
final
DecisionMaker
<
Object
>
IF_PRESENT
=
new
DecisionMaker
<
Object
>()
{
/**
* Decision maker for replace().
*/
static
final
DecisionMaker
<
Object
>
IF_PRESENT
=
new
DecisionMaker
<
Object
>()
{
@Override
@Override
public
Decision
decide
(
Object
existingValue
,
Object
providedValue
)
{
public
Decision
decide
(
Object
existingValue
,
Object
providedValue
)
{
return
existingValue
!=
null
?
Decision
.
PUT
:
Decision
.
ABORT
;
return
existingValue
!=
null
?
Decision
.
PUT
:
Decision
.
ABORT
;
...
@@ -1757,6 +1814,14 @@ public class MVMap<K, V> extends AbstractMap<K, V>
...
@@ -1757,6 +1814,14 @@ public class MVMap<K, V> extends AbstractMap<K, V>
public
void
reset
()
{}
public
void
reset
()
{}
}
}
/**
* Apply an operation to a key-value pair.
*
* @param key key to operate on
* @param value new value
* @param decisionMaker command object to make choices during transaction.
* @return new value
*/
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
public
V
operate
(
K
key
,
V
value
,
DecisionMaker
<?
super
V
>
decisionMaker
)
{
public
V
operate
(
K
key
,
V
value
,
DecisionMaker
<?
super
V
>
decisionMaker
)
{
beforeWrite
();
beforeWrite
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论