Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
5ccb0378
提交
5ccb0378
authored
7月 01, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
New experimental page store.
上级
9658fe81
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
47 行增加
和
19 行删除
+47
-19
PageFreeList.java
h2/src/main/org/h2/store/PageFreeList.java
+2
-2
PageLog.java
h2/src/main/org/h2/store/PageLog.java
+12
-4
PageOutputStream.java
h2/src/main/org/h2/store/PageOutputStream.java
+14
-4
PageStore.java
h2/src/main/org/h2/store/PageStore.java
+7
-1
Recover.java
h2/src/main/org/h2/tools/Recover.java
+12
-8
没有找到文件。
h2/src/main/org/h2/store/PageFreeList.java
浏览文件 @
5ccb0378
...
...
@@ -103,9 +103,9 @@ public class PageFreeList extends Record {
+
" expected type:"
+
Page
.
TYPE_FREE_LIST
);
}
for
(
int
i
=
0
;
i
<
pageCount
;
i
+=
8
)
{
used
.
setByte
(
i
,
data
.
readByte
());
used
.
setByte
(
i
,
data
.
readByte
()
&
255
);
}
full
=
used
.
nextClearBit
(
0
)
>=
pageCount
*
8
;
full
=
false
;
}
public
int
getByteCount
(
DataPage
dummy
)
{
...
...
h2/src/main/org/h2/store/PageLog.java
浏览文件 @
5ccb0378
...
...
@@ -144,11 +144,18 @@ public class PageLog {
* Free up all pages allocated by the log.
*/
void
free
()
throws
SQLException
{
if
(
this
.
firstTrunkPage
!=
0
)
{
while
(
this
.
firstTrunkPage
!=
0
)
{
// first remove all old log pages
PageStreamTrunk
t
=
new
PageStreamTrunk
(
store
,
this
.
firstTrunkPage
);
t
.
read
();
try
{
t
.
read
();
}
catch
(
SQLException
e
)
{
store
.
freePage
(
firstTrunkPage
,
false
,
null
);
// EOF
break
;
}
t
.
free
();
firstTrunkPage
=
t
.
getNextTrunk
();
}
}
...
...
@@ -525,8 +532,9 @@ public class PageLog {
void
close
()
throws
SQLException
{
try
{
trace
.
debug
(
"log close"
);
if
(
out
!=
null
)
{
out
.
close
();
if
(
pageOut
!=
null
)
{
pageOut
.
close
();
pageOut
=
null
;
}
out
=
null
;
}
catch
(
IOException
e
)
{
...
...
h2/src/main/org/h2/store/PageOutputStream.java
浏览文件 @
5ccb0378
...
...
@@ -93,10 +93,6 @@ public class PageOutputStream extends OutputStream {
}
int
len
=
PageStreamTrunk
.
getPagesAddressed
(
store
.
getPageSize
());
int
[]
pageIds
=
new
int
[
len
];
if
(
reservedPages
.
size
()
<
len
)
{
int
test
;
System
.
out
.
println
(
"stop"
);
}
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
pageIds
[
i
]
=
reservedPages
.
get
(
i
);
}
...
...
@@ -161,6 +157,11 @@ public class PageOutputStream extends OutputStream {
public
void
close
()
throws
IOException
{
flush
();
try
{
freeReserve
();
}
catch
(
SQLException
e
)
{
throw
Message
.
convertToIOException
(
e
);
}
store
=
null
;
}
...
...
@@ -207,4 +208,13 @@ public class PageOutputStream extends OutputStream {
return
pages
*
store
.
getPageSize
();
}
private
void
freeReserve
()
throws
SQLException
{
for
(
int
i
=
0
;
i
<
reservedPages
.
size
();
i
++)
{
int
p
=
reservedPages
.
get
(
i
);
store
.
freePage
(
p
,
false
,
null
);
}
reservedPages
=
new
IntArray
();
remaining
=
0
;
}
}
h2/src/main/org/h2/store/PageStore.java
浏览文件 @
5ccb0378
...
...
@@ -181,7 +181,8 @@ public class PageStore implements CacheWriter {
private
PageScanIndex
metaIndex
;
private
HashMap
<
Integer
,
Index
>
metaObjects
;
private
int
systemTableHeadPos
;
private
long
maxLogSize
=
Constants
.
DEFAULT_MAX_LOG_SIZE
;
// TODO reduce DEFAULT_MAX_LOG_SIZE, and don't divide here
private
long
maxLogSize
=
Constants
.
DEFAULT_MAX_LOG_SIZE
/
10
;
/**
* Create a new page store object.
...
...
@@ -309,6 +310,10 @@ public class PageStore implements CacheWriter {
}
log
.
checkpoint
();
switchLog
();
// write back the free list
for
(
CacheObject
rec
:
list
)
{
writeBack
(
rec
);
}
byte
[]
empty
=
new
byte
[
pageSize
];
// TODO avoid to write empty pages
for
(
int
i
=
PAGE_ID_FREE_LIST_ROOT
;
i
<
pageCount
;
i
++)
{
...
...
@@ -452,6 +457,7 @@ public class PageStore implements CacheWriter {
public
void
close
()
throws
SQLException
{
try
{
trace
.
debug
(
"close"
);
log
.
close
();
if
(
file
!=
null
)
{
file
.
close
();
}
...
...
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
5ccb0378
...
...
@@ -826,7 +826,7 @@ public class Recover extends Tool implements DataHandler {
break
;
case
Page
.
TYPE_FREE_LIST
:
writer
.
println
(
"-- page "
+
page
+
": free list "
+
(
last
?
"(last)"
:
""
));
free
+=
dumpPageFreeList
(
writer
,
s
,
pageSize
,
page
);
free
+=
dumpPageFreeList
(
writer
,
s
,
pageSize
,
page
,
pageCount
);
break
;
case
Page
.
TYPE_STREAM_TRUNK
:
writer
.
println
(
"-- page "
+
page
+
": log trunk"
);
...
...
@@ -1052,22 +1052,26 @@ public class Recover extends Tool implements DataHandler {
writer
.
println
(
"-- ["
+
entryCount
+
"] child: "
+
children
[
entryCount
]
+
" rowCount: "
+
rowCount
);
}
private
int
dumpPageFreeList
(
PrintWriter
writer
,
DataPage
s
,
int
pageSize
,
long
pageId
)
{
private
int
dumpPageFreeList
(
PrintWriter
writer
,
DataPage
s
,
int
pageSize
,
long
pageId
,
long
pageCount
)
{
int
pagesAddressed
=
PageFreeList
.
getPagesAddressed
(
pageSize
);
BitField
used
=
new
BitField
();
for
(
int
i
=
0
;
i
<
pagesAddressed
;
i
+=
8
)
{
used
.
setByte
(
i
,
s
.
readByte
());
used
.
setByte
(
i
,
s
.
readByte
()
&
255
);
}
int
free
=
0
;
for
(
int
i
=
0
;
i
<
pagesAddressed
;
i
++)
{
if
(
i
%
8
0
==
0
)
{
for
(
long
i
=
0
,
j
=
pageId
;
i
<
pagesAddressed
&&
j
<
pageCount
;
i
++,
j
++)
{
if
(
i
==
0
||
j
%
10
0
==
0
)
{
if
(
i
>
0
)
{
writer
.
println
();
}
writer
.
print
(
"-- "
+
(
i
+
pageId
)
+
" "
);
writer
.
print
(
"-- "
+
j
+
" "
);
}
else
if
(
j
%
20
==
0
)
{
writer
.
print
(
" - "
);
}
else
if
(
j
%
10
==
0
)
{
writer
.
print
(
' '
);
}
writer
.
print
(
used
.
get
(
i
)
?
'1'
:
'0'
);
if
(!
used
.
get
(
i
))
{
writer
.
print
(
used
.
get
(
(
int
)
i
)
?
'1'
:
'0'
);
if
(!
used
.
get
(
(
int
)
i
))
{
free
++;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论