Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
2e880b99
提交
2e880b99
authored
2月 08, 2014
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MVStore: the file format was changed slightly.
上级
00947d99
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
28 行增加
和
44 行删除
+28
-44
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+27
-43
MVStoreTool.java
h2/src/main/org/h2/mvstore/MVStoreTool.java
+1
-1
没有找到文件。
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
2e880b99
...
@@ -66,12 +66,7 @@ TransactionStore:
...
@@ -66,12 +66,7 @@ TransactionStore:
MVStore:
MVStore:
- maybe let a chunk point to a list of potential next chunks
(so no fixed location header is needed), similar to a skip list
(options: just after the current chunk, list of next)
- document and review the file format
- document and review the file format
- the newest chunk is the one with the newest version
(not necessarily the one with the highest chunk id)
- automated 'kill process' and 'power failure' test
- automated 'kill process' and 'power failure' test
- update checkstyle
- update checkstyle
...
@@ -599,7 +594,6 @@ public class MVStore {
...
@@ -599,7 +594,6 @@ public class MVStore {
int
chunk
=
DataUtils
.
readHexInt
(
m
,
"chunk"
,
0
);
int
chunk
=
DataUtils
.
readHexInt
(
m
,
"chunk"
,
0
);
long
version
=
DataUtils
.
readHexLong
(
m
,
"version"
,
chunk
);
long
version
=
DataUtils
.
readHexLong
(
m
,
"version"
,
chunk
);
if
(
version
>
newestVersion
)
{
if
(
version
>
newestVersion
)
{
fileHeader
.
putAll
(
m
);
newestVersion
=
version
;
newestVersion
=
version
;
newestChunkBlock
=
DataUtils
.
readHexLong
(
m
,
"block"
,
0
);
newestChunkBlock
=
DataUtils
.
readHexLong
(
m
,
"block"
,
0
);
validHeader
=
true
;
validHeader
=
true
;
...
@@ -619,21 +613,16 @@ public class MVStore {
...
@@ -619,21 +613,16 @@ public class MVStore {
// ignore the exception, but exit the loop
// ignore the exception, but exit the loop
break
;
break
;
}
}
if
(
header
.
version
<
=
newestVersion
)
{
if
(
header
.
version
<
newestVersion
)
{
// we reached the end
// we
have
reached the end
break
;
break
;
}
}
fileHeader
.
put
(
"chunk"
,
header
.
id
);
fileHeader
.
put
(
"version"
,
header
.
version
);
fileHeader
.
put
(
"block"
,
testChunkBlock
);
newestChunkBlock
=
testChunkBlock
;
newestChunkBlock
=
testChunkBlock
;
newestVersion
=
header
.
version
;
newestVersion
=
header
.
version
;
if
(
header
.
next
==
0
)
{
if
(
header
.
next
==
0
||
header
.
next
>=
fileStore
.
size
()
/
BLOCK_SIZE
)
{
// try the chunk just after this one
break
;
testChunkBlock
=
header
.
block
+
header
.
len
;
}
else
{
testChunkBlock
=
header
.
next
;
}
}
testChunkBlock
=
header
.
next
;
}
}
if
(
newestChunkBlock
>
0
)
{
if
(
newestChunkBlock
>
0
)
{
...
@@ -686,7 +675,7 @@ public class MVStore {
...
@@ -686,7 +675,7 @@ public class MVStore {
}
}
}
}
private
byte
[]
getFileHeaderBytes
()
{
private
void
writeFileHeader
()
{
StringBuilder
buff
=
new
StringBuilder
(
"H:2"
);
StringBuilder
buff
=
new
StringBuilder
(
"H:2"
);
if
(
lastChunk
!=
null
)
{
if
(
lastChunk
!=
null
)
{
fileHeader
.
put
(
"chunk"
,
lastChunk
.
id
);
fileHeader
.
put
(
"chunk"
,
lastChunk
.
id
);
...
@@ -702,11 +691,7 @@ public class MVStore {
...
@@ -702,11 +691,7 @@ public class MVStore {
int
checksum
=
DataUtils
.
getFletcher32
(
bytes
,
bytes
.
length
/
2
*
2
);
int
checksum
=
DataUtils
.
getFletcher32
(
bytes
,
bytes
.
length
/
2
*
2
);
DataUtils
.
appendMap
(
buff
,
"fletcher"
,
checksum
);
DataUtils
.
appendMap
(
buff
,
"fletcher"
,
checksum
);
buff
.
append
(
"\n"
);
buff
.
append
(
"\n"
);
return
buff
.
toString
().
getBytes
(
DataUtils
.
LATIN
);
bytes
=
buff
.
toString
().
getBytes
(
DataUtils
.
LATIN
);
}
private
void
writeFileHeader
()
{
byte
[]
bytes
=
getFileHeaderBytes
();
ByteBuffer
header
=
ByteBuffer
.
allocate
(
2
*
BLOCK_SIZE
);
ByteBuffer
header
=
ByteBuffer
.
allocate
(
2
*
BLOCK_SIZE
);
header
.
put
(
bytes
);
header
.
put
(
bytes
);
header
.
position
(
BLOCK_SIZE
);
header
.
position
(
BLOCK_SIZE
);
...
@@ -1023,10 +1008,6 @@ public class MVStore {
...
@@ -1023,10 +1008,6 @@ public class MVStore {
long
predictedNextStart
=
fileStore
.
allocate
(
predictBlocks
*
BLOCK_SIZE
);
long
predictedNextStart
=
fileStore
.
allocate
(
predictBlocks
*
BLOCK_SIZE
);
fileStore
.
free
(
predictedNextStart
,
predictBlocks
*
BLOCK_SIZE
);
fileStore
.
free
(
predictedNextStart
,
predictBlocks
*
BLOCK_SIZE
);
c
.
next
=
predictedNextStart
/
BLOCK_SIZE
;
c
.
next
=
predictedNextStart
/
BLOCK_SIZE
;
if
(
c
.
next
==
c
.
block
+
c
.
len
)
{
// just after this chunk
c
.
next
=
0
;
}
}
else
{
}
else
{
// just after this chunk
// just after this chunk
c
.
next
=
0
;
c
.
next
=
0
;
...
@@ -1042,30 +1023,33 @@ public class MVStore {
...
@@ -1042,30 +1023,33 @@ public class MVStore {
write
(
filePos
,
buff
.
getBuffer
());
write
(
filePos
,
buff
.
getBuffer
());
releaseWriteBuffer
(
buff
);
releaseWriteBuffer
(
buff
);
// whether
to over
write the file header
// whether
we need to
write the file header
boolean
needHeader
=
false
;
boolean
needHeader
=
false
;
// whether to reset the list of next chunks
boolean
resetNextChain
=
false
;
if
(!
storeAtEndOfFile
)
{
if
(!
storeAtEndOfFile
)
{
if
(
lastChunk
==
null
)
{
if
(
lastChunk
==
null
)
{
needHeader
=
true
;
needHeader
=
true
;
}
else
if
(
lastChunk
.
block
+
lastChunk
.
len
==
c
.
block
)
{
}
else
if
(
lastChunk
.
next
!=
c
.
block
)
{
// just after the last chunk
// the last prediction did not matched
}
else
if
(
lastChunk
.
next
==
c
.
block
)
{
// the last matched
}
else
{
needHeader
=
true
;
needHeader
=
true
;
}
else
{
int
chunkId
=
DataUtils
.
readHexInt
(
fileHeader
,
"chunk"
,
0
);
if
(
lastChunk
.
id
-
chunkId
>
20
)
{
// we write after at least 20 entries
needHeader
=
true
;
}
else
{
while
(
chunkId
<=
lastChunk
.
id
)
{
if
(
chunks
.
get
(
chunkId
)
==
null
)
{
// one of the chunks in between
// was removed
needHeader
=
true
;
break
;
}
chunkId
++;
}
}
}
}
;
// TODO check the length of the list - if too large
// write anyway (lets assume 11 is too large)
;
// TODO verify that no chunk between the last known one
// and the current chunk were removed
;
// TODO remove this once we have implemented
// reading and once we have tests
needHeader
=
true
;
}
}
lastChunk
=
c
;
lastChunk
=
c
;
if
(
needHeader
)
{
if
(
needHeader
)
{
writeFileHeader
();
writeFileHeader
();
...
...
h2/src/main/org/h2/mvstore/MVStoreTool.java
浏览文件 @
2e880b99
...
@@ -148,7 +148,7 @@ public class MVStoreTool {
...
@@ -148,7 +148,7 @@ public class MVStoreTool {
}
}
}
}
chunk
.
position
(
chunk
.
limit
()
-
Chunk
.
FOOTER_LENGTH
);
chunk
.
position
(
chunk
.
limit
()
-
Chunk
.
FOOTER_LENGTH
);
pw
.
println
(
"
store head
er"
);
pw
.
println
(
"
chunk foot
er"
);
pw
.
println
(
" "
+
new
String
(
chunk
.
array
(),
chunk
.
position
(),
Chunk
.
FOOTER_LENGTH
,
"UTF-8"
).
trim
());
pw
.
println
(
" "
+
new
String
(
chunk
.
array
(),
chunk
.
position
(),
Chunk
.
FOOTER_LENGTH
,
"UTF-8"
).
trim
());
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论