Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
fd46653c
提交
fd46653c
authored
9月 08, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
New experimental feature SHUTDOWN DEFRAG.
上级
dc492ea5
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
49 行增加
和
13 行删除
+49
-13
PageDataLeaf.java
h2/src/main/org/h2/index/PageDataLeaf.java
+1
-1
Page.java
h2/src/main/org/h2/store/Page.java
+9
-1
PageFreeList.java
h2/src/main/org/h2/store/PageFreeList.java
+4
-0
PageStore.java
h2/src/main/org/h2/store/PageStore.java
+27
-11
PageStreamData.java
h2/src/main/org/h2/store/PageStreamData.java
+4
-0
PageStreamTrunk.java
h2/src/main/org/h2/store/PageStreamTrunk.java
+4
-0
没有找到文件。
h2/src/main/org/h2/index/PageDataLeaf.java
浏览文件 @
fd46653c
...
@@ -538,13 +538,13 @@ public class PageDataLeaf extends PageData {
...
@@ -538,13 +538,13 @@ public class PageDataLeaf extends PageData {
p2
.
writeData
();
p2
.
writeData
();
p2
.
data
.
truncate
(
index
.
getPageStore
().
getPageSize
());
p2
.
data
.
truncate
(
index
.
getPageStore
().
getPageSize
());
store
.
update
(
p2
);
store
.
update
(
p2
);
store
.
free
(
getPos
());
if
(
parentPageId
==
ROOT
)
{
if
(
parentPageId
==
ROOT
)
{
index
.
setRootPageId
(
session
,
newPos
);
index
.
setRootPageId
(
session
,
newPos
);
}
else
{
}
else
{
PageDataNode
p
=
(
PageDataNode
)
store
.
getPage
(
parentPageId
);
PageDataNode
p
=
(
PageDataNode
)
store
.
getPage
(
parentPageId
);
p
.
moveChild
(
getPos
(),
newPos
);
p
.
moveChild
(
getPos
(),
newPos
);
}
}
store
.
free
(
getPos
());
}
}
/**
/**
...
...
h2/src/main/org/h2/store/Page.java
浏览文件 @
fd46653c
...
@@ -10,7 +10,6 @@ import java.lang.reflect.Array;
...
@@ -10,7 +10,6 @@ import java.lang.reflect.Array;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.util.CacheObject
;
import
org.h2.util.CacheObject
;
/**
/**
* A page. Format:
* A page. Format:
* <ul><li>0-3: parent page id (0 for root)
* <ul><li>0-3: parent page id (0 for root)
...
@@ -253,4 +252,13 @@ public abstract class Page extends CacheObject {
...
@@ -253,4 +252,13 @@ public abstract class Page extends CacheObject {
}
}
}
}
/**
* If this page can be moved. Transaction log and free-list pages can not.
*
* @return true if moving is allowed
*/
public
boolean
canMove
()
{
return
true
;
}
}
}
h2/src/main/org/h2/store/PageFreeList.java
浏览文件 @
fd46653c
...
@@ -222,4 +222,8 @@ public class PageFreeList extends Page {
...
@@ -222,4 +222,8 @@ public class PageFreeList extends Page {
return
false
;
return
false
;
}
}
public
boolean
canMove
()
{
return
false
;
}
}
}
h2/src/main/org/h2/store/PageStore.java
浏览文件 @
fd46653c
...
@@ -520,24 +520,34 @@ public class PageStore implements CacheWriter {
...
@@ -520,24 +520,34 @@ public class PageStore implements CacheWriter {
}
}
}
}
recordPageReads
=
false
;
recordPageReads
=
false
;
int
target
=
MIN_PAGE_COUNT
-
1
;
for
(
int
i
=
0
;
i
<
recordedPagesList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
recordedPagesList
.
size
();
i
++)
{
writeBack
();
writeBack
();
cache
.
clear
();
int
source
=
recordedPagesList
.
get
(
i
);
int
a
=
MIN_PAGE_COUNT
+
i
;
Page
pageSource
=
getPage
(
source
);
int
b
=
recordedPagesList
.
get
(
i
);
if
(!
pageSource
.
canMove
())
{
if
(
a
==
b
)
{
continue
;
}
while
(
true
)
{
Page
pageTarget
=
getPage
(++
target
);
if
(
pageTarget
==
null
||
pageTarget
.
canMove
())
{
break
;
}
}
if
(
target
==
source
)
{
continue
;
continue
;
}
}
int
temp
=
getFirstFree
();
int
temp
=
getFirstFree
();
if
(
temp
==
-
1
)
{
if
(
temp
==
-
1
)
{
DbException
.
throwInternalError
(
"no free page for defrag"
);
DbException
.
throwInternalError
(
"no free page for defrag"
);
}
}
swap
(
a
,
b
,
temp
);
cache
.
clear
();
int
index
=
recordedPagesList
.
indexOf
(
a
);
swap
(
source
,
target
,
temp
);
int
index
=
recordedPagesList
.
indexOf
(
target
);
if
(
index
>=
0
)
{
if
(
index
>=
0
)
{
recordedPagesList
.
set
(
index
,
b
);
recordedPagesList
.
set
(
index
,
source
);
}
}
recordedPagesList
.
set
(
i
,
a
);
recordedPagesList
.
set
(
i
,
target
);
}
}
recordedPagesList
=
null
;
recordedPagesList
=
null
;
recordedPages
=
null
;
recordedPages
=
null
;
...
@@ -606,17 +616,23 @@ public class PageStore implements CacheWriter {
...
@@ -606,17 +616,23 @@ public class PageStore implements CacheWriter {
Page
pageA
=
null
;
Page
pageA
=
null
;
if
(
isUsed
(
a
))
{
if
(
isUsed
(
a
))
{
pageA
=
getPage
(
a
);
pageA
=
getPage
(
a
);
if
(
pageA
!=
null
)
{
pageA
.
moveTo
(
systemSession
,
free
);
pageA
.
moveTo
(
systemSession
,
free
);
}
free
(
a
);
free
(
a
);
}
}
if
(
isUsed
(
b
))
{
if
(
isUsed
(
b
))
{
Page
pageB
=
getPage
(
b
);
Page
pageB
=
getPage
(
b
);
if
(
pageB
!=
null
)
{
pageB
.
moveTo
(
systemSession
,
a
);
pageB
.
moveTo
(
systemSession
,
a
);
}
free
(
b
);
free
(
b
);
}
}
if
(
pageA
!=
null
)
{
if
(
pageA
!=
null
)
{
f
=
getPage
(
free
);
f
=
getPage
(
free
);
if
(
f
!=
null
)
{
f
.
moveTo
(
systemSession
,
b
);
f
.
moveTo
(
systemSession
,
b
);
}
free
(
free
);
free
(
free
);
}
}
}
}
...
...
h2/src/main/org/h2/store/PageStreamData.java
浏览文件 @
fd46653c
...
@@ -165,4 +165,8 @@ public class PageStreamData extends Page {
...
@@ -165,4 +165,8 @@ public class PageStreamData extends Page {
return
DATA_START
;
return
DATA_START
;
}
}
public
boolean
canMove
()
{
return
false
;
}
}
}
\ No newline at end of file
h2/src/main/org/h2/store/PageStreamTrunk.java
浏览文件 @
fd46653c
...
@@ -287,4 +287,8 @@ public class PageStreamTrunk extends Page {
...
@@ -287,4 +287,8 @@ public class PageStreamTrunk extends Page {
return
"page["
+
getPos
()
+
"] stream trunk key:"
+
logKey
+
" next:"
+
nextTrunk
;
return
"page["
+
getPos
()
+
"] stream trunk key:"
+
logKey
+
" next:"
+
nextTrunk
;
}
}
public
boolean
canMove
()
{
return
false
;
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论