Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
d378a757
提交
d378a757
authored
3月 02, 2015
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Consistently use the term "store header"
上级
42b11b0d
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
31 行增加
和
31 行删除
+31
-31
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+31
-31
没有找到文件。
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
d378a757
...
@@ -203,7 +203,7 @@ public class MVStore {
...
@@ -203,7 +203,7 @@ public class MVStore {
private
final
ConcurrentHashMap
<
Integer
,
MVMap
<?,
?>>
maps
=
private
final
ConcurrentHashMap
<
Integer
,
MVMap
<?,
?>>
maps
=
new
ConcurrentHashMap
<
Integer
,
MVMap
<?,
?>>();
new
ConcurrentHashMap
<
Integer
,
MVMap
<?,
?>>();
private
HashMap
<
String
,
Object
>
fil
eHeader
=
New
.
hashMap
();
private
HashMap
<
String
,
Object
>
stor
eHeader
=
New
.
hashMap
();
private
WriteBuffer
writeBuffer
;
private
WriteBuffer
writeBuffer
;
...
@@ -342,13 +342,13 @@ public class MVStore {
...
@@ -342,13 +342,13 @@ public class MVStore {
if
(
fileStore
.
size
()
==
0
)
{
if
(
fileStore
.
size
()
==
0
)
{
creationTime
=
getTime
();
creationTime
=
getTime
();
lastCommitTime
=
creationTime
;
lastCommitTime
=
creationTime
;
fil
eHeader
.
put
(
"H"
,
2
);
stor
eHeader
.
put
(
"H"
,
2
);
fil
eHeader
.
put
(
"blockSize"
,
BLOCK_SIZE
);
stor
eHeader
.
put
(
"blockSize"
,
BLOCK_SIZE
);
fil
eHeader
.
put
(
"format"
,
FORMAT_WRITE
);
stor
eHeader
.
put
(
"format"
,
FORMAT_WRITE
);
fil
eHeader
.
put
(
"created"
,
creationTime
);
stor
eHeader
.
put
(
"created"
,
creationTime
);
write
Fil
eHeader
();
write
Stor
eHeader
();
}
else
{
}
else
{
read
Fil
eHeader
();
read
Stor
eHeader
();
}
}
}
catch
(
IllegalStateException
e
)
{
}
catch
(
IllegalStateException
e
)
{
panic
(
e
);
panic
(
e
);
...
@@ -548,7 +548,7 @@ public class MVStore {
...
@@ -548,7 +548,7 @@ public class MVStore {
metaChanged
=
true
;
metaChanged
=
true
;
}
}
private
synchronized
void
read
Fil
eHeader
()
{
private
synchronized
void
read
Stor
eHeader
()
{
boolean
validHeader
=
false
;
boolean
validHeader
=
false
;
// we don't know yet which chunk and version are the newest
// we don't know yet which chunk and version are the newest
long
newestVersion
=
-
1
;
long
newestVersion
=
-
1
;
...
@@ -583,7 +583,7 @@ public class MVStore {
...
@@ -583,7 +583,7 @@ public class MVStore {
long
version
=
DataUtils
.
readHexLong
(
m
,
"version"
,
0
);
long
version
=
DataUtils
.
readHexLong
(
m
,
"version"
,
0
);
if
(
version
>
newestVersion
)
{
if
(
version
>
newestVersion
)
{
newestVersion
=
version
;
newestVersion
=
version
;
fil
eHeader
.
putAll
(
m
);
stor
eHeader
.
putAll
(
m
);
chunkBlock
=
DataUtils
.
readHexLong
(
m
,
"block"
,
0
);
chunkBlock
=
DataUtils
.
readHexLong
(
m
,
"block"
,
0
);
creationTime
=
DataUtils
.
readHexLong
(
m
,
"created"
,
0
);
creationTime
=
DataUtils
.
readHexLong
(
m
,
"created"
,
0
);
validHeader
=
true
;
validHeader
=
true
;
...
@@ -597,7 +597,7 @@ public class MVStore {
...
@@ -597,7 +597,7 @@ public class MVStore {
DataUtils
.
ERROR_FILE_CORRUPT
,
DataUtils
.
ERROR_FILE_CORRUPT
,
"Store header is corrupt: {0}"
,
fileStore
);
"Store header is corrupt: {0}"
,
fileStore
);
}
}
long
format
=
DataUtils
.
readHexLong
(
fil
eHeader
,
"format"
,
1
);
long
format
=
DataUtils
.
readHexLong
(
stor
eHeader
,
"format"
,
1
);
if
(
format
>
FORMAT_WRITE
&&
!
fileStore
.
isReadOnly
())
{
if
(
format
>
FORMAT_WRITE
&&
!
fileStore
.
isReadOnly
())
{
throw
DataUtils
.
newIllegalStateException
(
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_UNSUPPORTED_FORMAT
,
DataUtils
.
ERROR_UNSUPPORTED_FORMAT
,
...
@@ -606,7 +606,7 @@ public class MVStore {
...
@@ -606,7 +606,7 @@ public class MVStore {
"and the file was not opened in read-only mode"
,
"and the file was not opened in read-only mode"
,
format
,
FORMAT_WRITE
);
format
,
FORMAT_WRITE
);
}
}
format
=
DataUtils
.
readHexLong
(
fil
eHeader
,
"formatRead"
,
format
);
format
=
DataUtils
.
readHexLong
(
stor
eHeader
,
"formatRead"
,
format
);
if
(
format
>
FORMAT_READ
)
{
if
(
format
>
FORMAT_READ
)
{
throw
DataUtils
.
newIllegalStateException
(
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_UNSUPPORTED_FORMAT
,
DataUtils
.
ERROR_UNSUPPORTED_FORMAT
,
...
@@ -630,7 +630,7 @@ public class MVStore {
...
@@ -630,7 +630,7 @@ public class MVStore {
// the system time was set to the past:
// the system time was set to the past:
// we change the creation time
// we change the creation time
creationTime
=
now
;
creationTime
=
now
;
fil
eHeader
.
put
(
"created"
,
creationTime
);
stor
eHeader
.
put
(
"created"
,
creationTime
);
}
}
Chunk
footer
=
readChunkFooter
(
fileStore
.
size
());
Chunk
footer
=
readChunkFooter
(
fileStore
.
size
());
...
@@ -748,14 +748,14 @@ public class MVStore {
...
@@ -748,14 +748,14 @@ public class MVStore {
return
null
;
return
null
;
}
}
private
void
write
Fil
eHeader
()
{
private
void
write
Stor
eHeader
()
{
StringBuilder
buff
=
new
StringBuilder
();
StringBuilder
buff
=
new
StringBuilder
();
if
(
lastChunk
!=
null
)
{
if
(
lastChunk
!=
null
)
{
fil
eHeader
.
put
(
"block"
,
lastChunk
.
block
);
stor
eHeader
.
put
(
"block"
,
lastChunk
.
block
);
fil
eHeader
.
put
(
"chunk"
,
lastChunk
.
id
);
stor
eHeader
.
put
(
"chunk"
,
lastChunk
.
id
);
fil
eHeader
.
put
(
"version"
,
lastChunk
.
version
);
stor
eHeader
.
put
(
"version"
,
lastChunk
.
version
);
}
}
DataUtils
.
appendMap
(
buff
,
fil
eHeader
);
DataUtils
.
appendMap
(
buff
,
stor
eHeader
);
byte
[]
bytes
=
buff
.
toString
().
getBytes
(
DataUtils
.
LATIN
);
byte
[]
bytes
=
buff
.
toString
().
getBytes
(
DataUtils
.
LATIN
);
int
checksum
=
DataUtils
.
getFletcher32
(
bytes
,
bytes
.
length
);
int
checksum
=
DataUtils
.
getFletcher32
(
bytes
,
bytes
.
length
);
DataUtils
.
appendMap
(
buff
,
"fletcher"
,
checksum
);
DataUtils
.
appendMap
(
buff
,
"fletcher"
,
checksum
);
...
@@ -1118,28 +1118,28 @@ public class MVStore {
...
@@ -1118,28 +1118,28 @@ public class MVStore {
write
(
filePos
,
buff
.
getBuffer
());
write
(
filePos
,
buff
.
getBuffer
());
releaseWriteBuffer
(
buff
);
releaseWriteBuffer
(
buff
);
// whether we need to write the
fil
e header
// whether we need to write the
stor
e header
boolean
need
Header
=
false
;
boolean
writeStore
Header
=
false
;
if
(!
storeAtEndOfFile
)
{
if
(!
storeAtEndOfFile
)
{
if
(
lastChunk
==
null
)
{
if
(
lastChunk
==
null
)
{
need
Header
=
true
;
writeStore
Header
=
true
;
}
else
if
(
lastChunk
.
next
!=
c
.
block
)
{
}
else
if
(
lastChunk
.
next
!=
c
.
block
)
{
// the last prediction did not matched
// the last prediction did not matched
need
Header
=
true
;
writeStore
Header
=
true
;
}
else
{
}
else
{
long
headerVersion
=
DataUtils
.
readHexLong
(
long
headerVersion
=
DataUtils
.
readHexLong
(
fil
eHeader
,
"version"
,
0
);
stor
eHeader
,
"version"
,
0
);
if
(
lastChunk
.
version
-
headerVersion
>
20
)
{
if
(
lastChunk
.
version
-
headerVersion
>
20
)
{
// we write after at least 20 entries
// we write after at least 20 entries
need
Header
=
true
;
writeStore
Header
=
true
;
}
else
{
}
else
{
int
chunkId
=
DataUtils
.
readHexInt
(
fil
eHeader
,
"chunk"
,
0
);
int
chunkId
=
DataUtils
.
readHexInt
(
stor
eHeader
,
"chunk"
,
0
);
while
(
true
)
{
while
(
true
)
{
Chunk
old
=
chunks
.
get
(
chunkId
);
Chunk
old
=
chunks
.
get
(
chunkId
);
if
(
old
==
null
)
{
if
(
old
==
null
)
{
// one of the chunks in between
// one of the chunks in between
// was removed
// was removed
need
Header
=
true
;
writeStore
Header
=
true
;
break
;
break
;
}
}
if
(
chunkId
==
lastChunk
.
id
)
{
if
(
chunkId
==
lastChunk
.
id
)
{
...
@@ -1152,11 +1152,11 @@ public class MVStore {
...
@@ -1152,11 +1152,11 @@ public class MVStore {
}
}
lastChunk
=
c
;
lastChunk
=
c
;
if
(
need
Header
)
{
if
(
writeStore
Header
)
{
write
Fil
eHeader
();
write
Stor
eHeader
();
}
}
if
(!
storeAtEndOfFile
)
{
if
(!
storeAtEndOfFile
)
{
// may only shrink after the
fil
e header was written
// may only shrink after the
stor
e header was written
shrinkFileIfPossible
(
1
);
shrinkFileIfPossible
(
1
);
}
}
...
@@ -2213,8 +2213,8 @@ public class MVStore {
...
@@ -2213,8 +2213,8 @@ public class MVStore {
releaseWriteBuffer
(
buff
);
releaseWriteBuffer
(
buff
);
lastChunk
=
chunks
.
get
(
lastChunk
.
id
-
1
);
lastChunk
=
chunks
.
get
(
lastChunk
.
id
-
1
);
}
}
write
Fil
eHeader
();
write
Stor
eHeader
();
read
Fil
eHeader
();
read
Stor
eHeader
();
}
}
for
(
MVMap
<?,
?>
m
:
New
.
arrayList
(
maps
.
values
()))
{
for
(
MVMap
<?,
?>
m
:
New
.
arrayList
(
maps
.
values
()))
{
int
id
=
m
.
getId
();
int
id
=
m
.
getId
();
...
@@ -2285,7 +2285,7 @@ public class MVStore {
...
@@ -2285,7 +2285,7 @@ public class MVStore {
* @return the store header
* @return the store header
*/
*/
public
Map
<
String
,
Object
>
getStoreHeader
()
{
public
Map
<
String
,
Object
>
getStoreHeader
()
{
return
fil
eHeader
;
return
stor
eHeader
;
}
}
private
void
checkOpen
()
{
private
void
checkOpen
()
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论