Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
e91be706
提交
e91be706
authored
10月 01, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Page store bugfixes.
上级
fa1a87b4
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
84 行增加
和
85 行删除
+84
-85
PageBtreeIndex.java
h2/src/main/org/h2/index/PageBtreeIndex.java
+7
-7
PageBtreeLeaf.java
h2/src/main/org/h2/index/PageBtreeLeaf.java
+5
-5
PageBtreeNode.java
h2/src/main/org/h2/index/PageBtreeNode.java
+12
-12
PageDataIndex.java
h2/src/main/org/h2/index/PageDataIndex.java
+7
-7
PageDataLeaf.java
h2/src/main/org/h2/index/PageDataLeaf.java
+8
-8
PageDataNode.java
h2/src/main/org/h2/index/PageDataNode.java
+14
-13
PageDataOverflow.java
h2/src/main/org/h2/index/PageDataOverflow.java
+4
-4
PageFreeList.java
h2/src/main/org/h2/store/PageFreeList.java
+4
-4
PageLog.java
h2/src/main/org/h2/store/PageLog.java
+2
-2
PageStore.java
h2/src/main/org/h2/store/PageStore.java
+13
-20
PageStreamTrunk.java
h2/src/main/org/h2/store/PageStreamTrunk.java
+3
-3
WriterThread.java
h2/src/main/org/h2/store/WriterThread.java
+5
-0
没有找到文件。
h2/src/main/org/h2/index/PageBtreeIndex.java
浏览文件 @
e91be706
...
@@ -53,7 +53,7 @@ public class PageBtreeIndex extends PageIndex {
...
@@ -53,7 +53,7 @@ public class PageBtreeIndex extends PageIndex {
store
.
addMeta
(
this
,
session
);
store
.
addMeta
(
this
,
session
);
PageBtreeLeaf
root
=
PageBtreeLeaf
.
create
(
this
,
rootPageId
,
PageBtree
.
ROOT
);
PageBtreeLeaf
root
=
PageBtreeLeaf
.
create
(
this
,
rootPageId
,
PageBtree
.
ROOT
);
store
.
logUndo
(
root
,
null
);
store
.
logUndo
(
root
,
null
);
store
.
update
Record
(
root
);
store
.
update
(
root
);
}
else
{
}
else
{
rootPageId
=
store
.
getRootPageId
(
id
);
rootPageId
=
store
.
getRootPageId
(
id
);
PageBtree
root
=
getPage
(
rootPageId
);
PageBtree
root
=
getPage
(
rootPageId
);
...
@@ -95,9 +95,9 @@ public class PageBtreeIndex extends PageIndex {
...
@@ -95,9 +95,9 @@ public class PageBtreeIndex extends PageIndex {
PageBtreeNode
newRoot
=
PageBtreeNode
.
create
(
this
,
rootPageId
,
PageBtree
.
ROOT
);
PageBtreeNode
newRoot
=
PageBtreeNode
.
create
(
this
,
rootPageId
,
PageBtree
.
ROOT
);
store
.
logUndo
(
newRoot
,
null
);
store
.
logUndo
(
newRoot
,
null
);
newRoot
.
init
(
page1
,
pivot
,
page2
);
newRoot
.
init
(
page1
,
pivot
,
page2
);
store
.
update
Record
(
page1
);
store
.
update
(
page1
);
store
.
update
Record
(
page2
);
store
.
update
(
page2
);
store
.
update
Record
(
newRoot
);
store
.
update
(
newRoot
);
root
=
newRoot
;
root
=
newRoot
;
}
}
rowCount
++;
rowCount
++;
...
@@ -131,7 +131,7 @@ public class PageBtreeIndex extends PageIndex {
...
@@ -131,7 +131,7 @@ public class PageBtreeIndex extends PageIndex {
PageBtreeLeaf
empty
=
PageBtreeLeaf
.
create
(
this
,
id
,
PageBtree
.
ROOT
);
PageBtreeLeaf
empty
=
PageBtreeLeaf
.
create
(
this
,
id
,
PageBtree
.
ROOT
);
// could have been created before, but never committed
// could have been created before, but never committed
store
.
logUndo
(
empty
,
null
);
store
.
logUndo
(
empty
,
null
);
store
.
update
Record
(
empty
);
store
.
update
(
empty
);
return
empty
;
return
empty
;
}
}
return
p
;
return
p
;
...
@@ -226,7 +226,7 @@ public class PageBtreeIndex extends PageIndex {
...
@@ -226,7 +226,7 @@ public class PageBtreeIndex extends PageIndex {
trace
.
debug
(
"remove"
);
trace
.
debug
(
"remove"
);
}
}
removeAllRows
();
removeAllRows
();
store
.
free
Page
(
rootPageId
,
false
,
null
);
store
.
free
(
rootPageId
,
true
);
store
.
removeMeta
(
this
,
session
);
store
.
removeMeta
(
this
,
session
);
}
}
...
@@ -247,7 +247,7 @@ public class PageBtreeIndex extends PageIndex {
...
@@ -247,7 +247,7 @@ public class PageBtreeIndex extends PageIndex {
root
.
freeChildren
();
root
.
freeChildren
();
root
=
PageBtreeLeaf
.
create
(
this
,
rootPageId
,
PageBtree
.
ROOT
);
root
=
PageBtreeLeaf
.
create
(
this
,
rootPageId
,
PageBtree
.
ROOT
);
store
.
removeRecord
(
rootPageId
);
store
.
removeRecord
(
rootPageId
);
store
.
update
Record
(
root
);
store
.
update
(
root
);
rowCount
=
0
;
rowCount
=
0
;
}
}
...
...
h2/src/main/org/h2/index/PageBtreeLeaf.java
浏览文件 @
e91be706
...
@@ -147,7 +147,7 @@ public class PageBtreeLeaf extends PageBtree {
...
@@ -147,7 +147,7 @@ public class PageBtreeLeaf extends PageBtree {
newRows
[
x
]
=
row
;
newRows
[
x
]
=
row
;
offsets
=
newOffsets
;
offsets
=
newOffsets
;
rows
=
newRows
;
rows
=
newRows
;
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
return
-
1
;
return
-
1
;
}
}
...
@@ -202,13 +202,13 @@ public class PageBtreeLeaf extends PageBtree {
...
@@ -202,13 +202,13 @@ public class PageBtreeLeaf extends PageBtree {
if
(
index
.
compareRows
(
row
,
delete
)
!=
0
||
delete
.
getKey
()
!=
row
.
getKey
())
{
if
(
index
.
compareRows
(
row
,
delete
)
!=
0
||
delete
.
getKey
()
!=
row
.
getKey
())
{
throw
Message
.
getSQLException
(
ErrorCode
.
ROW_NOT_FOUND_WHEN_DELETING_1
,
index
.
getSQL
()
+
": "
+
row
);
throw
Message
.
getSQLException
(
ErrorCode
.
ROW_NOT_FOUND_WHEN_DELETING_1
,
index
.
getSQL
()
+
": "
+
row
);
}
}
index
.
getPageStore
().
logUndo
(
this
,
data
);
if
(
entryCount
==
1
)
{
if
(
entryCount
==
1
)
{
// the page is now empty
// the page is now empty
return
row
;
return
row
;
}
}
index
.
getPageStore
().
logUndo
(
this
,
data
);
removeRow
(
at
);
removeRow
(
at
);
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
if
(
at
==
entryCount
)
{
if
(
at
==
entryCount
)
{
// the last row changed
// the last row changed
return
getRow
(
at
-
1
);
return
getRow
(
at
-
1
);
...
@@ -327,14 +327,14 @@ public class PageBtreeLeaf extends PageBtree {
...
@@ -327,14 +327,14 @@ public class PageBtreeLeaf extends PageBtree {
p2
.
onlyPosition
=
onlyPosition
;
p2
.
onlyPosition
=
onlyPosition
;
p2
.
parentPageId
=
parentPageId
;
p2
.
parentPageId
=
parentPageId
;
p2
.
start
=
start
;
p2
.
start
=
start
;
store
.
update
Record
(
p2
);
store
.
update
(
p2
);
if
(
parentPageId
==
ROOT
)
{
if
(
parentPageId
==
ROOT
)
{
index
.
setRootPageId
(
session
,
newPos
);
index
.
setRootPageId
(
session
,
newPos
);
}
else
{
}
else
{
PageBtreeNode
p
=
(
PageBtreeNode
)
store
.
getPage
(
parentPageId
);
PageBtreeNode
p
=
(
PageBtreeNode
)
store
.
getPage
(
parentPageId
);
p
.
moveChild
(
getPos
(),
newPos
);
p
.
moveChild
(
getPos
(),
newPos
);
}
}
store
.
free
Page
(
getPos
(),
true
,
data
);
store
.
free
(
getPos
(),
true
);
}
}
}
}
h2/src/main/org/h2/index/PageBtreeNode.java
浏览文件 @
e91be706
...
@@ -203,9 +203,9 @@ public class PageBtreeNode extends PageBtree {
...
@@ -203,9 +203,9 @@ public class PageBtreeNode extends PageBtree {
PageBtree
page2
=
page
.
split
(
splitPoint
);
PageBtree
page2
=
page
.
split
(
splitPoint
);
readAllRows
();
readAllRows
();
addChild
(
x
,
page2
.
getPos
(),
pivot
);
addChild
(
x
,
page2
.
getPos
(),
pivot
);
index
.
getPageStore
().
update
Record
(
page
);
index
.
getPageStore
().
update
(
page
);
index
.
getPageStore
().
update
Record
(
page2
);
index
.
getPageStore
().
update
(
page2
);
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
}
}
updateRowCount
(
1
);
updateRowCount
(
1
);
written
=
false
;
written
=
false
;
...
@@ -247,7 +247,7 @@ public class PageBtreeNode extends PageBtree {
...
@@ -247,7 +247,7 @@ public class PageBtreeNode extends PageBtree {
for
(
int
child
:
childPageIds
)
{
for
(
int
child
:
childPageIds
)
{
PageBtree
p
=
index
.
getPage
(
child
);
PageBtree
p
=
index
.
getPage
(
child
);
p
.
setParentPageId
(
getPos
());
p
.
setParentPageId
(
getPos
());
index
.
getPageStore
().
update
Record
(
p
);
index
.
getPageStore
().
update
(
p
);
}
}
}
}
...
@@ -311,7 +311,7 @@ public class PageBtreeNode extends PageBtree {
...
@@ -311,7 +311,7 @@ public class PageBtreeNode extends PageBtree {
return
null
;
return
null
;
}
else
if
(
last
==
row
)
{
}
else
if
(
last
==
row
)
{
// this child is now empty
// this child is now empty
index
.
getPageStore
().
free
Page
(
page
.
getPos
(),
true
,
page
.
data
);
index
.
getPageStore
().
free
(
page
.
getPos
(),
true
);
if
(
entryCount
<
1
)
{
if
(
entryCount
<
1
)
{
// no more children - this page is empty as well
// no more children - this page is empty as well
return
row
;
return
row
;
...
@@ -323,7 +323,7 @@ public class PageBtreeNode extends PageBtree {
...
@@ -323,7 +323,7 @@ public class PageBtreeNode extends PageBtree {
last
=
null
;
last
=
null
;
}
}
removeChild
(
at
);
removeChild
(
at
);
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
return
last
;
return
last
;
}
}
// the last row is in the last child
// the last row is in the last child
...
@@ -339,7 +339,7 @@ public class PageBtreeNode extends PageBtree {
...
@@ -339,7 +339,7 @@ public class PageBtreeNode extends PageBtree {
int
temp
=
childPageIds
[
at
];
int
temp
=
childPageIds
[
at
];
childPageIds
[
at
]
=
childPageIds
[
at
+
1
];
childPageIds
[
at
]
=
childPageIds
[
at
+
1
];
childPageIds
[
at
+
1
]
=
temp
;
childPageIds
[
at
+
1
]
=
temp
;
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
return
null
;
return
null
;
}
}
...
@@ -408,7 +408,7 @@ public class PageBtreeNode extends PageBtree {
...
@@ -408,7 +408,7 @@ public class PageBtreeNode extends PageBtree {
for
(
int
i
=
0
;
i
<=
entryCount
;
i
++)
{
for
(
int
i
=
0
;
i
<=
entryCount
;
i
++)
{
int
childPageId
=
childPageIds
[
i
];
int
childPageId
=
childPageIds
[
i
];
PageBtree
child
=
index
.
getPage
(
childPageId
);
PageBtree
child
=
index
.
getPage
(
childPageId
);
index
.
getPageStore
().
free
Page
(
childPageId
,
false
,
null
);
index
.
getPageStore
().
free
(
childPageId
,
false
);
child
.
freeChildren
();
child
.
freeChildren
();
}
}
}
}
...
@@ -516,7 +516,7 @@ public class PageBtreeNode extends PageBtree {
...
@@ -516,7 +516,7 @@ public class PageBtreeNode extends PageBtree {
p2
.
onlyPosition
=
onlyPosition
;
p2
.
onlyPosition
=
onlyPosition
;
p2
.
parentPageId
=
parentPageId
;
p2
.
parentPageId
=
parentPageId
;
p2
.
start
=
start
;
p2
.
start
=
start
;
store
.
update
Record
(
p2
);
store
.
update
(
p2
);
if
(
parentPageId
==
ROOT
)
{
if
(
parentPageId
==
ROOT
)
{
index
.
setRootPageId
(
session
,
newPos
);
index
.
setRootPageId
(
session
,
newPos
);
}
else
{
}
else
{
...
@@ -526,9 +526,9 @@ public class PageBtreeNode extends PageBtree {
...
@@ -526,9 +526,9 @@ public class PageBtreeNode extends PageBtree {
for
(
int
i
=
0
;
i
<
childPageIds
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
childPageIds
.
length
;
i
++)
{
PageBtree
p
=
(
PageBtree
)
store
.
getPage
(
childPageIds
[
i
]);
PageBtree
p
=
(
PageBtree
)
store
.
getPage
(
childPageIds
[
i
]);
p
.
setParentPageId
(
newPos
);
p
.
setParentPageId
(
newPos
);
store
.
update
Record
(
p
);
store
.
update
(
p
);
}
}
store
.
free
Page
(
getPos
(),
true
,
data
);
store
.
free
(
getPos
(),
true
);
}
}
/**
/**
...
@@ -543,7 +543,7 @@ public class PageBtreeNode extends PageBtree {
...
@@ -543,7 +543,7 @@ public class PageBtreeNode extends PageBtree {
index
.
getPageStore
().
logUndo
(
this
,
data
);
index
.
getPageStore
().
logUndo
(
this
,
data
);
written
=
false
;
written
=
false
;
childPageIds
[
i
]
=
newPos
;
childPageIds
[
i
]
=
newPos
;
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
return
;
return
;
}
}
}
}
...
...
h2/src/main/org/h2/index/PageDataIndex.java
浏览文件 @
e91be706
...
@@ -65,7 +65,7 @@ public class PageDataIndex extends PageIndex implements RowIndex {
...
@@ -65,7 +65,7 @@ public class PageDataIndex extends PageIndex implements RowIndex {
rootPageId
=
store
.
allocatePage
();
rootPageId
=
store
.
allocatePage
();
store
.
addMeta
(
this
,
session
);
store
.
addMeta
(
this
,
session
);
PageDataLeaf
root
=
PageDataLeaf
.
create
(
this
,
rootPageId
,
PageData
.
ROOT
);
PageDataLeaf
root
=
PageDataLeaf
.
create
(
this
,
rootPageId
,
PageData
.
ROOT
);
store
.
update
Record
(
root
);
store
.
update
(
root
);
}
else
{
}
else
{
rootPageId
=
store
.
getRootPageId
(
id
);
rootPageId
=
store
.
getRootPageId
(
id
);
PageData
root
=
getPage
(
rootPageId
,
0
);
PageData
root
=
getPage
(
rootPageId
,
0
);
...
@@ -161,9 +161,9 @@ public class PageDataIndex extends PageIndex implements RowIndex {
...
@@ -161,9 +161,9 @@ public class PageDataIndex extends PageIndex implements RowIndex {
page2
.
setParentPageId
(
rootPageId
);
page2
.
setParentPageId
(
rootPageId
);
PageDataNode
newRoot
=
PageDataNode
.
create
(
this
,
rootPageId
,
PageData
.
ROOT
);
PageDataNode
newRoot
=
PageDataNode
.
create
(
this
,
rootPageId
,
PageData
.
ROOT
);
newRoot
.
init
(
page1
,
pivot
,
page2
);
newRoot
.
init
(
page1
,
pivot
,
page2
);
store
.
update
Record
(
page1
);
store
.
update
(
page1
);
store
.
update
Record
(
page2
);
store
.
update
(
page2
);
store
.
update
Record
(
newRoot
);
store
.
update
(
newRoot
);
root
=
newRoot
;
root
=
newRoot
;
}
}
row
.
setDeleted
(
false
);
row
.
setDeleted
(
false
);
...
@@ -205,7 +205,7 @@ public class PageDataIndex extends PageIndex implements RowIndex {
...
@@ -205,7 +205,7 @@ public class PageDataIndex extends PageIndex implements RowIndex {
PageDataLeaf
empty
=
PageDataLeaf
.
create
(
this
,
id
,
parent
);
PageDataLeaf
empty
=
PageDataLeaf
.
create
(
this
,
id
,
parent
);
// could have been created before, but never committed
// could have been created before, but never committed
store
.
logUndo
(
empty
,
null
);
store
.
logUndo
(
empty
,
null
);
store
.
update
Record
(
empty
);
store
.
update
(
empty
);
return
empty
;
return
empty
;
}
}
if
(
p
.
index
.
rootPageId
!=
rootPageId
)
{
if
(
p
.
index
.
rootPageId
!=
rootPageId
)
{
...
@@ -325,7 +325,7 @@ public class PageDataIndex extends PageIndex implements RowIndex {
...
@@ -325,7 +325,7 @@ public class PageDataIndex extends PageIndex implements RowIndex {
trace
.
debug
(
"remove"
);
trace
.
debug
(
"remove"
);
}
}
removeAllRows
();
removeAllRows
();
store
.
free
Page
(
rootPageId
,
false
,
null
);
store
.
free
(
rootPageId
,
true
);
store
.
removeMeta
(
this
,
session
);
store
.
removeMeta
(
this
,
session
);
}
}
...
@@ -349,7 +349,7 @@ public class PageDataIndex extends PageIndex implements RowIndex {
...
@@ -349,7 +349,7 @@ public class PageDataIndex extends PageIndex implements RowIndex {
root
.
freeChildren
();
root
.
freeChildren
();
root
=
PageDataLeaf
.
create
(
this
,
rootPageId
,
PageData
.
ROOT
);
root
=
PageDataLeaf
.
create
(
this
,
rootPageId
,
PageData
.
ROOT
);
store
.
removeRecord
(
rootPageId
);
store
.
removeRecord
(
rootPageId
);
store
.
update
Record
(
root
);
store
.
update
(
root
);
rowCount
=
0
;
rowCount
=
0
;
lastKey
=
0
;
lastKey
=
0
;
}
}
...
...
h2/src/main/org/h2/index/PageDataLeaf.java
浏览文件 @
e91be706
...
@@ -198,7 +198,7 @@ public class PageDataLeaf extends PageData {
...
@@ -198,7 +198,7 @@ public class PageDataLeaf extends PageData {
offsets
=
newOffsets
;
offsets
=
newOffsets
;
keys
=
newKeys
;
keys
=
newKeys
;
rows
=
newRows
;
rows
=
newRows
;
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
if
(
offset
<
start
)
{
if
(
offset
<
start
)
{
if
(
entryCount
>
1
)
{
if
(
entryCount
>
1
)
{
Message
.
throwInternalError
();
Message
.
throwInternalError
();
...
@@ -234,7 +234,7 @@ public class PageDataLeaf extends PageData {
...
@@ -234,7 +234,7 @@ public class PageDataLeaf extends PageData {
next
=
index
.
getPageStore
().
allocatePage
();
next
=
index
.
getPageStore
().
allocatePage
();
}
}
PageDataOverflow
overflow
=
PageDataOverflow
.
create
(
index
.
getPageStore
(),
page
,
type
,
previous
,
next
,
all
,
dataOffset
,
size
);
PageDataOverflow
overflow
=
PageDataOverflow
.
create
(
index
.
getPageStore
(),
page
,
type
,
previous
,
next
,
all
,
dataOffset
,
size
);
index
.
getPageStore
().
update
Record
(
overflow
);
index
.
getPageStore
().
update
(
overflow
);
dataOffset
+=
size
;
dataOffset
+=
size
;
remaining
-=
size
;
remaining
-=
size
;
previous
=
page
;
previous
=
page
;
...
@@ -365,7 +365,7 @@ public class PageDataLeaf extends PageData {
...
@@ -365,7 +365,7 @@ public class PageDataLeaf extends PageData {
}
}
PageDataOverflow
overflow
=
index
.
getPageOverflow
(
firstOverflowPageId
);
PageDataOverflow
overflow
=
index
.
getPageOverflow
(
firstOverflowPageId
);
overflow
.
setParentPageId
(
getPos
());
overflow
.
setParentPageId
(
getPos
());
index
.
getPageStore
().
update
Record
(
overflow
);
index
.
getPageStore
().
update
(
overflow
);
}
}
boolean
remove
(
long
key
)
throws
SQLException
{
boolean
remove
(
long
key
)
throws
SQLException
{
...
@@ -379,7 +379,7 @@ public class PageDataLeaf extends PageData {
...
@@ -379,7 +379,7 @@ public class PageDataLeaf extends PageData {
return
true
;
return
true
;
}
}
removeRow
(
i
);
removeRow
(
i
);
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
return
false
;
return
false
;
}
}
...
@@ -389,7 +389,7 @@ public class PageDataLeaf extends PageData {
...
@@ -389,7 +389,7 @@ public class PageDataLeaf extends PageData {
int
next
=
firstOverflowPageId
;
int
next
=
firstOverflowPageId
;
do
{
do
{
PageDataOverflow
page
=
index
.
getPageOverflow
(
next
);
PageDataOverflow
page
=
index
.
getPageOverflow
(
next
);
store
.
free
Page
(
next
,
false
,
null
);
store
.
free
(
next
,
false
);
next
=
page
.
getNextOverflow
();
next
=
page
.
getNextOverflow
();
}
while
(
next
!=
0
);
}
while
(
next
!=
0
);
}
}
...
@@ -499,8 +499,8 @@ public class PageDataLeaf extends PageData {
...
@@ -499,8 +499,8 @@ public class PageDataLeaf extends PageData {
p2
.
remapChildren
();
p2
.
remapChildren
();
p2
.
write
();
p2
.
write
();
p2
.
data
.
truncate
(
index
.
getPageStore
().
getPageSize
());
p2
.
data
.
truncate
(
index
.
getPageStore
().
getPageSize
());
store
.
update
Record
(
p2
);
store
.
update
(
p2
);
store
.
free
Page
(
getPos
(),
true
,
data
);
store
.
free
(
getPos
(),
true
);
if
(
parentPageId
==
ROOT
)
{
if
(
parentPageId
==
ROOT
)
{
index
.
setRootPageId
(
session
,
newPos
);
index
.
setRootPageId
(
session
,
newPos
);
}
else
{
}
else
{
...
@@ -516,7 +516,7 @@ public class PageDataLeaf extends PageData {
...
@@ -516,7 +516,7 @@ public class PageDataLeaf extends PageData {
writeHead
();
writeHead
();
data
.
writeInt
(
firstOverflowPageId
);
data
.
writeInt
(
firstOverflowPageId
);
}
}
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
}
}
public
int
getMemorySize
()
{
public
int
getMemorySize
()
{
...
...
h2/src/main/org/h2/index/PageDataNode.java
浏览文件 @
e91be706
...
@@ -149,10 +149,10 @@ public class PageDataNode extends PageData {
...
@@ -149,10 +149,10 @@ public class PageDataNode extends PageData {
}
}
long
pivot
=
splitPoint
==
0
?
row
.
getKey
()
:
page
.
getKey
(
splitPoint
-
1
);
long
pivot
=
splitPoint
==
0
?
row
.
getKey
()
:
page
.
getKey
(
splitPoint
-
1
);
PageData
page2
=
page
.
split
(
splitPoint
);
PageData
page2
=
page
.
split
(
splitPoint
);
index
.
getPageStore
().
update
Record
(
page
);
index
.
getPageStore
().
update
(
page
);
index
.
getPageStore
().
update
Record
(
page2
);
index
.
getPageStore
().
update
(
page2
);
addChild
(
x
,
page2
.
getPos
(),
pivot
);
addChild
(
x
,
page2
.
getPos
(),
pivot
);
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
}
}
updateRowCount
(
1
);
updateRowCount
(
1
);
return
-
1
;
return
-
1
;
...
@@ -168,7 +168,7 @@ public class PageDataNode extends PageData {
...
@@ -168,7 +168,7 @@ public class PageDataNode extends PageData {
if
(
written
)
{
if
(
written
)
{
writeHead
();
writeHead
();
}
}
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
}
}
}
}
...
@@ -198,7 +198,7 @@ public class PageDataNode extends PageData {
...
@@ -198,7 +198,7 @@ public class PageDataNode extends PageData {
for
(
int
child
:
childPageIds
)
{
for
(
int
child
:
childPageIds
)
{
PageData
p
=
index
.
getPage
(
child
,
-
1
);
PageData
p
=
index
.
getPage
(
child
,
-
1
);
p
.
setParentPageId
(
getPos
());
p
.
setParentPageId
(
getPos
());
index
.
getPageStore
().
update
Record
(
p
);
index
.
getPageStore
().
update
(
p
);
}
}
}
}
...
@@ -251,19 +251,20 @@ public class PageDataNode extends PageData {
...
@@ -251,19 +251,20 @@ public class PageDataNode extends PageData {
// TODO maybe implement merge
// TODO maybe implement merge
PageData
page
=
index
.
getPage
(
childPageIds
[
at
],
getPos
());
PageData
page
=
index
.
getPage
(
childPageIds
[
at
],
getPos
());
boolean
empty
=
page
.
remove
(
key
);
boolean
empty
=
page
.
remove
(
key
);
index
.
getPageStore
().
logUndo
(
this
,
data
);
updateRowCount
(-
1
);
updateRowCount
(-
1
);
if
(!
empty
)
{
if
(!
empty
)
{
// the first row didn't change - nothing to do
// the first row didn't change - nothing to do
return
false
;
return
false
;
}
}
// this child is now empty
// this child is now empty
index
.
getPageStore
().
free
Page
(
page
.
getPos
(),
true
,
page
.
data
);
index
.
getPageStore
().
free
(
page
.
getPos
(),
true
);
if
(
entryCount
<
1
)
{
if
(
entryCount
<
1
)
{
// no more children - this page is empty as well
// no more children - this page is empty as well
return
true
;
return
true
;
}
}
removeChild
(
at
);
removeChild
(
at
);
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
return
false
;
return
false
;
}
}
...
@@ -271,7 +272,7 @@ public class PageDataNode extends PageData {
...
@@ -271,7 +272,7 @@ public class PageDataNode extends PageData {
for
(
int
i
=
0
;
i
<=
entryCount
;
i
++)
{
for
(
int
i
=
0
;
i
<=
entryCount
;
i
++)
{
int
childPageId
=
childPageIds
[
i
];
int
childPageId
=
childPageIds
[
i
];
PageData
child
=
index
.
getPage
(
childPageId
,
getPos
());
PageData
child
=
index
.
getPage
(
childPageId
,
getPos
());
index
.
getPageStore
().
free
Page
(
childPageId
,
false
,
null
);
index
.
getPageStore
().
free
(
childPageId
,
false
);
child
.
freeChildren
();
child
.
freeChildren
();
}
}
}
}
...
@@ -305,7 +306,7 @@ public class PageDataNode extends PageData {
...
@@ -305,7 +306,7 @@ public class PageDataNode extends PageData {
if
(
written
)
{
if
(
written
)
{
writeHead
();
writeHead
();
}
}
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
}
}
}
}
...
@@ -393,7 +394,7 @@ public class PageDataNode extends PageData {
...
@@ -393,7 +394,7 @@ public class PageDataNode extends PageData {
p2
.
keys
=
keys
;
p2
.
keys
=
keys
;
p2
.
entryCount
=
entryCount
;
p2
.
entryCount
=
entryCount
;
p2
.
length
=
length
;
p2
.
length
=
length
;
store
.
update
Record
(
p2
);
store
.
update
(
p2
);
if
(
parentPageId
==
ROOT
)
{
if
(
parentPageId
==
ROOT
)
{
index
.
setRootPageId
(
session
,
newPos
);
index
.
setRootPageId
(
session
,
newPos
);
}
else
{
}
else
{
...
@@ -403,9 +404,9 @@ public class PageDataNode extends PageData {
...
@@ -403,9 +404,9 @@ public class PageDataNode extends PageData {
for
(
int
i
=
0
;
i
<
childPageIds
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
childPageIds
.
length
;
i
++)
{
PageData
p
=
(
PageData
)
store
.
getPage
(
childPageIds
[
i
]);
PageData
p
=
(
PageData
)
store
.
getPage
(
childPageIds
[
i
]);
p
.
setParentPageId
(
newPos
);
p
.
setParentPageId
(
newPos
);
store
.
update
Record
(
p
);
store
.
update
(
p
);
}
}
store
.
free
Page
(
getPos
(),
true
,
data
);
store
.
free
(
getPos
(),
true
);
}
}
/**
/**
...
@@ -420,7 +421,7 @@ public class PageDataNode extends PageData {
...
@@ -420,7 +421,7 @@ public class PageDataNode extends PageData {
index
.
getPageStore
().
logUndo
(
this
,
data
);
index
.
getPageStore
().
logUndo
(
this
,
data
);
written
=
false
;
written
=
false
;
childPageIds
[
i
]
=
newPos
;
childPageIds
[
i
]
=
newPos
;
index
.
getPageStore
().
update
Record
(
this
);
index
.
getPageStore
().
update
(
this
);
return
;
return
;
}
}
}
}
...
...
h2/src/main/org/h2/index/PageDataOverflow.java
浏览文件 @
e91be706
...
@@ -216,11 +216,11 @@ public class PageDataOverflow extends Page {
...
@@ -216,11 +216,11 @@ public class PageDataOverflow extends Page {
public
void
moveTo
(
Session
session
,
int
newPos
)
throws
SQLException
{
public
void
moveTo
(
Session
session
,
int
newPos
)
throws
SQLException
{
store
.
logUndo
(
this
,
data
);
store
.
logUndo
(
this
,
data
);
PageDataOverflow
p2
=
PageDataOverflow
.
create
(
store
,
newPos
,
type
,
parentPageId
,
nextPage
,
data
,
start
,
size
);
PageDataOverflow
p2
=
PageDataOverflow
.
create
(
store
,
newPos
,
type
,
parentPageId
,
nextPage
,
data
,
start
,
size
);
store
.
update
Record
(
p2
);
store
.
update
(
p2
);
if
(
nextPage
!=
0
)
{
if
(
nextPage
!=
0
)
{
PageDataOverflow
p3
=
(
PageDataOverflow
)
store
.
getPage
(
nextPage
);
PageDataOverflow
p3
=
(
PageDataOverflow
)
store
.
getPage
(
nextPage
);
p3
.
setParentPageId
(
newPos
);
p3
.
setParentPageId
(
newPos
);
store
.
update
Record
(
p3
);
store
.
update
(
p3
);
}
}
Page
p
=
store
.
getPage
(
parentPageId
);
Page
p
=
store
.
getPage
(
parentPageId
);
if
(
p
==
null
)
{
if
(
p
==
null
)
{
...
@@ -233,8 +233,8 @@ public class PageDataOverflow extends Page {
...
@@ -233,8 +233,8 @@ public class PageDataOverflow extends Page {
PageDataLeaf
p1
=
(
PageDataLeaf
)
p
;
PageDataLeaf
p1
=
(
PageDataLeaf
)
p
;
p1
.
setOverflow
(
newPos
);
p1
.
setOverflow
(
newPos
);
}
}
store
.
update
Record
(
p
);
store
.
update
(
p
);
store
.
free
Page
(
getPos
(),
true
,
data
);
store
.
free
(
getPos
(),
true
);
}
}
private
void
setNext
(
int
nextPage
)
throws
SQLException
{
private
void
setNext
(
int
nextPage
)
throws
SQLException
{
...
...
h2/src/main/org/h2/store/PageFreeList.java
浏览文件 @
e91be706
...
@@ -88,7 +88,7 @@ public class PageFreeList extends Page {
...
@@ -88,7 +88,7 @@ public class PageFreeList extends Page {
}
else
{
}
else
{
store
.
logUndo
(
this
,
data
);
store
.
logUndo
(
this
,
data
);
used
.
set
(
free
);
used
.
set
(
free
);
store
.
update
Record
(
this
);
store
.
update
(
this
);
return
free
+
getPos
();
return
free
+
getPos
();
}
}
}
}
...
@@ -121,7 +121,7 @@ public class PageFreeList extends Page {
...
@@ -121,7 +121,7 @@ public class PageFreeList extends Page {
if
(
idx
>=
0
&&
!
used
.
get
(
idx
))
{
if
(
idx
>=
0
&&
!
used
.
get
(
idx
))
{
store
.
logUndo
(
this
,
data
);
store
.
logUndo
(
this
,
data
);
used
.
set
(
idx
);
used
.
set
(
idx
);
store
.
update
Record
(
this
);
store
.
update
(
this
);
}
}
return
pageId
;
return
pageId
;
}
}
...
@@ -135,7 +135,7 @@ public class PageFreeList extends Page {
...
@@ -135,7 +135,7 @@ public class PageFreeList extends Page {
full
=
false
;
full
=
false
;
store
.
logUndo
(
this
,
data
);
store
.
logUndo
(
this
,
data
);
used
.
clear
(
pageId
-
getPos
());
used
.
clear
(
pageId
-
getPos
());
store
.
update
Record
(
this
);
store
.
update
(
this
);
}
}
/**
/**
...
@@ -197,7 +197,7 @@ public class PageFreeList extends Page {
...
@@ -197,7 +197,7 @@ public class PageFreeList extends Page {
public
void
moveTo
(
Session
session
,
int
newPos
)
throws
SQLException
{
public
void
moveTo
(
Session
session
,
int
newPos
)
throws
SQLException
{
// the old data does not need to be copied, as free-list pages
// the old data does not need to be copied, as free-list pages
// at the end of the file are not required
// at the end of the file are not required
store
.
free
Page
(
getPos
(),
true
,
data
);
store
.
free
(
getPos
(),
false
);
}
}
public
String
toString
()
{
public
String
toString
()
{
...
...
h2/src/main/org/h2/store/PageLog.java
浏览文件 @
e91be706
...
@@ -198,7 +198,7 @@ public class PageLog {
...
@@ -198,7 +198,7 @@ public class PageLog {
while
(
firstTrunkPage
!=
0
)
{
while
(
firstTrunkPage
!=
0
)
{
PageStreamTrunk
t
=
(
PageStreamTrunk
)
store
.
getPage
(
firstTrunkPage
);
PageStreamTrunk
t
=
(
PageStreamTrunk
)
store
.
getPage
(
firstTrunkPage
);
if
(
t
==
null
)
{
if
(
t
==
null
)
{
store
.
free
Page
(
firstTrunkPage
,
false
,
null
);
store
.
free
(
firstTrunkPage
,
false
);
// EOF
// EOF
break
;
break
;
}
}
...
@@ -352,7 +352,7 @@ public class PageLog {
...
@@ -352,7 +352,7 @@ public class PageLog {
int
pageId
=
in
.
readVarInt
();
int
pageId
=
in
.
readVarInt
();
if
(
stage
==
RECOVERY_STAGE_REDO
)
{
if
(
stage
==
RECOVERY_STAGE_REDO
)
{
if
(!
usedLogPages
.
get
(
pageId
))
{
if
(!
usedLogPages
.
get
(
pageId
))
{
store
.
free
Page
(
pageId
,
false
,
null
);
store
.
free
(
pageId
,
false
);
}
}
}
}
}
}
...
...
h2/src/main/org/h2/store/PageStore.java
浏览文件 @
e91be706
...
@@ -717,27 +717,27 @@ public class PageStore implements CacheWriter {
...
@@ -717,27 +717,27 @@ public class PageStore implements CacheWriter {
}
}
/**
/**
* Update a
record
.
* Update a
page
.
*
*
* @param
record the record
* @param
page the page
*/
*/
public
void
update
Record
(
Record
record
)
throws
SQLException
{
public
void
update
(
Page
page
)
throws
SQLException
{
synchronized
(
database
)
{
synchronized
(
database
)
{
if
(
trace
.
isDebugEnabled
())
{
if
(
trace
.
isDebugEnabled
())
{
if
(!
record
.
isChanged
())
{
if
(!
page
.
isChanged
())
{
trace
.
debug
(
"updateRecord "
+
record
.
toString
());
trace
.
debug
(
"updateRecord "
+
page
.
toString
());
}
}
}
}
checkOpen
();
checkOpen
();
database
.
checkWritingAllowed
();
database
.
checkWritingAllowed
();
record
.
setChanged
(
true
);
page
.
setChanged
(
true
);
int
pos
=
record
.
getPos
();
int
pos
=
page
.
getPos
();
if
(
SysProperties
.
CHECK
&&
!
recoveryRunning
)
{
if
(
SysProperties
.
CHECK
&&
!
recoveryRunning
)
{
// ensure the undo entry is already written
// ensure the undo entry is already written
log
.
addUndo
(
pos
,
null
);
log
.
addUndo
(
pos
,
null
);
}
}
allocatePage
(
pos
);
allocatePage
(
pos
);
cache
.
update
(
pos
,
record
);
cache
.
update
(
pos
,
page
);
}
}
}
}
...
@@ -854,29 +854,22 @@ public class PageStore implements CacheWriter {
...
@@ -854,29 +854,22 @@ public class PageStore implements CacheWriter {
/**
/**
* Add a page to the free list.
* Add a page to the free list.
*
*
* @param pageId the page id
* @param page the page
* @param logUndo if an undo entry need to be logged
* @param undo if the undo record must have been written
* @param old the old data (if known)
*/
*/
public
void
free
Page
(
int
pageId
,
boolean
logUndo
,
Data
old
)
throws
SQLException
{
public
void
free
(
int
pageId
,
boolean
undo
)
throws
SQLException
{
if
(
trace
.
isDebugEnabled
())
{
if
(
trace
.
isDebugEnabled
())
{
// trace.debug("freePage " + pageId);
// trace.debug("freePage " + pageId);
}
}
int
todoRemoveOld
;
synchronized
(
database
)
{
synchronized
(
database
)
{
if
(
SysProperties
.
CHECK
&&
!
recoveryRunning
&&
logUndo
)
{
cache
.
remove
(
pageId
);
if
(
SysProperties
.
CHECK
&&
!
recoveryRunning
&&
undo
)
{
// ensure the undo entry is already written
// ensure the undo entry is already written
log
.
addUndo
(
pageId
,
null
);
log
.
addUndo
(
pageId
,
null
);
}
}
cache
.
remove
(
pageId
);
freePage
(
pageId
);
freePage
(
pageId
);
if
(
recoveryRunning
)
{
if
(
recoveryRunning
)
{
writePage
(
pageId
,
createData
());
writePage
(
pageId
,
createData
());
}
else
if
(
logUndo
)
{
if
(
old
==
null
)
{
old
=
readPage
(
pageId
);
}
log
.
addUndo
(
pageId
,
old
);
}
}
}
}
}
}
...
...
h2/src/main/org/h2/store/PageStreamTrunk.java
浏览文件 @
e91be706
...
@@ -168,11 +168,11 @@ public class PageStreamTrunk extends Page {
...
@@ -168,11 +168,11 @@ public class PageStreamTrunk extends Page {
* @return the number of pages freed
* @return the number of pages freed
*/
*/
int
free
()
throws
SQLException
{
int
free
()
throws
SQLException
{
store
.
free
Page
(
getPos
(),
false
,
null
);
store
.
free
(
getPos
(),
false
);
int
freed
=
1
;
int
freed
=
1
;
for
(
int
i
=
0
;
i
<
pageCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
pageCount
;
i
++)
{
int
page
=
pageIds
[
i
];
int
page
=
pageIds
[
i
];
store
.
free
Page
(
page
,
false
,
null
);
store
.
free
(
page
,
false
);
freed
++;
freed
++;
}
}
return
freed
;
return
freed
;
...
@@ -201,7 +201,7 @@ public class PageStreamTrunk extends Page {
...
@@ -201,7 +201,7 @@ public class PageStreamTrunk extends Page {
break
;
break
;
}
}
}
}
store
.
update
Record
(
this
);
store
.
update
(
this
);
}
}
public
void
moveTo
(
Session
session
,
int
newPos
)
{
public
void
moveTo
(
Session
session
,
int
newPos
)
{
...
...
h2/src/main/org/h2/store/WriterThread.java
浏览文件 @
e91be706
...
@@ -141,6 +141,11 @@ public class WriterThread implements Runnable {
...
@@ -141,6 +141,11 @@ public class WriterThread implements Runnable {
if
(
traceSystem
!=
null
)
{
if
(
traceSystem
!=
null
)
{
traceSystem
.
getTrace
(
Trace
.
LOG
).
error
(
"flush"
,
e
);
traceSystem
.
getTrace
(
Trace
.
LOG
).
error
(
"flush"
,
e
);
}
}
}
catch
(
RuntimeException
e
)
{
TraceSystem
traceSystem
=
database
.
getTraceSystem
();
if
(
traceSystem
!=
null
)
{
traceSystem
.
getTrace
(
Trace
.
LOG
).
error
(
"flush"
,
e
);
}
}
}
// TODO log writer: could also flush the dirty cache when there is
// TODO log writer: could also flush the dirty cache when there is
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论