Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
35d966ee
提交
35d966ee
authored
7月 18, 2008
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
The database file was growing after deleting many rows, and after large update operations.
上级
f10983aa
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
35 行增加
和
2 行删除
+35
-2
Storage.java
h2/src/main/org/h2/store/Storage.java
+35
-2
没有找到文件。
h2/src/main/org/h2/store/Storage.java
浏览文件 @
35d966ee
...
@@ -43,6 +43,7 @@ public class Storage {
...
@@ -43,6 +43,7 @@ public class Storage {
private
DiskFile
file
;
private
DiskFile
file
;
private
int
recordCount
;
private
int
recordCount
;
private
RecordReader
reader
;
private
RecordReader
reader
;
private
int
freeCount
;
private
IntArray
freeList
=
new
IntArray
();
private
IntArray
freeList
=
new
IntArray
();
private
IntArray
pages
=
new
IntArray
();
private
IntArray
pages
=
new
IntArray
();
private
int
id
;
private
int
id
;
...
@@ -221,15 +222,43 @@ public class Storage {
...
@@ -221,15 +222,43 @@ public class Storage {
}
}
}
}
private
void
refillFreeList
()
{
if
(
freeList
.
size
()
!=
0
||
freeCount
==
0
)
{
return
;
}
BitField
used
=
file
.
getUsed
();
for
(
int
i
=
0
;
i
<
pages
.
size
();
i
++)
{
int
p
=
pages
.
get
(
i
);
int
block
=
DiskFile
.
BLOCKS_PER_PAGE
*
p
;
for
(
int
j
=
0
;
j
<
DiskFile
.
BLOCKS_PER_PAGE
;
j
++)
{
if
(!
used
.
get
(
block
))
{
if
(
freeList
.
size
()
<
FREE_LIST_SIZE
)
{
freeList
.
add
(
block
);
}
else
{
return
;
}
}
block
++;
}
}
// if we came here, all free records must be in the list
// otherwise it would have returned early
if
(
SysProperties
.
CHECK
&&
freeCount
>
freeList
.
size
())
{
throw
Message
.
getInternalError
(
"freeCount expected "
+
freeList
.
size
()
+
", got: "
+
freeCount
);
}
freeCount
=
freeList
.
size
();
}
private
int
allocate
(
int
blockCount
)
throws
SQLException
{
private
int
allocate
(
int
blockCount
)
throws
SQLException
{
refillFreeList
();
if
(
freeList
.
size
()
>
0
)
{
if
(
freeList
.
size
()
>
0
)
{
synchronized
(
database
)
{
synchronized
(
database
)
{
BitField
used
=
file
.
getUsed
();
BitField
used
=
file
.
getUsed
();
for
(
int
i
=
0
;
i
<
freeList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
freeList
.
size
();
i
++)
{
int
px
=
freeList
.
get
(
i
);
int
px
=
freeList
.
get
(
i
);
if
(
used
.
get
(
px
))
{
if
(
used
.
get
(
px
))
{
// sometime
there may stay
some entries in the freeList
// sometime
s
some entries in the freeList
//
that
are not free (free 2, free 1, allocate 1+2)
// are not free (free 2, free 1, allocate 1+2)
// these entries are removed right here
// these entries are removed right here
freeList
.
remove
(
i
--);
freeList
.
remove
(
i
--);
}
else
{
}
else
{
...
@@ -237,6 +266,7 @@ public class Storage {
...
@@ -237,6 +266,7 @@ public class Storage {
int
pos
=
px
;
int
pos
=
px
;
freeList
.
remove
(
i
);
freeList
.
remove
(
i
);
file
.
setUsed
(
pos
,
blockCount
);
file
.
setUsed
(
pos
,
blockCount
);
freeCount
-=
blockCount
;
return
pos
;
return
pos
;
}
}
}
}
...
@@ -245,6 +275,7 @@ public class Storage {
...
@@ -245,6 +275,7 @@ public class Storage {
}
}
int
pos
=
file
.
allocate
(
this
,
blockCount
);
int
pos
=
file
.
allocate
(
this
,
blockCount
);
file
.
setUsed
(
pos
,
blockCount
);
file
.
setUsed
(
pos
,
blockCount
);
freeCount
-=
blockCount
;
return
pos
;
return
pos
;
}
}
...
@@ -259,6 +290,7 @@ public class Storage {
...
@@ -259,6 +290,7 @@ public class Storage {
if
(
freeList
.
size
()
<
FREE_LIST_SIZE
)
{
if
(
freeList
.
size
()
<
FREE_LIST_SIZE
)
{
freeList
.
add
(
pos
);
freeList
.
add
(
pos
);
}
}
freeCount
+=
blockCount
;
}
}
// private int allocateBest(int start, int blocks) {
// private int allocateBest(int start, int blocks) {
...
@@ -299,6 +331,7 @@ public class Storage {
...
@@ -299,6 +331,7 @@ public class Storage {
*/
*/
public
void
truncate
(
Session
session
)
throws
SQLException
{
public
void
truncate
(
Session
session
)
throws
SQLException
{
freeList
=
new
IntArray
();
freeList
=
new
IntArray
();
freeCount
=
0
;
recordCount
=
0
;
recordCount
=
0
;
file
.
truncateStorage
(
session
,
this
,
pages
);
file
.
truncateStorage
(
session
,
this
,
pages
);
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论