Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
138b5f4d
提交
138b5f4d
authored
9月 18, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Page store: change page header format
上级
aa4c1bd1
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
46 行增加
和
52 行删除
+46
-52
PageBtreeLeaf.java
h2/src/main/org/h2/index/PageBtreeLeaf.java
+3
-3
PageBtreeNode.java
h2/src/main/org/h2/index/PageBtreeNode.java
+3
-3
PageDataLeaf.java
h2/src/main/org/h2/index/PageDataLeaf.java
+3
-3
PageDataNode.java
h2/src/main/org/h2/index/PageDataNode.java
+3
-3
PageDataOverflow.java
h2/src/main/org/h2/index/PageDataOverflow.java
+5
-5
PageFreeList.java
h2/src/main/org/h2/store/PageFreeList.java
+6
-16
PageStore.java
h2/src/main/org/h2/store/PageStore.java
+1
-1
PageStreamData.java
h2/src/main/org/h2/store/PageStreamData.java
+4
-4
PageStreamTrunk.java
h2/src/main/org/h2/store/PageStreamTrunk.java
+4
-4
Recover.java
h2/src/main/org/h2/tools/Recover.java
+14
-10
没有找到文件。
h2/src/main/org/h2/index/PageBtreeLeaf.java
浏览文件 @
138b5f4d
...
@@ -20,8 +20,8 @@ import org.h2.store.PageStore;
...
@@ -20,8 +20,8 @@ import org.h2.store.PageStore;
/**
/**
* A b-tree leaf page that contains index data. Format:
* A b-tree leaf page that contains index data. Format:
* <ul>
* <ul>
* <li>parent page id (0 for root): int</li>
* <li>page type: byte</li>
* <li>page type: byte</li>
* <li>parent page id (0 for root): int</li>
* <li>index id: varInt</li>
* <li>index id: varInt</li>
* <li>entry count: short</li>
* <li>entry count: short</li>
* <li>list of offsets: short</li>
* <li>list of offsets: short</li>
...
@@ -68,8 +68,8 @@ public class PageBtreeLeaf extends PageBtree {
...
@@ -68,8 +68,8 @@ public class PageBtreeLeaf extends PageBtree {
private
void
read
()
throws
SQLException
{
private
void
read
()
throws
SQLException
{
data
.
reset
();
data
.
reset
();
this
.
parentPageId
=
data
.
readInt
();
int
type
=
data
.
readByte
();
int
type
=
data
.
readByte
();
this
.
parentPageId
=
data
.
readInt
();
onlyPosition
=
(
type
&
Page
.
FLAG_LAST
)
==
0
;
onlyPosition
=
(
type
&
Page
.
FLAG_LAST
)
==
0
;
int
indexId
=
data
.
readVarInt
();
int
indexId
=
data
.
readVarInt
();
if
(
indexId
!=
index
.
getId
())
{
if
(
indexId
!=
index
.
getId
())
{
...
@@ -233,8 +233,8 @@ public class PageBtreeLeaf extends PageBtree {
...
@@ -233,8 +233,8 @@ public class PageBtreeLeaf extends PageBtree {
}
}
private
void
writeHead
()
{
private
void
writeHead
()
{
data
.
writeInt
(
parentPageId
);
data
.
writeByte
((
byte
)
(
Page
.
TYPE_BTREE_LEAF
|
(
onlyPosition
?
0
:
Page
.
FLAG_LAST
)));
data
.
writeByte
((
byte
)
(
Page
.
TYPE_BTREE_LEAF
|
(
onlyPosition
?
0
:
Page
.
FLAG_LAST
)));
data
.
writeInt
(
parentPageId
);
data
.
writeVarInt
(
index
.
getId
());
data
.
writeVarInt
(
index
.
getId
());
data
.
writeShortInt
(
entryCount
);
data
.
writeShortInt
(
entryCount
);
}
}
...
...
h2/src/main/org/h2/index/PageBtreeNode.java
浏览文件 @
138b5f4d
...
@@ -21,8 +21,8 @@ import org.h2.util.MemoryUtils;
...
@@ -21,8 +21,8 @@ import org.h2.util.MemoryUtils;
/**
/**
* A b-tree node page that contains index data. Format:
* A b-tree node page that contains index data. Format:
* <ul>
* <ul>
* <li>parent page id (0 for root): int</li>
* <li>page type: byte</li>
* <li>page type: byte</li>
* <li>parent page id (0 for root): int</li>
* <li>index id: varInt</li>
* <li>index id: varInt</li>
* <li>count of all children (-1 if not known): int</li>
* <li>count of all children (-1 if not known): int</li>
* <li>entry count: short</li>
* <li>entry count: short</li>
...
@@ -81,8 +81,8 @@ public class PageBtreeNode extends PageBtree {
...
@@ -81,8 +81,8 @@ public class PageBtreeNode extends PageBtree {
private
void
read
()
throws
SQLException
{
private
void
read
()
throws
SQLException
{
data
.
reset
();
data
.
reset
();
this
.
parentPageId
=
data
.
readInt
();
int
type
=
data
.
readByte
();
int
type
=
data
.
readByte
();
this
.
parentPageId
=
data
.
readInt
();
onlyPosition
=
(
type
&
Page
.
FLAG_LAST
)
==
0
;
onlyPosition
=
(
type
&
Page
.
FLAG_LAST
)
==
0
;
int
indexId
=
data
.
readVarInt
();
int
indexId
=
data
.
readVarInt
();
if
(
indexId
!=
index
.
getId
())
{
if
(
indexId
!=
index
.
getId
())
{
...
@@ -370,8 +370,8 @@ public class PageBtreeNode extends PageBtree {
...
@@ -370,8 +370,8 @@ public class PageBtreeNode extends PageBtree {
}
}
private
void
writeHead
()
{
private
void
writeHead
()
{
data
.
writeInt
(
parentPageId
);
data
.
writeByte
((
byte
)
(
Page
.
TYPE_BTREE_NODE
|
(
onlyPosition
?
0
:
Page
.
FLAG_LAST
)));
data
.
writeByte
((
byte
)
(
Page
.
TYPE_BTREE_NODE
|
(
onlyPosition
?
0
:
Page
.
FLAG_LAST
)));
data
.
writeInt
(
parentPageId
);
data
.
writeVarInt
(
index
.
getId
());
data
.
writeVarInt
(
index
.
getId
());
data
.
writeInt
(
rowCount
);
data
.
writeInt
(
rowCount
);
data
.
writeShortInt
(
entryCount
);
data
.
writeShortInt
(
entryCount
);
...
...
h2/src/main/org/h2/index/PageDataLeaf.java
浏览文件 @
138b5f4d
...
@@ -21,8 +21,8 @@ import org.h2.store.PageStore;
...
@@ -21,8 +21,8 @@ import org.h2.store.PageStore;
/**
/**
* A leaf page that contains data of one or multiple rows. Format:
* A leaf page that contains data of one or multiple rows. Format:
* <ul>
* <ul>
* <li>parent page id (0 for root): int</li>
* <li>page type: byte</li>
* <li>page type: byte</li>
* <li>parent page id (0 for root): int</li>
* <li>table id: varInt</li>
* <li>table id: varInt</li>
* <li>column count: varInt</li>
* <li>column count: varInt</li>
* <li>entry count: short</li>
* <li>entry count: short</li>
...
@@ -104,8 +104,8 @@ public class PageDataLeaf extends PageData {
...
@@ -104,8 +104,8 @@ public class PageDataLeaf extends PageData {
private
void
read
()
throws
SQLException
{
private
void
read
()
throws
SQLException
{
data
.
reset
();
data
.
reset
();
this
.
parentPageId
=
data
.
readInt
();
int
type
=
data
.
readByte
();
int
type
=
data
.
readByte
();
this
.
parentPageId
=
data
.
readInt
();
int
tableId
=
data
.
readVarInt
();
int
tableId
=
data
.
readVarInt
();
if
(
tableId
!=
index
.
getId
())
{
if
(
tableId
!=
index
.
getId
())
{
throw
Message
.
getSQLException
(
ErrorCode
.
FILE_CORRUPTED_1
,
throw
Message
.
getSQLException
(
ErrorCode
.
FILE_CORRUPTED_1
,
...
@@ -416,7 +416,6 @@ public class PageDataLeaf extends PageData {
...
@@ -416,7 +416,6 @@ public class PageDataLeaf extends PageData {
}
}
private
void
writeHead
()
{
private
void
writeHead
()
{
data
.
writeInt
(
parentPageId
);
int
type
;
int
type
;
if
(
firstOverflowPageId
==
0
)
{
if
(
firstOverflowPageId
==
0
)
{
type
=
Page
.
TYPE_DATA_LEAF
|
Page
.
FLAG_LAST
;
type
=
Page
.
TYPE_DATA_LEAF
|
Page
.
FLAG_LAST
;
...
@@ -424,6 +423,7 @@ public class PageDataLeaf extends PageData {
...
@@ -424,6 +423,7 @@ public class PageDataLeaf extends PageData {
type
=
Page
.
TYPE_DATA_LEAF
;
type
=
Page
.
TYPE_DATA_LEAF
;
}
}
data
.
writeByte
((
byte
)
type
);
data
.
writeByte
((
byte
)
type
);
data
.
writeInt
(
parentPageId
);
data
.
writeVarInt
(
index
.
getId
());
data
.
writeVarInt
(
index
.
getId
());
data
.
writeVarInt
(
columnCount
);
data
.
writeVarInt
(
columnCount
);
data
.
writeShortInt
(
entryCount
);
data
.
writeShortInt
(
entryCount
);
...
...
h2/src/main/org/h2/index/PageDataNode.java
浏览文件 @
138b5f4d
...
@@ -21,8 +21,8 @@ import org.h2.util.MemoryUtils;
...
@@ -21,8 +21,8 @@ import org.h2.util.MemoryUtils;
/**
/**
* A leaf page that contains data of one or multiple rows. Format:
* A leaf page that contains data of one or multiple rows. Format:
* <ul>
* <ul>
* <li>parent page id (0 for root): int</li>
* <li>page type: byte</li>
* <li>page type: byte</li>
* <li>parent page id (0 for root): int</li>
* <li>table id: varInt</li>
* <li>table id: varInt</li>
* <li>count of all children (-1 if not known): int</li>
* <li>count of all children (-1 if not known): int</li>
* <li>entry count: short</li>
* <li>entry count: short</li>
...
@@ -85,8 +85,8 @@ public class PageDataNode extends PageData {
...
@@ -85,8 +85,8 @@ public class PageDataNode extends PageData {
private
void
read
()
throws
SQLException
{
private
void
read
()
throws
SQLException
{
data
.
reset
();
data
.
reset
();
this
.
parentPageId
=
data
.
readInt
();
data
.
readByte
();
data
.
readByte
();
this
.
parentPageId
=
data
.
readInt
();
int
indexId
=
data
.
readVarInt
();
int
indexId
=
data
.
readVarInt
();
if
(
indexId
!=
index
.
getId
())
{
if
(
indexId
!=
index
.
getId
())
{
throw
Message
.
getSQLException
(
ErrorCode
.
FILE_CORRUPTED_1
,
throw
Message
.
getSQLException
(
ErrorCode
.
FILE_CORRUPTED_1
,
...
@@ -312,8 +312,8 @@ public class PageDataNode extends PageData {
...
@@ -312,8 +312,8 @@ public class PageDataNode extends PageData {
}
}
private
void
writeHead
()
{
private
void
writeHead
()
{
data
.
writeInt
(
parentPageId
);
data
.
writeByte
((
byte
)
Page
.
TYPE_DATA_NODE
);
data
.
writeByte
((
byte
)
Page
.
TYPE_DATA_NODE
);
data
.
writeInt
(
parentPageId
);
data
.
writeVarInt
(
index
.
getId
());
data
.
writeVarInt
(
index
.
getId
());
data
.
writeInt
(
rowCountStored
);
data
.
writeInt
(
rowCountStored
);
data
.
writeShortInt
(
entryCount
);
data
.
writeShortInt
(
entryCount
);
...
...
h2/src/main/org/h2/index/PageDataOverflow.java
浏览文件 @
138b5f4d
...
@@ -18,8 +18,8 @@ import org.h2.store.PageStore;
...
@@ -18,8 +18,8 @@ import org.h2.store.PageStore;
/**
/**
* Overflow data for a leaf page. Format:
* Overflow data for a leaf page. Format:
* <ul>
* <ul>
* <li>pa
rent page id (0 for root): int (0-3
)</li>
* <li>pa
ge type: byte (0
)</li>
* <li>pa
ge type: byte (
4)</li>
* <li>pa
rent page id (0 for root): int (1-
4)</li>
* <li>more data: next overflow page id: int (5-8)</li>
* <li>more data: next overflow page id: int (5-8)</li>
* <li>last remaining size: short (5-6)</li>
* <li>last remaining size: short (5-6)</li>
* <li>data (9-/7-)</li>
* <li>data (9-/7-)</li>
...
@@ -108,8 +108,8 @@ public class PageDataOverflow extends Page {
...
@@ -108,8 +108,8 @@ public class PageDataOverflow extends Page {
static
PageDataOverflow
create
(
PageStore
store
,
int
page
,
int
type
,
int
parentPageId
,
int
next
,
Data
all
,
int
offset
,
int
size
)
{
static
PageDataOverflow
create
(
PageStore
store
,
int
page
,
int
type
,
int
parentPageId
,
int
next
,
Data
all
,
int
offset
,
int
size
)
{
Data
data
=
store
.
createData
();
Data
data
=
store
.
createData
();
PageDataOverflow
p
=
new
PageDataOverflow
(
store
,
page
,
data
);
PageDataOverflow
p
=
new
PageDataOverflow
(
store
,
page
,
data
);
data
.
writeInt
(
parentPageId
);
data
.
writeByte
((
byte
)
type
);
data
.
writeByte
((
byte
)
type
);
data
.
writeInt
(
parentPageId
);
if
(
type
==
Page
.
TYPE_DATA_OVERFLOW
)
{
if
(
type
==
Page
.
TYPE_DATA_OVERFLOW
)
{
data
.
writeInt
(
next
);
data
.
writeInt
(
next
);
}
else
{
}
else
{
...
@@ -129,8 +129,8 @@ public class PageDataOverflow extends Page {
...
@@ -129,8 +129,8 @@ public class PageDataOverflow extends Page {
*/
*/
private
void
read
()
throws
SQLException
{
private
void
read
()
throws
SQLException
{
data
.
reset
();
data
.
reset
();
parentPageId
=
data
.
readInt
();
type
=
data
.
readByte
();
type
=
data
.
readByte
();
parentPageId
=
data
.
readInt
();
if
(
type
==
(
Page
.
TYPE_DATA_OVERFLOW
|
Page
.
FLAG_LAST
))
{
if
(
type
==
(
Page
.
TYPE_DATA_OVERFLOW
|
Page
.
FLAG_LAST
))
{
size
=
data
.
readShortInt
();
size
=
data
.
readShortInt
();
nextPage
=
0
;
nextPage
=
0
;
...
@@ -168,8 +168,8 @@ public class PageDataOverflow extends Page {
...
@@ -168,8 +168,8 @@ public class PageDataOverflow extends Page {
}
}
private
void
writeHead
()
{
private
void
writeHead
()
{
data
.
writeInt
(
parentPageId
);
data
.
writeByte
((
byte
)
type
);
data
.
writeByte
((
byte
)
type
);
data
.
writeInt
(
parentPageId
);
}
}
public
void
write
(
DataPage
buff
)
throws
SQLException
{
public
void
write
(
DataPage
buff
)
throws
SQLException
{
...
...
h2/src/main/org/h2/store/PageFreeList.java
浏览文件 @
138b5f4d
...
@@ -6,23 +6,20 @@
...
@@ -6,23 +6,20 @@
package
org
.
h2
.
store
;
package
org
.
h2
.
store
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
org.h2.constant.ErrorCode
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.message.Message
;
import
org.h2.util.BitField
;
import
org.h2.util.BitField
;
/**
/**
* The list of free pages of a page store. The format of a free list trunk page
* The list of free pages of a page store. The format of a free list trunk page
* is:
* is:
* <ul>
* <ul>
* <li>parent page id (always 0): int</li>
* <li>page type: byte</li>
* <li>page type: byte</li>
* <li>data (
5
-)</li>
* <li>data (
1
-)</li>
* </ul>
* </ul>
*/
*/
public
class
PageFreeList
extends
Page
{
public
class
PageFreeList
extends
Page
{
private
static
final
int
DATA_START
=
5
;
private
static
final
int
DATA_START
=
1
;
private
final
PageStore
store
;
private
final
PageStore
store
;
private
final
BitField
used
=
new
BitField
();
private
final
BitField
used
=
new
BitField
();
...
@@ -45,7 +42,7 @@ public class PageFreeList extends Page {
...
@@ -45,7 +42,7 @@ public class PageFreeList extends Page {
* @param pageId the page id
* @param pageId the page id
* @return the page
* @return the page
*/
*/
static
PageFreeList
read
(
PageStore
store
,
Data
data
,
int
pageId
)
throws
SQLException
{
static
PageFreeList
read
(
PageStore
store
,
Data
data
,
int
pageId
)
{
PageFreeList
p
=
new
PageFreeList
(
store
,
pageId
);
PageFreeList
p
=
new
PageFreeList
(
store
,
pageId
);
p
.
data
=
data
;
p
.
data
=
data
;
p
.
read
();
p
.
read
();
...
@@ -140,14 +137,9 @@ public class PageFreeList extends Page {
...
@@ -140,14 +137,9 @@ public class PageFreeList extends Page {
/**
/**
* Read the page from the disk.
* Read the page from the disk.
*/
*/
private
void
read
()
throws
SQLException
{
private
void
read
()
{
data
.
reset
();
data
.
reset
();
int
p
=
data
.
readInt
();
data
.
readByte
();
int
t
=
data
.
readByte
();
if
(
p
!=
0
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
FILE_CORRUPTED_1
,
"pos:"
+
getPos
()
+
" type:"
+
t
+
" parent:"
+
p
+
" expected type:"
+
Page
.
TYPE_FREE_LIST
);
}
for
(
int
i
=
0
;
i
<
pageCount
;
i
+=
8
)
{
for
(
int
i
=
0
;
i
<
pageCount
;
i
+=
8
)
{
used
.
setByte
(
i
,
data
.
readByte
()
&
255
);
used
.
setByte
(
i
,
data
.
readByte
()
&
255
);
}
}
...
@@ -160,9 +152,7 @@ public class PageFreeList extends Page {
...
@@ -160,9 +152,7 @@ public class PageFreeList extends Page {
public
void
write
(
DataPage
buff
)
throws
SQLException
{
public
void
write
(
DataPage
buff
)
throws
SQLException
{
data
=
store
.
createData
();
data
=
store
.
createData
();
data
.
writeInt
(
0
);
data
.
writeByte
((
byte
)
Page
.
TYPE_FREE_LIST
);
int
type
=
Page
.
TYPE_FREE_LIST
;
data
.
writeByte
((
byte
)
type
);
for
(
int
i
=
0
;
i
<
pageCount
;
i
+=
8
)
{
for
(
int
i
=
0
;
i
<
pageCount
;
i
+=
8
)
{
data
.
writeByte
((
byte
)
used
.
getByte
(
i
));
data
.
writeByte
((
byte
)
used
.
getByte
(
i
));
}
}
...
...
h2/src/main/org/h2/store/PageStore.java
浏览文件 @
138b5f4d
...
@@ -454,8 +454,8 @@ public class PageStore implements CacheWriter {
...
@@ -454,8 +454,8 @@ public class PageStore implements CacheWriter {
}
}
Data
data
=
createData
();
Data
data
=
createData
();
readPage
(
pageId
,
data
);
readPage
(
pageId
,
data
);
data
.
readInt
();
int
type
=
data
.
readByte
();
int
type
=
data
.
readByte
();
data
.
readInt
();
Page
p
;
Page
p
;
switch
(
type
&
~
Page
.
FLAG_LAST
)
{
switch
(
type
&
~
Page
.
FLAG_LAST
)
{
case
Page
.
TYPE_EMPTY
:
case
Page
.
TYPE_EMPTY
:
...
...
h2/src/main/org/h2/store/PageStreamData.java
浏览文件 @
138b5f4d
...
@@ -12,8 +12,8 @@ import org.h2.engine.Session;
...
@@ -12,8 +12,8 @@ import org.h2.engine.Session;
/**
/**
* A data page of a stream. The format is:
* A data page of a stream. The format is:
* <ul>
* <ul>
* <li>
the trunk page id: int (0-3
)</li>
* <li>
page type: byte (0
)</li>
* <li>
page type: byte (
4)</li>
* <li>
the trunk page id: int (1-
4)</li>
* <li>log key: int (5-8)</li>
* <li>log key: int (5-8)</li>
* <li>data (9-)</li>
* <li>data (9-)</li>
* </ul>
* </ul>
...
@@ -68,8 +68,8 @@ public class PageStreamData extends Page {
...
@@ -68,8 +68,8 @@ public class PageStreamData extends Page {
*/
*/
private
void
read
()
{
private
void
read
()
{
data
.
reset
();
data
.
reset
();
trunk
=
data
.
readInt
();
data
.
readByte
();
data
.
readByte
();
trunk
=
data
.
readInt
();
logKey
=
data
.
readInt
();
logKey
=
data
.
readInt
();
}
}
...
@@ -82,8 +82,8 @@ public class PageStreamData extends Page {
...
@@ -82,8 +82,8 @@ public class PageStreamData extends Page {
*/
*/
void
initWrite
()
{
void
initWrite
()
{
data
=
store
.
createData
();
data
=
store
.
createData
();
data
.
writeInt
(
trunk
);
data
.
writeByte
((
byte
)
Page
.
TYPE_STREAM_DATA
);
data
.
writeByte
((
byte
)
Page
.
TYPE_STREAM_DATA
);
data
.
writeInt
(
trunk
);
data
.
writeInt
(
logKey
);
data
.
writeInt
(
logKey
);
remaining
=
store
.
getPageSize
()
-
data
.
length
();
remaining
=
store
.
getPageSize
()
-
data
.
length
();
}
}
...
...
h2/src/main/org/h2/store/PageStreamTrunk.java
浏览文件 @
138b5f4d
...
@@ -13,8 +13,8 @@ import org.h2.engine.Session;
...
@@ -13,8 +13,8 @@ import org.h2.engine.Session;
* A trunk page of a stream. It contains the page numbers of the stream, and the
* A trunk page of a stream. It contains the page numbers of the stream, and the
* page number of the next trunk. The format is:
* page number of the next trunk. The format is:
* <ul>
* <ul>
* <li>p
revious trunk page, or 0 if none: int (0-3
)</li>
* <li>p
age type: byte (0
)</li>
* <li>p
age type: byte (
4)</li>
* <li>p
revious trunk page, or 0 if none: int (1-
4)</li>
* <li>log key: int (5-8)</li>
* <li>log key: int (5-8)</li>
* <li>next trunk page: int (9-12)</li>
* <li>next trunk page: int (9-12)</li>
* <li>number of pages: short (13-14)</li>
* <li>number of pages: short (13-14)</li>
...
@@ -84,8 +84,8 @@ public class PageStreamTrunk extends Page {
...
@@ -84,8 +84,8 @@ public class PageStreamTrunk extends Page {
*/
*/
private
void
read
()
{
private
void
read
()
{
data
.
reset
();
data
.
reset
();
parent
=
data
.
readInt
();
data
.
readByte
();
data
.
readByte
();
parent
=
data
.
readInt
();
logKey
=
data
.
readInt
();
logKey
=
data
.
readInt
();
nextTrunk
=
data
.
readInt
();
nextTrunk
=
data
.
readInt
();
pageCount
=
data
.
readShortInt
();
pageCount
=
data
.
readShortInt
();
...
@@ -123,8 +123,8 @@ public class PageStreamTrunk extends Page {
...
@@ -123,8 +123,8 @@ public class PageStreamTrunk extends Page {
public
void
write
(
DataPage
buff
)
throws
SQLException
{
public
void
write
(
DataPage
buff
)
throws
SQLException
{
data
=
store
.
createData
();
data
=
store
.
createData
();
data
.
writeInt
(
parent
);
data
.
writeByte
((
byte
)
Page
.
TYPE_STREAM_TRUNK
);
data
.
writeByte
((
byte
)
Page
.
TYPE_STREAM_TRUNK
);
data
.
writeInt
(
parent
);
data
.
writeInt
(
logKey
);
data
.
writeInt
(
logKey
);
data
.
writeInt
(
nextTrunk
);
data
.
writeInt
(
nextTrunk
);
data
.
writeShortInt
(
pageCount
);
data
.
writeShortInt
(
pageCount
);
...
...
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
138b5f4d
...
@@ -859,14 +859,10 @@ public class Recover extends Tool implements DataHandler {
...
@@ -859,14 +859,10 @@ public class Recover extends Tool implements DataHandler {
s
=
Data
.
create
(
this
,
pageSize
);
s
=
Data
.
create
(
this
,
pageSize
);
store
.
seek
(
page
*
pageSize
);
store
.
seek
(
page
*
pageSize
);
store
.
readFully
(
s
.
getBytes
(),
0
,
pageSize
);
store
.
readFully
(
s
.
getBytes
(),
0
,
pageSize
);
int
parentPageId
=
s
.
readInt
();
int
type
=
s
.
readByte
();
int
type
=
s
.
readByte
();
switch
(
type
)
{
switch
(
type
)
{
case
Page
.
TYPE_EMPTY
:
case
Page
.
TYPE_EMPTY
:
pageTypeCount
[
type
]++;
pageTypeCount
[
type
]++;
if
(
parentPageId
!=
0
)
{
writer
.
println
(
"-- ERROR empty page with parent: "
+
parentPageId
);
}
emptyPages
++;
emptyPages
++;
continue
;
continue
;
}
}
...
@@ -876,20 +872,24 @@ public class Recover extends Tool implements DataHandler {
...
@@ -876,20 +872,24 @@ public class Recover extends Tool implements DataHandler {
// type 1
// type 1
case
Page
.
TYPE_DATA_LEAF
:
{
case
Page
.
TYPE_DATA_LEAF
:
{
pageTypeCount
[
type
]++;
pageTypeCount
[
type
]++;
int
parentPageId
=
s
.
readInt
();
setStorage
(
s
.
readVarInt
());
setStorage
(
s
.
readVarInt
());
int
columnCount
=
s
.
readVarInt
();
int
columnCount
=
s
.
readVarInt
();
int
entries
=
s
.
readShortInt
();
int
entries
=
s
.
readShortInt
();
writer
.
println
(
"-- page "
+
page
+
": data leaf "
+
(
last
?
"(last)"
:
""
)
+
" table: "
+
storageId
+
" entries: "
+
entries
+
" columns: "
+
columnCount
);
writer
.
println
(
"-- page "
+
page
+
": data leaf "
+
(
last
?
"(last)"
:
""
)
+
" parent: "
+
parentPageId
+
" table: "
+
storageId
+
" entries: "
+
entries
+
" columns: "
+
columnCount
);
dumpPageDataLeaf
(
writer
,
s
,
last
,
page
,
columnCount
,
entries
);
dumpPageDataLeaf
(
writer
,
s
,
last
,
page
,
columnCount
,
entries
);
break
;
break
;
}
}
// type 2
// type 2
case
Page
.
TYPE_DATA_NODE
:
{
case
Page
.
TYPE_DATA_NODE
:
{
pageTypeCount
[
type
]++;
pageTypeCount
[
type
]++;
int
parentPageId
=
s
.
readInt
();
setStorage
(
s
.
readVarInt
());
setStorage
(
s
.
readVarInt
());
int
rowCount
=
s
.
readInt
();
int
rowCount
=
s
.
readInt
();
int
entries
=
s
.
readShortInt
();
int
entries
=
s
.
readShortInt
();
writer
.
println
(
"-- page "
+
page
+
": data node "
+
(
last
?
"(last)"
:
""
)
+
" entries: "
+
entries
+
" rowCount: "
+
rowCount
);
writer
.
println
(
"-- page "
+
page
+
": data node "
+
(
last
?
"(last)"
:
""
)
+
" parent: "
+
parentPageId
+
" entries: "
+
entries
+
" rowCount: "
+
rowCount
);
break
;
break
;
}
}
// type 3
// type 3
...
@@ -900,9 +900,11 @@ public class Recover extends Tool implements DataHandler {
...
@@ -900,9 +900,11 @@ public class Recover extends Tool implements DataHandler {
// type 4
// type 4
case
Page
.
TYPE_BTREE_LEAF
:
{
case
Page
.
TYPE_BTREE_LEAF
:
{
pageTypeCount
[
type
]++;
pageTypeCount
[
type
]++;
int
parentPageId
=
s
.
readInt
();
setStorage
(
s
.
readVarInt
());
setStorage
(
s
.
readVarInt
());
int
entries
=
s
.
readShortInt
();
int
entries
=
s
.
readShortInt
();
writer
.
println
(
"-- page "
+
page
+
": b-tree leaf "
+
(
last
?
"(last)"
:
""
)
+
" index: "
+
storageId
+
" entries: "
+
entries
);
writer
.
println
(
"-- page "
+
page
+
": b-tree leaf "
+
(
last
?
"(last)"
:
""
)
+
" parent: "
+
parentPageId
+
" index: "
+
storageId
+
" entries: "
+
entries
);
if
(
trace
)
{
if
(
trace
)
{
dumpPageBtreeLeaf
(
writer
,
s
,
entries
,
!
last
);
dumpPageBtreeLeaf
(
writer
,
s
,
entries
,
!
last
);
}
}
...
@@ -911,8 +913,10 @@ public class Recover extends Tool implements DataHandler {
...
@@ -911,8 +913,10 @@ public class Recover extends Tool implements DataHandler {
// type 5
// type 5
case
Page
.
TYPE_BTREE_NODE
:
case
Page
.
TYPE_BTREE_NODE
:
pageTypeCount
[
type
]++;
pageTypeCount
[
type
]++;
int
parentPageId
=
s
.
readInt
();
setStorage
(
s
.
readVarInt
());
setStorage
(
s
.
readVarInt
());
writer
.
println
(
"-- page "
+
page
+
": b-tree node"
+
(
last
?
"(last)"
:
""
)
+
" index: "
+
storageId
);
writer
.
println
(
"-- page "
+
page
+
": b-tree node"
+
(
last
?
"(last)"
:
""
)
+
" parent: "
+
parentPageId
+
"index: "
+
storageId
);
if
(
trace
)
{
if
(
trace
)
{
dumpPageBtreeNode
(
writer
,
s
,
!
last
);
dumpPageBtreeNode
(
writer
,
s
,
!
last
);
}
}
...
@@ -1107,8 +1111,8 @@ public class Recover extends Tool implements DataHandler {
...
@@ -1107,8 +1111,8 @@ public class Recover extends Tool implements DataHandler {
store
.
seek
((
long
)
trunkPage
*
pageSize
);
store
.
seek
((
long
)
trunkPage
*
pageSize
);
store
.
readFully
(
page
.
getBytes
(),
0
,
pageSize
);
store
.
readFully
(
page
.
getBytes
(),
0
,
pageSize
);
page
.
reset
();
page
.
reset
();
page
.
readInt
();
int
t
=
page
.
readByte
();
int
t
=
page
.
readByte
();
page
.
readInt
();
if
(
t
!=
Page
.
TYPE_STREAM_TRUNK
)
{
if
(
t
!=
Page
.
TYPE_STREAM_TRUNK
)
{
writer
.
println
(
"-- eof page: "
+
trunkPage
+
" type: "
+
t
+
" expected type: "
+
Page
.
TYPE_STREAM_TRUNK
);
writer
.
println
(
"-- eof page: "
+
trunkPage
+
" type: "
+
t
+
" expected type: "
+
Page
.
TYPE_STREAM_TRUNK
);
endOfFile
=
true
;
endOfFile
=
true
;
...
@@ -1140,8 +1144,8 @@ public class Recover extends Tool implements DataHandler {
...
@@ -1140,8 +1144,8 @@ public class Recover extends Tool implements DataHandler {
store
.
seek
((
long
)
nextPage
*
pageSize
);
store
.
seek
((
long
)
nextPage
*
pageSize
);
store
.
readFully
(
page
.
getBytes
(),
0
,
pageSize
);
store
.
readFully
(
page
.
getBytes
(),
0
,
pageSize
);
page
.
reset
();
page
.
reset
();
int
p
=
page
.
readInt
();
int
t
=
page
.
readByte
();
int
t
=
page
.
readByte
();
int
p
=
page
.
readInt
();
int
k
=
page
.
readInt
();
int
k
=
page
.
readInt
();
if
(
t
!=
Page
.
TYPE_STREAM_DATA
)
{
if
(
t
!=
Page
.
TYPE_STREAM_DATA
)
{
writer
.
println
(
"-- eof page: "
+
nextPage
+
" type: "
+
t
+
" parent: "
+
p
+
writer
.
println
(
"-- eof page: "
+
nextPage
+
" type: "
+
t
+
" parent: "
+
p
+
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论