Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
f716dece
提交
f716dece
authored
3月 18, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
new experimental page store
上级
d54b5f08
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
61 行增加
和
7 行删除
+61
-7
PageScanIndex.java
h2/src/main/org/h2/index/PageScanIndex.java
+1
-1
PageStore.java
h2/src/main/org/h2/store/PageStore.java
+60
-6
没有找到文件。
h2/src/main/org/h2/index/PageScanIndex.java
浏览文件 @
f716dece
...
@@ -51,7 +51,7 @@ public class PageScanIndex extends BaseIndex implements RowIndex {
...
@@ -51,7 +51,7 @@ public class PageScanIndex extends BaseIndex implements RowIndex {
if
(
headPos
==
Index
.
EMPTY_HEAD
)
{
if
(
headPos
==
Index
.
EMPTY_HEAD
)
{
// new table
// new table
headPos
=
store
.
allocatePage
();
headPos
=
store
.
allocatePage
();
store
.
addMeta
(
this
,
id
);
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
);
...
...
h2/src/main/org/h2/store/PageStore.java
浏览文件 @
f716dece
...
@@ -14,7 +14,9 @@ import org.h2.constant.ErrorCode;
...
@@ -14,7 +14,9 @@ import org.h2.constant.ErrorCode;
import
org.h2.engine.Database
;
import
org.h2.engine.Database
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.index.Cursor
;
import
org.h2.index.Cursor
;
import
org.h2.index.Index
;
import
org.h2.index.IndexType
;
import
org.h2.index.IndexType
;
import
org.h2.index.PageBtreeIndex
;
import
org.h2.index.PageScanIndex
;
import
org.h2.index.PageScanIndex
;
import
org.h2.log.SessionState
;
import
org.h2.log.SessionState
;
import
org.h2.message.Message
;
import
org.h2.message.Message
;
...
@@ -33,8 +35,10 @@ import org.h2.util.CacheWriter;
...
@@ -33,8 +35,10 @@ import org.h2.util.CacheWriter;
import
org.h2.util.FileUtils
;
import
org.h2.util.FileUtils
;
import
org.h2.util.ObjectArray
;
import
org.h2.util.ObjectArray
;
import
org.h2.util.ObjectUtils
;
import
org.h2.util.ObjectUtils
;
import
org.h2.util.StringUtils
;
import
org.h2.value.Value
;
import
org.h2.value.Value
;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueString
;
/**
/**
* This class represents a file that is organized as a number of pages. The
* This class represents a file that is organized as a number of pages. The
...
@@ -140,6 +144,7 @@ public class PageStore implements CacheWriter {
...
@@ -140,6 +144,7 @@ public class PageStore implements CacheWriter {
private
TableData
pageTable
;
private
TableData
pageTable
;
private
PageScanIndex
pageIndex
;
private
PageScanIndex
pageIndex
;
private
HashMap
metaObjects
=
new
HashMap
();
/**
/**
* Create a new page store object.
* Create a new page store object.
...
@@ -735,11 +740,6 @@ trace.setLevel(TraceSystem.DEBUG);
...
@@ -735,11 +740,6 @@ trace.setLevel(TraceSystem.DEBUG);
return
state
.
isCommitted
(
logId
,
pos
);
return
state
.
isCommitted
(
logId
,
pos
);
}
}
public
void
addMeta
(
PageScanIndex
pageScanIndex
,
int
id
)
{
// pageIndex.add(session, row)
}
public
int
getMetaTableHeadPos
()
throws
SQLException
{
public
int
getMetaTableHeadPos
()
throws
SQLException
{
int
todo
;
int
todo
;
return
0
;
return
0
;
...
@@ -747,8 +747,10 @@ trace.setLevel(TraceSystem.DEBUG);
...
@@ -747,8 +747,10 @@ trace.setLevel(TraceSystem.DEBUG);
private
void
openPageIndex
()
throws
SQLException
{
private
void
openPageIndex
()
throws
SQLException
{
ObjectArray
cols
=
new
ObjectArray
();
ObjectArray
cols
=
new
ObjectArray
();
cols
.
add
(
new
Column
(
"ID"
,
Value
.
INT
));
cols
.
add
(
new
Column
(
"TYPE"
,
Value
.
INT
));
cols
.
add
(
new
Column
(
"PARENT"
,
Value
.
INT
));
cols
.
add
(
new
Column
(
"HEAD"
,
Value
.
INT
));
cols
.
add
(
new
Column
(
"HEAD"
,
Value
.
INT
));
cols
.
add
(
new
Column
(
"TABLE"
,
Value
.
INT
));
cols
.
add
(
new
Column
(
"COLUMNS"
,
Value
.
STRING
));
cols
.
add
(
new
Column
(
"COLUMNS"
,
Value
.
STRING
));
int
headPos
=
getSystemRootPageId
();
int
headPos
=
getSystemRootPageId
();
pageTable
=
database
.
getMainSchema
().
createTable
(
pageTable
=
database
.
getMainSchema
().
createTable
(
...
@@ -762,7 +764,59 @@ trace.setLevel(TraceSystem.DEBUG);
...
@@ -762,7 +764,59 @@ trace.setLevel(TraceSystem.DEBUG);
while
(
cursor
.
next
())
{
while
(
cursor
.
next
())
{
Row
row
=
cursor
.
get
();
Row
row
=
cursor
.
get
();
int
headPos
=
row
.
getValue
(
0
).
getInt
();
int
headPos
=
row
.
getValue
(
0
).
getInt
();
int
type
=
row
.
getValue
(
1
).
getInt
();
int
id
=
row
.
getValue
(
2
).
getInt
();
int
tableId
=
row
.
getValue
(
3
).
getInt
();
String
columnList
=
row
.
getValue
(
4
).
getString
();
String
[]
columns
=
StringUtils
.
arraySplit
(
columnList
,
','
,
false
);
IndexType
indexType
=
IndexType
.
createNonUnique
(
true
);
Index
meta
;
TableData
table
;
if
(
type
==
0
)
{
ObjectArray
columnArray
=
new
ObjectArray
();
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++)
{
Column
col
=
new
Column
(
"C"
+
i
,
Value
.
INT
);
columnArray
.
add
(
col
);
}
table
=
new
TableData
(
database
.
getMainSchema
(),
"T"
+
id
,
id
,
columnArray
,
true
,
false
,
headPos
);
}
else
{
PageScanIndex
p
=
(
PageScanIndex
)
metaObjects
.
get
(
ObjectUtils
.
getInteger
(
tableId
));
table
=
(
TableData
)
p
.
getTable
();
}
Column
[]
tableCols
=
table
.
getColumns
();
Column
[]
cols
=
new
Column
[
columns
.
length
];
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++)
{
cols
[
i
]
=
tableCols
[
Integer
.
parseInt
(
columns
[
i
])];
}
IndexColumn
[]
indexColumns
=
IndexColumn
.
wrap
(
cols
);
if
(
type
==
0
)
{
meta
=
new
PageScanIndex
(
table
,
id
,
indexColumns
,
indexType
,
headPos
);
}
else
{
meta
=
new
PageBtreeIndex
(
table
,
id
,
"I"
+
id
,
indexColumns
,
indexType
,
headPos
);
}
metaObjects
.
put
(
ObjectUtils
.
getInteger
(
id
),
meta
);
}
}
public
void
addMeta
(
Index
index
)
throws
SQLException
{
int
type
=
index
instanceof
PageScanIndex
?
0
:
1
;
Column
[]
columns
=
index
.
getColumns
();
String
[]
columnIndexes
=
new
String
[
columns
.
length
];
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++)
{
columnIndexes
[
i
]
=
String
.
valueOf
(
columns
[
i
].
getColumnId
());
}
}
String
columnList
=
StringUtils
.
arrayCombine
(
columnIndexes
,
','
);
addMeta
(
index
.
getId
(),
type
,
index
.
getHeadPos
(),
index
.
getTable
().
getId
(),
columnList
);
}
private
void
addMeta
(
int
id
,
int
type
,
int
parent
,
int
headPos
,
String
columnList
)
throws
SQLException
{
Row
row
=
pageTable
.
getTemplateRow
();
row
.
setValue
(
0
,
ValueInt
.
get
(
id
));
row
.
setValue
(
1
,
ValueInt
.
get
(
type
));
row
.
setValue
(
2
,
ValueInt
.
get
(
parent
));
row
.
setValue
(
3
,
ValueInt
.
get
(
headPos
));
row
.
setValue
(
3
,
ValueString
.
get
(
columnList
));
pageIndex
.
add
(
database
.
getSystemSession
(),
row
);
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论