Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
03e1c25a
提交
03e1c25a
authored
3月 21, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
new experimental page store
上级
d7e9f4a2
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
171 行增加
和
120 行删除
+171
-120
Database.java
h2/src/main/org/h2/engine/Database.java
+3
-26
PageBtreeIndex.java
h2/src/main/org/h2/index/PageBtreeIndex.java
+11
-11
PageScanIndex.java
h2/src/main/org/h2/index/PageScanIndex.java
+13
-8
PageLog.java
h2/src/main/org/h2/store/PageLog.java
+2
-3
PageStore.java
h2/src/main/org/h2/store/PageStore.java
+133
-63
TableData.java
h2/src/main/org/h2/table/TableData.java
+9
-9
没有找到文件。
h2/src/main/org/h2/engine/Database.java
浏览文件 @
03e1c25a
...
@@ -524,7 +524,9 @@ public class Database implements DataHandler {
...
@@ -524,7 +524,9 @@ public class Database implements DataHandler {
// wait until pending changes are written
// wait until pending changes are written
isReconnectNeeded
();
isReconnectNeeded
();
if
(
SysProperties
.
PAGE_STORE
)
{
if
(
SysProperties
.
PAGE_STORE
)
{
starting
=
true
;
getPageStore
();
getPageStore
();
starting
=
false
;
}
}
if
(
FileUtils
.
exists
(
dataFileName
))
{
if
(
FileUtils
.
exists
(
dataFileName
))
{
lobFilesInDirectories
&=
!
ValueLob
.
existsLobFile
(
getDatabasePath
());
lobFilesInDirectories
&=
!
ValueLob
.
existsLobFile
(
getDatabasePath
());
...
@@ -582,7 +584,7 @@ public class Database implements DataHandler {
...
@@ -582,7 +584,7 @@ public class Database implements DataHandler {
cols
.
add
(
new
Column
(
"SQL"
,
Value
.
STRING
));
cols
.
add
(
new
Column
(
"SQL"
,
Value
.
STRING
));
int
headPos
=
0
;
int
headPos
=
0
;
if
(
pageStore
!=
null
)
{
if
(
pageStore
!=
null
)
{
headPos
=
pageStore
.
get
Meta
TableHeadPos
();
headPos
=
pageStore
.
get
System
TableHeadPos
();
}
}
meta
=
mainSchema
.
createTable
(
"SYS"
,
0
,
cols
,
persistent
,
false
,
headPos
);
meta
=
mainSchema
.
createTable
(
"SYS"
,
0
,
cols
,
persistent
,
false
,
headPos
);
tableMap
.
put
(
0
,
meta
);
tableMap
.
put
(
0
,
meta
);
...
@@ -2143,31 +2145,6 @@ public class Database implements DataHandler {
...
@@ -2143,31 +2145,6 @@ public class Database implements DataHandler {
return
pageStore
;
return
pageStore
;
}
}
/**
* Redo a change in a table.
*
* @param tableId the object id of the table
* @param row the row
* @param add true if the record is added, false if deleted
*/
public
void
redo
(
int
tableId
,
Row
row
,
boolean
add
)
throws
SQLException
{
TableData
table
=
(
TableData
)
tableMap
.
get
(
tableId
);
if
(
add
)
{
table
.
addRow
(
systemSession
,
row
);
}
else
{
table
.
removeRow
(
systemSession
,
row
);
}
if
(
tableId
==
0
)
{
MetaRecord
m
=
new
MetaRecord
(
row
);
if
(
add
)
{
objectIds
.
set
(
m
.
getId
());
m
.
execute
(
this
,
systemSession
,
eventListener
);
}
else
{
m
.
undo
(
this
,
systemSession
,
eventListener
);
}
}
}
/**
/**
* Get the first user defined table.
* Get the first user defined table.
*
*
...
...
h2/src/main/org/h2/index/PageBtreeIndex.java
浏览文件 @
03e1c25a
...
@@ -11,6 +11,7 @@ import org.h2.constant.ErrorCode;
...
@@ -11,6 +11,7 @@ import org.h2.constant.ErrorCode;
import
org.h2.constant.SysProperties
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.message.Message
;
import
org.h2.message.Message
;
import
org.h2.message.TraceSystem
;
import
org.h2.result.Row
;
import
org.h2.result.Row
;
import
org.h2.result.SearchRow
;
import
org.h2.result.SearchRow
;
import
org.h2.store.DataPage
;
import
org.h2.store.DataPage
;
...
@@ -36,6 +37,7 @@ public class PageBtreeIndex extends BaseIndex {
...
@@ -36,6 +37,7 @@ public class PageBtreeIndex extends BaseIndex {
public
PageBtreeIndex
(
TableData
table
,
int
id
,
String
indexName
,
IndexColumn
[]
columns
,
public
PageBtreeIndex
(
TableData
table
,
int
id
,
String
indexName
,
IndexColumn
[]
columns
,
IndexType
indexType
,
int
headPos
)
throws
SQLException
{
IndexType
indexType
,
int
headPos
)
throws
SQLException
{
initBaseIndex
(
table
,
id
,
indexName
,
columns
,
indexType
);
initBaseIndex
(
table
,
id
,
indexName
,
columns
,
indexType
);
int
test
;
// trace.setLevel(TraceSystem.DEBUG);
// trace.setLevel(TraceSystem.DEBUG);
if
(
database
.
isMultiVersion
())
{
if
(
database
.
isMultiVersion
())
{
int
todoMvcc
;
int
todoMvcc
;
...
@@ -49,22 +51,20 @@ public class PageBtreeIndex extends BaseIndex {
...
@@ -49,22 +51,20 @@ public class PageBtreeIndex extends BaseIndex {
if
(
headPos
==
Index
.
EMPTY_HEAD
)
{
if
(
headPos
==
Index
.
EMPTY_HEAD
)
{
// new index
// new index
needRebuild
=
true
;
needRebuild
=
true
;
headPos
=
store
.
allocatePage
();
this
.
headPos
=
headPos
=
store
.
allocatePage
();
PageBtreeLeaf
root
=
new
PageBtreeLeaf
(
this
,
headPos
,
Page
.
ROOT
,
store
.
createDataPage
());
PageBtreeLeaf
root
=
new
PageBtreeLeaf
(
this
,
headPos
,
Page
.
ROOT
,
store
.
createDataPage
());
store
.
updateRecord
(
root
,
true
,
root
.
data
);
store
.
updateRecord
(
root
,
true
,
root
.
data
);
int
test
;
store
.
addMeta
(
this
);
// } else if (store.isNew()) {
// // the system table for a new database
// PageBtreeLeaf root = new PageBtreeLeaf(this,
// headPos, Page.ROOT, store.createDataPage());
// store.updateRecord(root, true, root.data);
}
else
{
}
else
{
rowCount
=
getPage
(
headPos
).
getRowCount
();
this
.
headPos
=
headPos
;
PageBtree
root
=
getPage
(
headPos
);
rowCount
=
root
.
getRowCount
();
// could have been created before, but never committed
store
.
updateRecord
(
root
,
false
,
null
);
int
reuseKeysIfManyDeleted
;
int
reuseKeysIfManyDeleted
;
}
}
this
.
headPos
=
headPos
;
if
(
trace
.
isDebugEnabled
())
{
if
(
trace
.
isDebugEnabled
())
{
trace
.
debug
(
"open
"
+
rowCount
);
trace
.
debug
(
"open
ed "
+
getName
()
+
" rows:"
+
rowCount
);
}
}
}
}
...
@@ -211,7 +211,7 @@ public class PageBtreeIndex extends BaseIndex {
...
@@ -211,7 +211,7 @@ public class PageBtreeIndex extends BaseIndex {
if
(
trace
.
isDebugEnabled
())
{
if
(
trace
.
isDebugEnabled
())
{
trace
.
debug
(
"remove"
);
trace
.
debug
(
"remove"
);
}
}
int
todo
;
store
.
removeMeta
(
this
)
;
}
}
public
void
truncate
(
Session
session
)
throws
SQLException
{
public
void
truncate
(
Session
session
)
throws
SQLException
{
...
...
h2/src/main/org/h2/index/PageScanIndex.java
浏览文件 @
03e1c25a
...
@@ -12,6 +12,7 @@ import org.h2.constant.ErrorCode;
...
@@ -12,6 +12,7 @@ import org.h2.constant.ErrorCode;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.message.Message
;
import
org.h2.message.Message
;
import
org.h2.message.TraceSystem
;
import
org.h2.result.Row
;
import
org.h2.result.Row
;
import
org.h2.result.SearchRow
;
import
org.h2.result.SearchRow
;
import
org.h2.store.DataPage
;
import
org.h2.store.DataPage
;
...
@@ -32,25 +33,27 @@ public class PageScanIndex extends BaseIndex implements RowIndex {
...
@@ -32,25 +33,27 @@ public class PageScanIndex extends BaseIndex implements RowIndex {
private
PageStore
store
;
private
PageStore
store
;
private
TableData
tableData
;
private
TableData
tableData
;
private
int
headPos
;
private
final
int
headPos
;
private
int
lastKey
;
private
int
lastKey
;
private
long
rowCount
;
private
long
rowCount
;
public
PageScanIndex
(
TableData
table
,
int
id
,
IndexColumn
[]
columns
,
IndexType
indexType
,
int
headPos
)
throws
SQLException
{
public
PageScanIndex
(
TableData
table
,
int
id
,
IndexColumn
[]
columns
,
IndexType
indexType
,
int
headPos
)
throws
SQLException
{
initBaseIndex
(
table
,
id
,
table
.
getName
()
+
"_TABLE_SCAN"
,
columns
,
indexType
);
initBaseIndex
(
table
,
id
,
table
.
getName
()
+
"_TABLE_SCAN"
,
columns
,
indexType
);
int
test
;
// trace.setLevel(TraceSystem.DEBUG);
// trace.setLevel(TraceSystem.DEBUG);
if
(
database
.
isMultiVersion
())
{
if
(
database
.
isMultiVersion
())
{
int
todoMvcc
;
int
todoMvcc
;
}
}
tableData
=
table
;
tableData
=
table
;
if
(!
database
.
isPersistent
()
||
id
<
0
)
{
this
.
store
=
database
.
getPageStore
();
if
(!
database
.
isPersistent
())
{
int
todo
;
int
todo
;
this
.
headPos
=
0
;
return
;
return
;
}
}
this
.
store
=
database
.
getPageStore
();
if
(
headPos
==
Index
.
EMPTY_HEAD
)
{
if
(
headPos
==
Index
.
EMPTY_HEAD
)
{
// new table
// new table
headPos
=
store
.
allocatePage
();
this
.
headPos
=
headPos
=
store
.
allocatePage
();
store
.
addMeta
(
this
);
store
.
addMeta
(
this
);
PageDataLeaf
root
=
new
PageDataLeaf
(
this
,
headPos
,
Page
.
ROOT
,
store
.
createDataPage
());
PageDataLeaf
root
=
new
PageDataLeaf
(
this
,
headPos
,
Page
.
ROOT
,
store
.
createDataPage
());
store
.
updateRecord
(
root
,
true
,
root
.
data
);
store
.
updateRecord
(
root
,
true
,
root
.
data
);
...
@@ -61,6 +64,7 @@ public class PageScanIndex extends BaseIndex implements RowIndex {
...
@@ -61,6 +64,7 @@ public class PageScanIndex extends BaseIndex implements RowIndex {
// Page.ROOT, store.createDataPage());
// Page.ROOT, store.createDataPage());
// store.updateRecord(root, true, root.data);
// store.updateRecord(root, true, root.data);
}
else
{
}
else
{
this
.
headPos
=
headPos
;
PageData
root
=
getPage
(
headPos
);
PageData
root
=
getPage
(
headPos
);
lastKey
=
root
.
getLastKey
();
lastKey
=
root
.
getLastKey
();
rowCount
=
root
.
getRowCount
();
rowCount
=
root
.
getRowCount
();
...
@@ -68,9 +72,8 @@ public class PageScanIndex extends BaseIndex implements RowIndex {
...
@@ -68,9 +72,8 @@ public class PageScanIndex extends BaseIndex implements RowIndex {
store
.
updateRecord
(
root
,
false
,
null
);
store
.
updateRecord
(
root
,
false
,
null
);
int
reuseKeysIfManyDeleted
;
int
reuseKeysIfManyDeleted
;
}
}
this
.
headPos
=
headPos
;
if
(
trace
.
isDebugEnabled
())
{
if
(
trace
.
isDebugEnabled
())
{
trace
.
debug
(
"open
"
+
rowCount
);
trace
.
debug
(
"open
ed "
+
getName
()
+
" rows:
"
+
rowCount
);
}
}
table
.
setRowCount
(
rowCount
);
table
.
setRowCount
(
rowCount
);
}
}
...
@@ -80,7 +83,9 @@ public class PageScanIndex extends BaseIndex implements RowIndex {
...
@@ -80,7 +83,9 @@ public class PageScanIndex extends BaseIndex implements RowIndex {
}
}
public
void
add
(
Session
session
,
Row
row
)
throws
SQLException
{
public
void
add
(
Session
session
,
Row
row
)
throws
SQLException
{
row
.
setPos
(++
lastKey
);
if
(
row
.
getPos
()
==
0
)
{
row
.
setPos
(++
lastKey
);
}
if
(
trace
.
isDebugEnabled
())
{
if
(
trace
.
isDebugEnabled
())
{
trace
.
debug
(
"add "
+
row
.
getPos
());
trace
.
debug
(
"add "
+
row
.
getPos
());
}
}
...
@@ -217,7 +222,7 @@ public class PageScanIndex extends BaseIndex implements RowIndex {
...
@@ -217,7 +222,7 @@ public class PageScanIndex extends BaseIndex implements RowIndex {
if
(
trace
.
isDebugEnabled
())
{
if
(
trace
.
isDebugEnabled
())
{
trace
.
debug
(
"remove"
);
trace
.
debug
(
"remove"
);
}
}
int
todo
;
store
.
removeMeta
(
this
)
;
}
}
public
void
truncate
(
Session
session
)
throws
SQLException
{
public
void
truncate
(
Session
session
)
throws
SQLException
{
...
...
h2/src/main/org/h2/store/PageLog.java
浏览文件 @
03e1c25a
...
@@ -154,12 +154,11 @@ public class PageLog {
...
@@ -154,12 +154,11 @@ public class PageLog {
int
tableId
=
in
.
readInt
();
int
tableId
=
in
.
readInt
();
Row
row
=
readRow
(
in
,
data
);
Row
row
=
readRow
(
in
,
data
);
if
(!
undo
)
{
if
(!
undo
)
{
Database
db
=
store
.
getDatabase
();
if
(
store
.
isSessionCommitted
(
sessionId
,
id
,
pos
))
{
if
(
store
.
isSessionCommitted
(
sessionId
,
id
,
pos
))
{
if
(
trace
.
isDebugEnabled
())
{
if
(
trace
.
isDebugEnabled
())
{
trace
.
debug
(
"log redo "
+
(
x
==
ADD
?
"+"
:
"-"
)
+
" "
+
row
);
trace
.
debug
(
"log redo "
+
(
x
==
ADD
?
"+"
:
"-"
)
+
"
table:"
+
tableId
+
"
"
+
row
);
}
}
db
.
redo
(
tableId
,
row
,
x
==
ADD
);
store
.
redo
(
tableId
,
row
,
x
==
ADD
);
}
}
}
}
}
else
if
(
x
==
COMMIT
)
{
}
else
if
(
x
==
COMMIT
)
{
...
...
h2/src/main/org/h2/store/PageStore.java
浏览文件 @
03e1c25a
差异被折叠。
点击展开。
h2/src/main/org/h2/table/TableData.java
浏览文件 @
03e1c25a
...
@@ -239,15 +239,15 @@ public class TableData extends Table implements RecordReader {
...
@@ -239,15 +239,15 @@ public class TableData extends Table implements RecordReader {
}
else
{
}
else
{
database
.
addSchemaObject
(
session
,
index
);
database
.
addSchemaObject
(
session
,
index
);
}
}
//
Need to update, because maybe the index is rebuilt at startup,
//
must not do this when using the page store
//
and so the head pos may have changed, which needs to be stored now.
//
because recovery is not done yet
// addSchemaObject doesn't update the sys table at startup
if
(!
SysProperties
.
PAGE_STORE
)
{
if
(
index
.
getIndexType
().
getPersistent
()
&&
!
database
.
getReadOnly
()
// need to update, because maybe the index is rebuilt at startup,
&&
!
database
.
getLog
().
containsInDoubtTransactions
())
{
// and so the head pos may have changed, which needs to be stored now.
//
can not save anything in the log file if it contains in-doubt transactions
//
addSchemaObject doesn't update the sys table at startup
if
(
!
SysProperties
.
PAGE_STORE
)
{
if
(
index
.
getIndexType
().
getPersistent
()
&&
!
database
.
getReadOnly
()
// must not do this when using the page store
&&
!
database
.
getLog
().
containsInDoubtTransactions
())
{
//
because recovery is not done yet
//
can not save anything in the log file if it contains in-doubt transactions
database
.
update
(
session
,
index
);
database
.
update
(
session
,
index
);
}
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论