Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
04feaa24
提交
04feaa24
authored
12月 09, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improved performance, bugfix
上级
e67b6759
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
16 行增加
和
12 行删除
+16
-12
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+16
-12
没有找到文件。
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
04feaa24
...
@@ -299,8 +299,9 @@ public class MVStore {
...
@@ -299,8 +299,9 @@ public class MVStore {
segmentCount
,
stackMoveDistance
);
segmentCount
,
stackMoveDistance
);
}
}
o
=
config
.
get
(
"autoCommitBufferSize"
);
o
=
config
.
get
(
"autoCommitBufferSize"
);
mb
=
o
==
null
?
4
:
(
Integer
)
o
;
int
kb
=
o
==
null
?
512
:
(
Integer
)
o
;
int
autoCommitBufferSize
=
mb
*
1024
*
1024
;
// 19 KB memory is about 1 KB storage
int
autoCommitBufferSize
=
kb
*
1024
*
19
;
int
div
=
pageSplitSize
;
int
div
=
pageSplitSize
;
autoCommitPageCount
=
autoCommitBufferSize
/
(
div
==
0
?
1
:
div
);
autoCommitPageCount
=
autoCommitBufferSize
/
(
div
==
0
?
1
:
div
);
char
[]
encryptionKey
=
(
char
[])
config
.
get
(
"encryptionKey"
);
char
[]
encryptionKey
=
(
char
[])
config
.
get
(
"encryptionKey"
);
...
@@ -902,7 +903,9 @@ public class MVStore {
...
@@ -902,7 +903,9 @@ public class MVStore {
fileStore
.
free
(
x
.
start
,
len
);
fileStore
.
free
(
x
.
start
,
len
);
}
}
long
end
=
getEndPosition
();
// the length of the file that is still in use
// (not necessarily the end of the file)
long
end
=
getFileLengthInUse
();
long
filePos
;
long
filePos
;
if
(
reuseSpace
)
{
if
(
reuseSpace
)
{
filePos
=
fileStore
.
allocate
(
length
);
filePos
=
fileStore
.
allocate
(
length
);
...
@@ -910,7 +913,8 @@ public class MVStore {
...
@@ -910,7 +913,8 @@ public class MVStore {
filePos
=
end
;
filePos
=
end
;
fileStore
.
markUsed
(
end
,
length
);
fileStore
.
markUsed
(
end
,
length
);
}
}
boolean
storeAtEndOfFile
=
filePos
+
length
>=
end
;
// end is not necessarily the end of the file
boolean
storeAtEndOfFile
=
filePos
+
length
>=
fileStore
.
size
();
c
.
start
=
filePos
;
c
.
start
=
filePos
;
c
.
length
=
chunkLength
;
c
.
length
=
chunkLength
;
...
@@ -1078,7 +1082,7 @@ public class MVStore {
...
@@ -1078,7 +1082,7 @@ public class MVStore {
* @param minPercent the minimum percentage to save
* @param minPercent the minimum percentage to save
*/
*/
private
void
shrinkFileIfPossible
(
int
minPercent
)
{
private
void
shrinkFileIfPossible
(
int
minPercent
)
{
long
end
=
get
EndPosition
();
long
end
=
get
FileLengthInUse
();
long
fileSize
=
fileStore
.
size
();
long
fileSize
=
fileStore
.
size
();
if
(
end
>=
fileSize
)
{
if
(
end
>=
fileSize
)
{
return
;
return
;
...
@@ -1098,7 +1102,7 @@ public class MVStore {
...
@@ -1098,7 +1102,7 @@ public class MVStore {
*
*
* @return the position
* @return the position
*/
*/
private
long
get
EndPosition
()
{
private
long
get
FileLengthInUse
()
{
long
size
=
2
*
BLOCK_SIZE
;
long
size
=
2
*
BLOCK_SIZE
;
for
(
Chunk
c
:
chunks
.
values
())
{
for
(
Chunk
c
:
chunks
.
values
())
{
long
x
=
c
.
start
+
c
.
length
;
long
x
=
c
.
start
+
c
.
length
;
...
@@ -1184,7 +1188,7 @@ public class MVStore {
...
@@ -1184,7 +1188,7 @@ public class MVStore {
buff
.
limit
(
length
);
buff
.
limit
(
length
);
ByteBuffer
buff2
=
fileStore
.
readFully
(
c
.
start
,
length
);
ByteBuffer
buff2
=
fileStore
.
readFully
(
c
.
start
,
length
);
buff
.
put
(
buff2
);
buff
.
put
(
buff2
);
long
end
=
get
EndPosition
();
long
end
=
get
FileLengthInUse
();
fileStore
.
markUsed
(
end
,
length
);
fileStore
.
markUsed
(
end
,
length
);
fileStore
.
free
(
c
.
start
,
length
);
fileStore
.
free
(
c
.
start
,
length
);
c
.
start
=
end
;
c
.
start
=
end
;
...
@@ -2069,20 +2073,20 @@ public class MVStore {
...
@@ -2069,20 +2073,20 @@ public class MVStore {
}
}
/**
/**
* Set the size of the write buffer, in
M
B (for file-based stores).
* Set the size of the write buffer, in
K
B (for file-based stores).
* Unless auto-commit is disabled, changes are automatically saved if
* Unless auto-commit is disabled, changes are automatically saved if
* there are more than this amount of changes.
* there are more than this amount of changes.
* <p>
* <p>
* The default is
4 M
B.
* The default is
512 K
B.
* <p>
* <p>
* When the value is set to 0 or lower, data is not automatically
* When the value is set to 0 or lower, data is not automatically
* stored.
* stored.
*
*
* @param
mb the write buffer size, in mega
bytes
* @param
kb the write buffer size, in kilo
bytes
* @return this
* @return this
*/
*/
public
Builder
autoCommitBufferSize
(
int
m
b
)
{
public
Builder
autoCommitBufferSize
(
int
k
b
)
{
return
set
(
"autoCommitBufferSize"
,
m
b
);
return
set
(
"autoCommitBufferSize"
,
k
b
);
}
}
/**
/**
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论