Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
38ca7aba
提交
38ca7aba
authored
6月 28, 2018
作者:
Andrei Tokar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
address code review comments
上级
91a6e0a7
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
21 行增加
和
11 行删除
+21
-11
MVMap.java
h2/src/main/org/h2/mvstore/MVMap.java
+21
-11
没有找到文件。
h2/src/main/org/h2/mvstore/MVMap.java
浏览文件 @
38ca7aba
...
...
@@ -8,6 +8,7 @@ package org.h2.mvstore;
import
java.util.AbstractList
;
import
java.util.AbstractMap
;
import
java.util.AbstractSet
;
import
java.util.Arrays
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -960,13 +961,15 @@ public class MVMap<K, V> extends AbstractMap<K, V>
* @return the number of entries
*/
public
final
long
sizeAsLong
()
{
return
getRootPage
().
getTotalCount
();
RootReference
rootReference
=
getRoot
();
return
rootReference
.
root
.
getTotalCount
()
+
rootReference
.
appendCounter
;
}
@Override
public
boolean
isEmpty
()
{
Page
rootPage
=
getRootPage
();
return
rootPage
.
isLeaf
()
&&
rootPage
.
getKeyCount
()
==
0
;
RootReference
rootReference
=
getRoot
();
Page
rootPage
=
rootReference
.
root
;
return
rootPage
.
isLeaf
()
&&
rootPage
.
getKeyCount
()
==
0
&&
rootReference
.
appendCounter
==
0
;
}
public
final
long
getCreateVersion
()
{
...
...
@@ -1181,8 +1184,8 @@ public class MVMap<K, V> extends AbstractMap<K, V>
break
;
}
Page
page
=
Page
.
create
(
this
,
createAndFillStorage
(
keyCount
,
keysBuffer
),
createAndFillStorage
(
keyCount
,
valuesBuffer
),
Arrays
.
copyOf
(
keysBuffer
,
keyCount
),
Arrays
.
copyOf
(
valuesBuffer
,
keyCount
),
null
,
keyCount
,
0
);
rootReference
=
appendLeafPage
(
rootReference
,
page
,
++
attempt
);
if
(
rootReference
!=
null
)
{
...
...
@@ -1258,6 +1261,14 @@ public class MVMap<K, V> extends AbstractMap<K, V>
return
null
;
}
/**
* Appends entry to this map. this method is NOT thread safe and can not be used
* neither concurrently, nor in combination with any method that updates this map.
* Non-updating method may be used concurrently, but latest appended values
* are not guaranteed to be visible.
* @param key should be higher in map's order than any existing key
* @param value to be appended
*/
public
void
append
(
K
key
,
V
value
)
{
int
attempt
=
0
;
boolean
success
=
false
;
...
...
@@ -1275,6 +1286,11 @@ public class MVMap<K, V> extends AbstractMap<K, V>
}
}
/**
* Removes last entry from this map. this method is NOT thread safe and can not be used
* neither concurrently, nor in combination with any method that updates this map.
* Non-updating method may be used concurrently, but latest removal may not be visible.
*/
public
void
trimLast
()
{
int
attempt
=
0
;
boolean
success
;
...
...
@@ -1852,12 +1868,6 @@ public class MVMap<K, V> extends AbstractMap<K, V>
return
new
CursorPos
(
p
,
p
.
binarySearch
(
key
),
pos
);
}
private
static
Object
[]
createAndFillStorage
(
int
count
,
Object
dataBuffer
[])
{
Object
storage
[]
=
new
Object
[
count
];
System
.
arraycopy
(
dataBuffer
,
0
,
storage
,
0
,
count
);
return
storage
;
}
private
static
final
class
EqualsDecisionMaker
<
V
>
extends
DecisionMaker
<
V
>
{
private
final
DataType
dataType
;
private
final
V
expectedValue
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论