Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
a4a52a3e
提交
a4a52a3e
authored
3月 29, 2018
作者:
andrei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rollback and versions
上级
5116b071
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
17 行增加
和
21 行删除
+17
-21
MVMap.java
h2/src/main/org/h2/mvstore/MVMap.java
+1
-2
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+7
-6
TestMVStore.java
h2/src/test/org/h2/test/store/TestMVStore.java
+9
-13
没有找到文件。
h2/src/main/org/h2/mvstore/MVMap.java
浏览文件 @
a4a52a3e
...
@@ -1049,8 +1049,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
...
@@ -1049,8 +1049,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
RootReference
rootReference
=
getRoot
();
RootReference
rootReference
=
getRoot
();
RootReference
previous
=
rootReference
.
previous
;
RootReference
previous
=
rootReference
.
previous
;
return
previous
==
null
||
previous
.
root
!=
rootReference
.
root
?
return
previous
==
null
||
previous
.
root
!=
rootReference
.
root
?
rootReference
.
version
:
rootReference
.
version
:
previous
.
version
;
previous
.
version
==
INITIAL_VERSION
?
store
.
getLastStoredVersion
()
:
previous
.
version
;
}
}
final
boolean
hasChangesSince
(
long
version
)
{
final
boolean
hasChangesSince
(
long
version
)
{
...
...
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
a4a52a3e
...
@@ -740,6 +740,9 @@ public final class MVStore {
...
@@ -740,6 +740,9 @@ public final class MVStore {
}
while
((
newest
=
verifyLastChunks
())
!=
null
);
}
while
((
newest
=
verifyLastChunks
())
!=
null
);
setWriteVersion
(
currentVersion
);
setWriteVersion
(
currentVersion
);
if
(
lastStoredVersion
==
INITIAL_VERSION
)
{
lastStoredVersion
=
currentVersion
-
1
;
}
}
}
private
void
loadChunkMeta
()
{
private
void
loadChunkMeta
()
{
...
@@ -2330,6 +2333,7 @@ public final class MVStore {
...
@@ -2330,6 +2333,7 @@ public final class MVStore {
currentVersion
=
version
;
currentVersion
=
version
;
setWriteVersion
(
version
);
setWriteVersion
(
version
);
metaChanged
=
false
;
metaChanged
=
false
;
lastStoredVersion
=
INITIAL_VERSION
;
return
;
return
;
}
}
DataUtils
.
checkArgument
(
DataUtils
.
checkArgument
(
...
@@ -2401,13 +2405,10 @@ public final class MVStore {
...
@@ -2401,13 +2405,10 @@ public final class MVStore {
}
}
}
}
}
}
// rollback might have rolled back the stored chunk metadata as well
if
(
lastChunk
!=
null
)
{
for
(
Chunk
c
:
chunks
.
values
())
{
meta
.
put
(
Chunk
.
getMetaKey
(
c
.
id
),
c
.
asString
());
}
}
currentVersion
=
version
;
currentVersion
=
version
;
if
(
lastStoredVersion
==
INITIAL_VERSION
)
{
lastStoredVersion
=
currentVersion
-
1
;
}
}
}
private
static
long
getRootPos
(
MVMap
<
String
,
String
>
map
,
int
mapId
)
{
private
static
long
getRootPos
(
MVMap
<
String
,
String
>
map
,
int
mapId
)
{
...
...
h2/src/test/org/h2/test/store/TestMVStore.java
浏览文件 @
a4a52a3e
...
@@ -833,9 +833,6 @@ public class TestMVStore extends TestBase {
...
@@ -833,9 +833,6 @@ public class TestMVStore extends TestBase {
}
}
s
.
close
();
s
.
close
();
int
[]
expectedReadsForCacheSize
=
{
int
[]
expectedReadsForCacheSize
=
{
// 3407, 2590, 1924, 1440, 1330, 956, 918
// 1880, 1789, 1578, 1374, 995, 711, 541
// 942, 1789, 1578, 1374, 995, 711, 541
1880
,
1789
,
1616
,
1374
,
970
,
711
,
541
// compressed
1880
,
1789
,
1616
,
1374
,
970
,
711
,
541
// compressed
// 1887, 1775, 1599, 1355, 1035, 732, 507 // uncompressed
// 1887, 1775, 1599, 1355, 1035, 732, 507 // uncompressed
};
};
...
@@ -1372,7 +1369,6 @@ public class TestMVStore extends TestBase {
...
@@ -1372,7 +1369,6 @@ public class TestMVStore extends TestBase {
s
.
close
();
s
.
close
();
s
=
openStore
(
fileName
);
s
=
openStore
(
fileName
);
s
.
setAutoCommitDelay
(
0
);
m
=
s
.
openMap
(
"data"
);
m
=
s
.
openMap
(
"data"
);
assertEquals
(
"Hi"
,
m
.
get
(
"1"
));
assertEquals
(
"Hi"
,
m
.
get
(
"1"
));
assertEquals
(
null
,
m
.
get
(
"2"
));
assertEquals
(
null
,
m
.
get
(
"2"
));
...
@@ -1381,7 +1377,7 @@ public class TestMVStore extends TestBase {
...
@@ -1381,7 +1377,7 @@ public class TestMVStore extends TestBase {
// which is rather implementation artifact then intentional.
// which is rather implementation artifact then intentional.
// Once store is closed, only one sinle version of the data
// Once store is closed, only one sinle version of the data
// will exists upon re-opening - the latest.
// will exists upon re-opening - the latest.
// I hope nobody relies on this.
// I hope nobody relies on this
"multi-versioning"
.
/*
/*
mOld = m.openVersion(old3);
mOld = m.openVersion(old3);
assertEquals("Hallo", mOld.get("1"));
assertEquals("Hallo", mOld.get("1"));
...
@@ -1423,6 +1419,7 @@ public class TestMVStore extends TestBase {
...
@@ -1423,6 +1419,7 @@ public class TestMVStore extends TestBase {
}
}
}
}
assertTrue
(
s
.
compact
(
100
,
50
*
1024
));
assertTrue
(
s
.
compact
(
100
,
50
*
1024
));
// compaction alone will not guarantee file size reduction
s
.
compactMoveChunks
();
s
.
compactMoveChunks
();
s
.
close
();
s
.
close
();
long
len2
=
FileUtils
.
size
(
fileName
);
long
len2
=
FileUtils
.
size
(
fileName
);
...
@@ -1441,10 +1438,8 @@ public class TestMVStore extends TestBase {
...
@@ -1441,10 +1438,8 @@ public class TestMVStore extends TestBase {
assertEquals
(
i
+
1
,
m
.
size
());
assertEquals
(
i
+
1
,
m
.
size
());
}
}
assertEquals
(
1000
,
m
.
size
());
assertEquals
(
1000
,
m
.
size
());
// previously (131896) we fail to account for initial root page for every map
// memory calculations were adjusted, so as this out-of-the-thin-air number
// there are two of them here (meta and "data"), hence lack of 256 bytes
assertEquals
(
84730
,
s
.
getUnsavedMemory
());
// assertEquals(132152, s.getUnsavedMemory());
assertEquals
(
84940
,
s
.
getUnsavedMemory
());
s
.
commit
();
s
.
commit
();
assertEquals
(
2
,
s
.
getFileStore
().
getWriteCount
());
assertEquals
(
2
,
s
.
getFileStore
().
getWriteCount
());
s
.
close
();
s
.
close
();
...
@@ -1524,12 +1519,13 @@ public class TestMVStore extends TestBase {
...
@@ -1524,12 +1519,13 @@ public class TestMVStore extends TestBase {
assertNull
(
meta
.
get
(
"name.data1"
));
assertNull
(
meta
.
get
(
"name.data1"
));
assertNull
(
m0
.
get
(
"1"
));
assertNull
(
m0
.
get
(
"1"
));
assertEquals
(
"Hello"
,
m
.
get
(
"1"
));
assertEquals
(
"Hello"
,
m
.
get
(
"1"
));
assertEquals
(
3
,
s
.
commit
());
// no changes - no real commit here
assertEquals
(
2
,
s
.
commit
());
s
.
close
();
s
.
close
();
s
=
openStore
(
fileName
);
s
=
openStore
(
fileName
);
s
.
setRetentionTime
(
45000
);
s
.
setRetentionTime
(
45000
);
assertEquals
(
3
,
s
.
getCurrentVersion
());
assertEquals
(
2
,
s
.
getCurrentVersion
());
meta
=
s
.
getMetaMap
();
meta
=
s
.
getMetaMap
();
assertNotNull
(
meta
.
get
(
"name.data"
));
assertNotNull
(
meta
.
get
(
"name.data"
));
assertNotNull
(
meta
.
get
(
"name.data0"
));
assertNotNull
(
meta
.
get
(
"name.data0"
));
...
@@ -1542,12 +1538,12 @@ public class TestMVStore extends TestBase {
...
@@ -1542,12 +1538,12 @@ public class TestMVStore extends TestBase {
m
.
put
(
"1"
,
"Hallo"
);
m
.
put
(
"1"
,
"Hallo"
);
s
.
commit
();
s
.
commit
();
long
v3
=
s
.
getCurrentVersion
();
long
v3
=
s
.
getCurrentVersion
();
assertEquals
(
4
,
v3
);
assertEquals
(
3
,
v3
);
s
.
close
();
s
.
close
();
s
=
openStore
(
fileName
);
s
=
openStore
(
fileName
);
s
.
setRetentionTime
(
45000
);
s
.
setRetentionTime
(
45000
);
assertEquals
(
4
,
s
.
getCurrentVersion
());
assertEquals
(
3
,
s
.
getCurrentVersion
());
m
=
s
.
openMap
(
"data"
);
m
=
s
.
openMap
(
"data"
);
m
.
put
(
"1"
,
"Hi"
);
m
.
put
(
"1"
,
"Hi"
);
s
.
close
();
s
.
close
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论