Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
b8f74f1b
提交
b8f74f1b
authored
7月 17, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
New experimental page store.
上级
a4afb494
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
58 行增加
和
67 行删除
+58
-67
LogSystem.java
h2/src/main/org/h2/log/LogSystem.java
+3
-0
PageLog.java
h2/src/main/org/h2/store/PageLog.java
+7
-11
PageOutputStream.java
h2/src/main/org/h2/store/PageOutputStream.java
+1
-16
PageStore.java
h2/src/main/org/h2/store/PageStore.java
+32
-22
WriterThread.java
h2/src/main/org/h2/store/WriterThread.java
+10
-15
TableData.java
h2/src/main/org/h2/table/TableData.java
+5
-3
没有找到文件。
h2/src/main/org/h2/log/LogSystem.java
浏览文件 @
b8f74f1b
...
@@ -713,6 +713,9 @@ public class LogSystem {
...
@@ -713,6 +713,9 @@ public class LogSystem {
* @return the write position
* @return the write position
*/
*/
public
String
getWritePos
()
{
public
String
getWritePos
()
{
if
(
pageStore
!=
null
)
{
return
""
+
pageStore
.
getWriteCount
();
}
return
currentLog
.
getId
()
+
"/"
+
currentLog
.
getPos
();
return
currentLog
.
getId
()
+
"/"
+
currentLog
.
getPos
();
}
}
...
...
h2/src/main/org/h2/store/PageLog.java
浏览文件 @
b8f74f1b
...
@@ -562,19 +562,15 @@ public class PageLog {
...
@@ -562,19 +562,15 @@ public class PageLog {
}
}
/**
/**
* Close
the lo
g.
* Close
without further writin
g.
*/
*/
void
close
()
throws
SQLException
{
void
close
()
{
try
{
trace
.
debug
(
"log close"
);
trace
.
debug
(
"log close"
);
if
(
pageOut
!=
null
)
{
if
(
pageOut
!=
null
)
{
pageOut
.
close
();
pageOut
.
close
();
pageOut
=
null
;
pageOut
=
null
;
}
out
=
null
;
}
catch
(
IOException
e
)
{
throw
Message
.
convertIOException
(
e
,
null
);
}
}
out
=
null
;
}
}
/**
/**
...
...
h2/src/main/org/h2/store/PageOutputStream.java
浏览文件 @
b8f74f1b
...
@@ -155,13 +155,7 @@ public class PageOutputStream extends OutputStream {
...
@@ -155,13 +155,7 @@ public class PageOutputStream extends OutputStream {
}
}
}
}
public
void
close
()
throws
IOException
{
public
void
close
()
{
flush
();
try
{
freeReserve
();
}
catch
(
SQLException
e
)
{
throw
Message
.
convertToIOException
(
e
);
}
store
=
null
;
store
=
null
;
}
}
...
@@ -187,15 +181,6 @@ public class PageOutputStream extends OutputStream {
...
@@ -187,15 +181,6 @@ public class PageOutputStream extends OutputStream {
return
pages
*
store
.
getPageSize
();
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
;
}
/**
/**
* Remove a trunk page from the stream.
* Remove a trunk page from the stream.
*
*
...
...
h2/src/main/org/h2/store/PageStore.java
浏览文件 @
b8f74f1b
...
@@ -98,7 +98,11 @@ public class PageStore implements CacheWriter {
...
@@ -98,7 +98,11 @@ public class PageStore implements CacheWriter {
// TODO PageData and PageBtree addRowTry: try to simplify
// TODO PageData and PageBtree addRowTry: try to simplify
// TODO test running out of disk space (using a special file system)
// TODO test running out of disk space (using a special file system)
// TODO check for file size (exception if not exact size expected)
// TODO check for file size (exception if not exact size expected)
// TODO implement missing code for STORE_BTREE_ROWCOUNT (maybe enable, maybe not)
// TODO implement missing code for STORE_BTREE_ROWCOUNT (maybe enable)
// TODO delete: only log the key
// TODO update: only log the key and changed values
// TODO store dates differently in Data; test moving db to another timezone
// TODO online backup using bsdiff
// TODO when removing DiskFile:
// TODO when removing DiskFile:
// remove CacheObject.blockCount
// remove CacheObject.blockCount
...
@@ -152,7 +156,7 @@ public class PageStore implements CacheWriter {
...
@@ -152,7 +156,7 @@ public class PageStore implements CacheWriter {
private
String
accessMode
;
private
String
accessMode
;
private
int
pageSize
;
private
int
pageSize
;
private
int
pageSizeShift
;
private
int
pageSizeShift
;
private
long
writeCount
er
;
private
long
writeCount
;
private
int
logFirstTrunkPage
,
logFirstDataPage
;
private
int
logFirstTrunkPage
,
logFirstDataPage
;
private
int
cacheSize
;
private
int
cacheSize
;
...
@@ -321,6 +325,7 @@ public class PageStore implements CacheWriter {
...
@@ -321,6 +325,7 @@ public class PageStore implements CacheWriter {
if
(!
isUsed
(
i
))
{
if
(!
isUsed
(
i
))
{
file
.
seek
((
long
)
i
<<
pageSizeShift
);
file
.
seek
((
long
)
i
<<
pageSizeShift
);
file
.
write
(
empty
,
0
,
pageSize
);
file
.
write
(
empty
,
0
,
pageSize
);
writeCount
++;
}
}
}
}
// TODO shrink file if required here
// TODO shrink file if required here
...
@@ -374,7 +379,7 @@ public class PageStore implements CacheWriter {
...
@@ -374,7 +379,7 @@ public class PageStore implements CacheWriter {
}
}
page
.
reset
();
page
.
reset
();
readPage
(
i
,
page
);
readPage
(
i
,
page
);
writeCount
er
=
page
.
readLong
();
writeCount
=
page
.
readLong
();
logFirstTrunkPage
=
page
.
readInt
();
logFirstTrunkPage
=
page
.
readInt
();
logFirstDataPage
=
page
.
readInt
();
logFirstDataPage
=
page
.
readInt
();
CRC32
crc
=
new
CRC32
();
CRC32
crc
=
new
CRC32
();
...
@@ -437,7 +442,7 @@ public class PageStore implements CacheWriter {
...
@@ -437,7 +442,7 @@ public class PageStore implements CacheWriter {
private
void
writeVariableHeader
()
throws
SQLException
{
private
void
writeVariableHeader
()
throws
SQLException
{
Data
page
=
Data
.
create
(
database
,
pageSize
);
Data
page
=
Data
.
create
(
database
,
pageSize
);
page
.
writeLong
(
writeCount
er
);
page
.
writeLong
(
writeCount
);
page
.
writeInt
(
logFirstTrunkPage
);
page
.
writeInt
(
logFirstTrunkPage
);
page
.
writeInt
(
logFirstDataPage
);
page
.
writeInt
(
logFirstDataPage
);
CRC32
crc
=
new
CRC32
();
CRC32
crc
=
new
CRC32
();
...
@@ -447,32 +452,26 @@ public class PageStore implements CacheWriter {
...
@@ -447,32 +452,26 @@ public class PageStore implements CacheWriter {
file
.
write
(
page
.
getBytes
(),
0
,
pageSize
);
file
.
write
(
page
.
getBytes
(),
0
,
pageSize
);
file
.
seek
(
pageSize
+
pageSize
);
file
.
seek
(
pageSize
+
pageSize
);
file
.
write
(
page
.
getBytes
(),
0
,
pageSize
);
file
.
write
(
page
.
getBytes
(),
0
,
pageSize
);
writeCount
++;
}
}
/**
/**
* Close the file without
writing anyth
ing.
* Close the file without
further writ
ing.
*/
*/
public
void
close
()
throws
SQLException
{
public
void
close
()
throws
SQLException
{
Exception
closeException
=
null
;
trace
.
debug
(
"close"
);
try
{
if
(
log
!=
null
)
{
trace
.
debug
(
"close"
);
log
.
close
();
if
(
log
!=
null
)
{
log
=
null
;
log
.
close
();
}
}
catch
(
SQLException
e
)
{
closeException
=
e
;
}
}
try
{
if
(
file
!=
null
)
{
if
(
file
!=
null
)
{
try
{
file
.
close
();
file
.
close
();
}
catch
(
IOException
e
)
{
throw
Message
.
convert
(
e
);
}
finally
{
file
=
null
;
}
}
}
catch
(
IOException
e
)
{
closeException
=
e
;
}
log
=
null
;
file
=
null
;
if
(
closeException
!=
null
)
{
throw
Message
.
convert
(
closeException
);
}
}
}
}
...
@@ -597,6 +596,7 @@ public class PageStore implements CacheWriter {
...
@@ -597,6 +596,7 @@ public class PageStore implements CacheWriter {
pageCount
+=
increment
;
pageCount
+=
increment
;
long
newLength
=
(
long
)
pageCount
<<
pageSizeShift
;
long
newLength
=
(
long
)
pageCount
<<
pageSizeShift
;
file
.
setLength
(
newLength
);
file
.
setLength
(
newLength
);
writeCount
++;
fileLength
=
newLength
;
fileLength
=
newLength
;
}
}
...
@@ -703,6 +703,7 @@ public class PageStore implements CacheWriter {
...
@@ -703,6 +703,7 @@ public class PageStore implements CacheWriter {
synchronized
(
database
)
{
synchronized
(
database
)
{
file
.
seek
((
long
)
pageId
<<
pageSizeShift
);
file
.
seek
((
long
)
pageId
<<
pageSizeShift
);
file
.
write
(
data
.
getBytes
(),
0
,
pageSize
);
file
.
write
(
data
.
getBytes
(),
0
,
pageSize
);
writeCount
++;
}
}
}
}
...
@@ -1035,6 +1036,15 @@ public class PageStore implements CacheWriter {
...
@@ -1035,6 +1036,15 @@ public class PageStore implements CacheWriter {
return
new
SearchRow
[
entryCount
];
return
new
SearchRow
[
entryCount
];
}
}
/**
* Get the write count.
*
* @return the write count
*/
public
long
getWriteCount
()
{
return
writeCount
;
}
// TODO implement checksum
// TODO implement checksum
// private void updateChecksum(byte[] d, int pos) {
// private void updateChecksum(byte[] d, int pos) {
// int ps = pageSize;
// int ps = pageSize;
...
...
h2/src/main/org/h2/store/WriterThread.java
浏览文件 @
b8f74f1b
...
@@ -112,26 +112,21 @@ public class WriterThread implements Runnable {
...
@@ -112,26 +112,21 @@ public class WriterThread implements Runnable {
if
(
database
==
null
)
{
if
(
database
==
null
)
{
break
;
break
;
}
}
if
(
Constants
.
FLUSH_INDEX_DELAY
!=
0
)
{
boolean
flush
=
Constants
.
FLUSH_INDEX_DELAY
!=
0
;
if
(
flush
)
{
flushIndexesIfRequired
(
database
);
flushIndexesIfRequired
(
database
);
}
}
// checkpoint if required
try
{
try
{
database
.
checkpointIfRequired
();
if
(
database
.
isFileLockSerialized
())
{
}
catch
(
SQLException
e
)
{
database
.
checkpointIfRequired
();
TraceSystem
traceSystem
=
database
.
getTraceSystem
();
}
else
{
if
(
traceSystem
!=
null
)
{
LogSystem
log
=
database
.
getLog
();
traceSystem
.
getTrace
(
Trace
.
LOG
).
error
(
"reconnectCheckpoint"
,
e
);
if
(
log
==
null
)
{
break
;
}
log
.
flush
();
}
}
}
LogSystem
log
=
database
.
getLog
();
if
(
log
==
null
)
{
break
;
}
try
{
log
.
flush
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
TraceSystem
traceSystem
=
database
.
getTraceSystem
();
TraceSystem
traceSystem
=
database
.
getTraceSystem
();
if
(
traceSystem
!=
null
)
{
if
(
traceSystem
!=
null
)
{
...
...
h2/src/main/org/h2/table/TableData.java
浏览文件 @
b8f74f1b
...
@@ -346,9 +346,11 @@ public class TableData extends Table implements RecordReader {
...
@@ -346,9 +346,11 @@ public class TableData extends Table implements RecordReader {
Index
index
=
indexes
.
get
(
i
);
Index
index
=
indexes
.
get
(
i
);
index
.
truncate
(
session
);
index
.
truncate
(
session
);
if
(
SysProperties
.
CHECK
)
{
if
(
SysProperties
.
CHECK
)
{
long
rc
=
index
.
getRowCount
(
session
);
if
(!
database
.
isPageStoreEnabled
())
{
if
(
rc
!=
0
)
{
long
rc
=
index
.
getRowCount
(
session
);
Message
.
throwInternalError
(
"rowCount expected 0 got "
+
rc
);
if
(
rc
!=
0
)
{
Message
.
throwInternalError
(
"rowCount expected 0 got "
+
rc
);
}
}
}
}
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论