Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
7f81a4a8
提交
7f81a4a8
authored
12月 26, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Don't use the page store when using the MVStore table engine
上级
97c5cb26
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
39 行增加
和
13 行删除
+39
-13
MVTableEngine.java
h2/src/main/org/h2/mvstore/db/MVTableEngine.java
+4
-3
ResultTempTable.java
h2/src/main/org/h2/result/ResultTempTable.java
+35
-10
没有找到文件。
h2/src/main/org/h2/mvstore/db/MVTableEngine.java
浏览文件 @
7f81a4a8
...
@@ -10,6 +10,7 @@ import java.io.InputStream;
...
@@ -10,6 +10,7 @@ import java.io.InputStream;
import
java.lang.Thread.UncaughtExceptionHandler
;
import
java.lang.Thread.UncaughtExceptionHandler
;
import
java.nio.channels.FileChannel
;
import
java.nio.channels.FileChannel
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
org.h2.api.TableEngine
;
import
org.h2.api.TableEngine
;
...
@@ -102,7 +103,7 @@ public class MVTableEngine implements TableEngine {
...
@@ -102,7 +103,7 @@ public class MVTableEngine implements TableEngine {
@Override
@Override
public
TableBase
createTable
(
CreateTableData
data
)
{
public
TableBase
createTable
(
CreateTableData
data
)
{
Database
db
=
data
.
session
.
getDatabase
();
Database
db
=
data
.
session
.
getDatabase
();
if
(!
data
.
persistData
||
(
data
.
temporary
&&
!
data
.
persistIndexes
)
)
{
if
(!
data
.
persistData
)
{
return
new
RegularTable
(
data
);
return
new
RegularTable
(
data
);
}
}
Store
store
=
init
(
db
);
Store
store
=
init
(
db
);
...
@@ -125,7 +126,7 @@ public class MVTableEngine implements TableEngine {
...
@@ -125,7 +126,7 @@ public class MVTableEngine implements TableEngine {
/**
/**
* The list of open tables.
* The list of open tables.
*/
*/
final
ArrayList
<
MVTable
>
openTables
=
New
.
arrayList
(
);
final
List
<
MVTable
>
openTables
=
Collections
.
synchronizedList
(
new
ArrayList
<
MVTable
>()
);
/**
/**
* The store.
* The store.
...
@@ -153,7 +154,7 @@ public class MVTableEngine implements TableEngine {
...
@@ -153,7 +154,7 @@ public class MVTableEngine implements TableEngine {
}
}
public
List
<
MVTable
>
getTables
()
{
public
List
<
MVTable
>
getTables
()
{
return
openTables
;
return
new
ArrayList
<
MVTable
>(
openTables
)
;
}
}
/**
/**
...
...
h2/src/main/org/h2/result/ResultTempTable.java
浏览文件 @
7f81a4a8
...
@@ -19,6 +19,7 @@ import org.h2.schema.Schema;
...
@@ -19,6 +19,7 @@ import org.h2.schema.Schema;
import
org.h2.table.Column
;
import
org.h2.table.Column
;
import
org.h2.table.IndexColumn
;
import
org.h2.table.IndexColumn
;
import
org.h2.table.RegularTable
;
import
org.h2.table.RegularTable
;
import
org.h2.table.Table
;
import
org.h2.value.Value
;
import
org.h2.value.Value
;
import
org.h2.value.ValueArray
;
import
org.h2.value.ValueArray
;
...
@@ -29,10 +30,11 @@ public class ResultTempTable implements ResultExternal {
...
@@ -29,10 +30,11 @@ public class ResultTempTable implements ResultExternal {
private
static
final
String
COLUMN_NAME
=
"DATA"
;
private
static
final
String
COLUMN_NAME
=
"DATA"
;
private
final
SortOrder
sort
;
private
final
SortOrder
sort
;
private
final
Session
session
;
private
final
Index
index
;
private
final
Index
index
;
private
RegularTable
table
;
private
Session
session
;
private
Table
table
;
private
Cursor
resultCursor
;
private
Cursor
resultCursor
;
private
int
rowCount
;
private
final
ResultTempTable
parent
;
private
final
ResultTempTable
parent
;
private
boolean
closed
;
private
boolean
closed
;
...
@@ -53,7 +55,7 @@ public class ResultTempTable implements ResultExternal {
...
@@ -53,7 +55,7 @@ public class ResultTempTable implements ResultExternal {
data
.
persistData
=
true
;
data
.
persistData
=
true
;
data
.
create
=
true
;
data
.
create
=
true
;
data
.
session
=
session
;
data
.
session
=
session
;
table
=
(
RegularTable
)
schema
.
createTable
(
data
);
table
=
schema
.
createTable
(
data
);
int
indexId
=
session
.
getDatabase
().
allocateObjectId
();
int
indexId
=
session
.
getDatabase
().
allocateObjectId
();
IndexColumn
indexColumn
=
new
IndexColumn
();
IndexColumn
indexColumn
=
new
IndexColumn
();
indexColumn
.
column
=
column
;
indexColumn
.
column
=
column
;
...
@@ -61,9 +63,14 @@ public class ResultTempTable implements ResultExternal {
...
@@ -61,9 +63,14 @@ public class ResultTempTable implements ResultExternal {
IndexType
indexType
;
IndexType
indexType
;
indexType
=
IndexType
.
createPrimaryKey
(
true
,
false
);
indexType
=
IndexType
.
createPrimaryKey
(
true
,
false
);
IndexColumn
[]
indexCols
=
{
indexColumn
};
IndexColumn
[]
indexCols
=
{
indexColumn
};
index
=
new
PageBtreeIndex
(
table
,
indexId
,
data
.
tableName
,
indexCols
,
indexType
,
true
,
session
);
if
(
session
.
getDatabase
().
getMvStore
()
!=
null
)
{
index
.
setTemporary
(
true
);
index
=
table
.
addIndex
(
session
,
data
.
tableName
,
indexId
,
indexCols
,
indexType
,
true
,
null
);
table
.
getIndexes
().
add
(
index
);
index
.
setTemporary
(
true
);
}
else
{
index
=
new
PageBtreeIndex
((
RegularTable
)
table
,
indexId
,
data
.
tableName
,
indexCols
,
indexType
,
true
,
session
);
index
.
setTemporary
(
true
);
table
.
getIndexes
().
add
(
index
);
}
parent
=
null
;
parent
=
null
;
}
}
...
@@ -72,6 +79,7 @@ public class ResultTempTable implements ResultExternal {
...
@@ -72,6 +79,7 @@ public class ResultTempTable implements ResultExternal {
this
.
session
=
parent
.
session
;
this
.
session
=
parent
.
session
;
this
.
table
=
parent
.
table
;
this
.
table
=
parent
.
table
;
this
.
index
=
parent
.
index
;
this
.
index
=
parent
.
index
;
this
.
rowCount
=
parent
.
rowCount
;
// sort is only used when adding rows
// sort is only used when adding rows
this
.
sort
=
null
;
this
.
sort
=
null
;
reset
();
reset
();
...
@@ -96,8 +104,9 @@ public class ResultTempTable implements ResultExternal {
...
@@ -96,8 +104,9 @@ public class ResultTempTable implements ResultExternal {
if
(
cursor
!=
null
)
{
if
(
cursor
!=
null
)
{
row
=
cursor
.
get
();
row
=
cursor
.
get
();
table
.
removeRow
(
session
,
row
);
table
.
removeRow
(
session
,
row
);
rowCount
--;
}
}
return
(
int
)
table
.
getRowCount
(
session
)
;
return
rowCount
;
}
}
@Override
@Override
...
@@ -111,8 +120,9 @@ public class ResultTempTable implements ResultExternal {
...
@@ -111,8 +120,9 @@ public class ResultTempTable implements ResultExternal {
Cursor
cursor
=
find
(
row
);
Cursor
cursor
=
find
(
row
);
if
(
cursor
==
null
)
{
if
(
cursor
==
null
)
{
table
.
addRow
(
session
,
row
);
table
.
addRow
(
session
,
row
);
rowCount
++;
}
}
return
(
int
)
table
.
getRowCount
(
session
)
;
return
rowCount
;
}
}
@Override
@Override
...
@@ -123,7 +133,7 @@ public class ResultTempTable implements ResultExternal {
...
@@ -123,7 +133,7 @@ public class ResultTempTable implements ResultExternal {
for
(
Value
[]
values
:
rows
)
{
for
(
Value
[]
values
:
rows
)
{
addRow
(
values
);
addRow
(
values
);
}
}
return
(
int
)
table
.
getRowCount
(
session
)
;
return
rowCount
;
}
}
private
synchronized
void
closeChild
()
{
private
synchronized
void
closeChild
()
{
...
@@ -186,6 +196,21 @@ public class ResultTempTable implements ResultExternal {
...
@@ -186,6 +196,21 @@ public class ResultTempTable implements ResultExternal {
@Override
@Override
public
Value
[]
next
()
{
public
Value
[]
next
()
{
if
(
resultCursor
==
null
)
{
if
(
session
.
getDatabase
().
getMvStore
()
!=
null
)
{
// sometimes the transaction is already committed,
// in which case we can't use the session
if
(
index
.
getRowCount
(
session
)
==
0
&&
rowCount
>
0
)
{
// this means querying is not transactional
resultCursor
=
index
.
find
((
Session
)
null
,
null
,
null
);
}
else
{
// the transaction is still open
resultCursor
=
index
.
find
(
session
,
null
,
null
);
}
}
else
{
resultCursor
=
index
.
find
(
session
,
null
,
null
);
}
}
if
(!
resultCursor
.
next
())
{
if
(!
resultCursor
.
next
())
{
return
null
;
return
null
;
}
}
...
@@ -196,7 +221,7 @@ public class ResultTempTable implements ResultExternal {
...
@@ -196,7 +221,7 @@ public class ResultTempTable implements ResultExternal {
@Override
@Override
public
void
reset
()
{
public
void
reset
()
{
resultCursor
=
index
.
find
(
session
,
null
,
null
)
;
resultCursor
=
null
;
}
}
private
static
Row
convertToRow
(
Value
[]
values
)
{
private
static
Row
convertToRow
(
Value
[]
values
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论