Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
00947d99
提交
00947d99
authored
11 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MVStore: the file format was changed slightly.
上级
2ed0a04b
master
noel-pr1
plus33-master
pr/267
stumc-Issue#576
version-1.4.198
version-1.4.197
version-1.4.196
version-1.4.195
version-1.4.194
version-1.4.193
version-1.4.192
version-1.4.191
version-1.4.190
version-1.4.188
version-1.4.187
version-1.4.186
version-1.4.185
version-1.4.184
version-1.4.183
version-1.4.182
version-1.4.181
version-1.4.178
version-1.4.177
version-1.3
无相关合并请求
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
55 行增加
和
18 行删除
+55
-18
Chunk.java
h2/src/main/org/h2/mvstore/Chunk.java
+7
-1
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+44
-13
MVStoreTool.java
h2/src/main/org/h2/mvstore/MVStoreTool.java
+2
-2
TestMVStore.java
h2/src/test/org/h2/test/store/TestMVStore.java
+1
-1
TestStreamStore.java
h2/src/test/org/h2/test/store/TestStreamStore.java
+1
-1
没有找到文件。
h2/src/main/org/h2/mvstore/Chunk.java
浏览文件 @
00947d99
...
...
@@ -23,6 +23,12 @@ public class Chunk {
*/
static
final
int
MAX_HEADER_LENGTH
=
1024
;
/**
* The length of the chunk footer. The longest footer is:
* chunk:ffffffff,block:ffffffffffffffff,version:ffffffffffffffff,fletcher:ffffffff
*/
static
final
int
FOOTER_LENGTH
=
128
;
/**
* The chunk id.
*/
...
...
@@ -217,7 +223,7 @@ public class Chunk {
byte
[]
bytes
=
buff
.
toString
().
getBytes
(
DataUtils
.
LATIN
);
int
checksum
=
DataUtils
.
getFletcher32
(
bytes
,
bytes
.
length
/
2
*
2
);
DataUtils
.
appendMap
(
buff
,
"fletcher"
,
checksum
);
while
(
buff
.
length
()
<
MVStore
.
CHUNK_
FOOTER_LENGTH
-
1
)
{
while
(
buff
.
length
()
<
Chunk
.
FOOTER_LENGTH
-
1
)
{
buff
.
append
(
' '
);
}
buff
.
append
(
"\n"
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
00947d99
...
...
@@ -149,11 +149,6 @@ public class MVStore {
*/
static
final
int
BLOCK_SIZE
=
4
*
1024
;
/**
* The maximum length of the store header.
*/
static
final
int
CHUNK_FOOTER_LENGTH
=
64
;
private
static
final
int
FORMAT_WRITE
=
1
;
private
static
final
int
FORMAT_READ
=
1
;
...
...
@@ -527,7 +522,7 @@ public class MVStore {
// we don't know yet which chunk and version are the newest
long
newestVersion
=
-
1
;
long
newestChunkBlock
=
-
1
;
// read the
last block of the file, and then the two first
blocks
// read the
first two
blocks
ByteBuffer
fileHeaderBlocks
=
fileStore
.
readFully
(
0
,
2
*
BLOCK_SIZE
);
byte
[]
buff
=
new
byte
[
BLOCK_SIZE
];
for
(
int
i
=
0
;
i
<=
BLOCK_SIZE
;
i
+=
BLOCK_SIZE
)
{
...
...
@@ -536,6 +531,13 @@ public class MVStore {
try
{
String
s
=
new
String
(
buff
,
0
,
BLOCK_SIZE
,
DataUtils
.
LATIN
).
trim
();
HashMap
<
String
,
String
>
m
=
DataUtils
.
parseMap
(
s
);
int
blockSize
=
DataUtils
.
readHexInt
(
m
,
"blockSize"
,
BLOCK_SIZE
);
if
(
blockSize
!=
BLOCK_SIZE
)
{
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_UNSUPPORTED_FORMAT
,
"Block size {0} is currently not supported"
,
blockSize
);
}
int
check
=
DataUtils
.
readHexInt
(
m
,
"fletcher"
,
0
);
m
.
remove
(
"fletcher"
);
s
=
s
.
substring
(
0
,
s
.
lastIndexOf
(
"fletcher"
)
-
1
);
...
...
@@ -579,9 +581,10 @@ public class MVStore {
}
lastStoredVersion
=
-
1
;
// read the chunk footer of the last block of the file
ByteBuffer
lastBlock
=
fileStore
.
readFully
(
fileStore
.
size
()
-
C
HUNK_FOOTER_LENGTH
,
CHUNK_
FOOTER_LENGTH
);
buff
=
new
byte
[
C
HUNK_
FOOTER_LENGTH
];
fileStore
.
size
()
-
C
hunk
.
FOOTER_LENGTH
,
Chunk
.
FOOTER_LENGTH
);
buff
=
new
byte
[
C
hunk
.
FOOTER_LENGTH
];
lastBlock
.
get
(
buff
);
// the following can fail for various reasons
try
{
...
...
@@ -604,7 +607,35 @@ public class MVStore {
}
}
catch
(
Exception
e
)
{
// ignore
}
}
// follow the chain of next chunks
long
testChunkBlock
=
newestChunkBlock
;
while
(
true
)
{
Chunk
header
;
try
{
header
=
readChunkHeader
(
testChunkBlock
);
}
catch
(
Exception
e
)
{
// ignore the exception, but exit the loop
break
;
}
if
(
header
.
version
<=
newestVersion
)
{
// we reached the end
break
;
}
fileHeader
.
put
(
"chunk"
,
header
.
id
);
fileHeader
.
put
(
"version"
,
header
.
version
);
fileHeader
.
put
(
"block"
,
testChunkBlock
);
newestChunkBlock
=
testChunkBlock
;
newestVersion
=
header
.
version
;
if
(
header
.
next
==
0
)
{
// try the chunk just after this one
testChunkBlock
=
header
.
block
+
header
.
len
;
}
else
{
testChunkBlock
=
header
.
next
;
}
}
if
(
newestChunkBlock
>
0
)
{
readMeta
(
newestChunkBlock
);
}
...
...
@@ -951,7 +982,7 @@ public class MVStore {
// add the store header and round to the next block
int
length
=
MathUtils
.
roundUpInt
(
chunkLength
+
C
HUNK_
FOOTER_LENGTH
,
BLOCK_SIZE
);
C
hunk
.
FOOTER_LENGTH
,
BLOCK_SIZE
);
buff
.
limit
(
length
);
// the length of the file that is still in use
...
...
@@ -1004,7 +1035,7 @@ public class MVStore {
c
.
writeChunkHeader
(
buff
,
headerLength
);
revertTemp
(
storeVersion
);
buff
.
position
(
buff
.
limit
()
-
C
HUNK_
FOOTER_LENGTH
);
buff
.
position
(
buff
.
limit
()
-
C
hunk
.
FOOTER_LENGTH
);
buff
.
put
(
c
.
getFooterBytes
());
buff
.
position
(
0
);
...
...
@@ -1303,7 +1334,7 @@ public class MVStore {
c
.
next
=
0
;
buff
.
position
(
0
);
c
.
writeChunkHeader
(
buff
,
chunkHeaderLen
);
buff
.
position
(
length
-
C
HUNK_
FOOTER_LENGTH
);
buff
.
position
(
length
-
C
hunk
.
FOOTER_LENGTH
);
buff
.
put
(
lastChunk
.
getFooterBytes
());
buff
.
position
(
0
);
write
(
end
,
buff
.
getBuffer
());
...
...
@@ -1341,7 +1372,7 @@ public class MVStore {
buff
.
position
(
0
);
c
.
block
=
pos
/
BLOCK_SIZE
;
c
.
writeChunkHeader
(
buff
,
chunkHeaderLen
);
buff
.
position
(
length
-
C
HUNK_
FOOTER_LENGTH
);
buff
.
position
(
length
-
C
hunk
.
FOOTER_LENGTH
);
buff
.
put
(
lastChunk
.
getFooterBytes
());
buff
.
position
(
0
);
write
(
pos
,
buff
.
getBuffer
());
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/MVStoreTool.java
浏览文件 @
00947d99
...
...
@@ -147,9 +147,9 @@ public class MVStoreTool {
}
}
}
chunk
.
position
(
chunk
.
limit
()
-
MVStore
.
CHUNK_
FOOTER_LENGTH
);
chunk
.
position
(
chunk
.
limit
()
-
Chunk
.
FOOTER_LENGTH
);
pw
.
println
(
" store header"
);
pw
.
println
(
" "
+
new
String
(
chunk
.
array
(),
chunk
.
position
(),
MVStore
.
CHUNK_
FOOTER_LENGTH
,
"UTF-8"
).
trim
());
pw
.
println
(
" "
+
new
String
(
chunk
.
array
(),
chunk
.
position
(),
Chunk
.
FOOTER_LENGTH
,
"UTF-8"
).
trim
());
}
}
catch
(
IOException
e
)
{
pw
.
println
(
"ERROR: "
+
e
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/store/TestMVStore.java
浏览文件 @
00947d99
...
...
@@ -1172,7 +1172,7 @@ public class TestMVStore extends TestBase {
assertEquals
(
0
,
m
.
size
());
s
.
commit
();
// ensure only nodes are read, but not leaves
assertEquals
(
4
0
,
s
.
getFileStore
().
getReadCount
());
assertEquals
(
4
1
,
s
.
getFileStore
().
getReadCount
());
assertTrue
(
s
.
getFileStore
().
getWriteCount
()
<
5
);
s
.
close
();
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/store/TestStreamStore.java
浏览文件 @
00947d99
...
...
@@ -97,7 +97,7 @@ public class TestStreamStore extends TestBase {
long
readCount
=
s
.
getFileStore
().
getReadCount
();
// the read count should be low because new blocks
// are appended at the end (not between existing blocks)
assertTrue
(
"rc: "
+
readCount
,
readCount
<
1
0
);
assertTrue
(
"rc: "
+
readCount
,
readCount
<
1
5
);
map
=
s
.
openMap
(
"data"
);
assertTrue
(
"size: "
+
map
.
size
(),
map
.
sizeAsLong
()
>=
200
);
s
.
close
();
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论