Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
47559bd1
提交
47559bd1
authored
9月 19, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MVTableEngine improvements
上级
d893c6bd
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
43 行增加
和
28 行删除
+43
-28
Session.java
h2/src/main/org/h2/engine/Session.java
+3
-0
SpatialTreeIndex.java
h2/src/main/org/h2/index/SpatialTreeIndex.java
+10
-11
MVTable.java
h2/src/main/org/h2/mvstore/db/MVTable.java
+5
-7
MVTableEngine.java
h2/src/main/org/h2/mvstore/db/MVTableEngine.java
+1
-1
RegularTable.java
h2/src/main/org/h2/table/RegularTable.java
+1
-7
Table.java
h2/src/main/org/h2/table/Table.java
+11
-0
TestBase.java
h2/src/test/org/h2/test/TestBase.java
+12
-2
没有找到文件。
h2/src/main/org/h2/engine/Session.java
浏览文件 @
47559bd1
...
...
@@ -856,6 +856,9 @@ public class Session extends SessionWithState {
* @return true if yes
*/
public
boolean
containsUncommitted
()
{
if
(
database
.
getMvStore
()
!=
null
)
{
return
transaction
!=
null
;
}
return
firstUncommittedLog
!=
Session
.
LOG_WRITTEN
;
}
...
...
h2/src/main/org/h2/index/SpatialTreeIndex.java
浏览文件 @
47559bd1
...
...
@@ -19,7 +19,7 @@ import org.h2.result.SearchRow;
import
org.h2.result.SortOrder
;
import
org.h2.table.Column
;
import
org.h2.table.IndexColumn
;
import
org.h2.table.
Regular
Table
;
import
org.h2.table.Table
;
import
org.h2.table.TableFilter
;
import
org.h2.value.Value
;
import
org.h2.value.ValueGeometry
;
...
...
@@ -41,7 +41,6 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
private
final
MVRTreeMap
<
Long
>
treeMap
;
private
final
MVStore
store
;
private
final
RegularTable
tableData
;
private
boolean
closed
;
private
boolean
needRebuild
;
private
boolean
persistent
;
...
...
@@ -58,7 +57,7 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
* @param create whether to create a new index
* @param session the session.
*/
public
SpatialTreeIndex
(
Regular
Table
table
,
int
id
,
String
indexName
,
public
SpatialTreeIndex
(
Table
table
,
int
id
,
String
indexName
,
IndexColumn
[]
columns
,
IndexType
indexType
,
boolean
persistent
,
boolean
create
,
Session
session
)
{
if
(
indexType
.
isUnique
())
{
...
...
@@ -82,7 +81,7 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
initBaseIndex
(
table
,
id
,
indexName
,
columns
,
indexType
);
this
.
needRebuild
=
create
;
this
.
persistent
=
persistent
;
t
ableData
=
table
;
t
his
.
table
=
table
;
if
(!
database
.
isStarting
())
{
if
(
columns
[
0
].
column
.
getType
()
!=
Value
.
GEOMETRY
)
{
throw
DbException
.
getUnsupportedException
(
"spatial index on non-geometry column, "
...
...
@@ -158,7 +157,7 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
}
private
Cursor
find
(
Session
session
)
{
return
new
SpatialCursor
(
treeMap
.
keySet
().
iterator
(),
table
Data
,
session
);
return
new
SpatialCursor
(
treeMap
.
keySet
().
iterator
(),
table
,
session
);
}
@Override
...
...
@@ -166,7 +165,7 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
if
(
intersection
==
null
)
{
return
find
(
filter
.
getSession
());
}
return
new
SpatialCursor
(
treeMap
.
findIntersectingKeys
(
getEnvelope
(
intersection
)),
table
Data
,
filter
.
getSession
());
return
new
SpatialCursor
(
treeMap
.
findIntersectingKeys
(
getEnvelope
(
intersection
)),
table
,
filter
.
getSession
());
}
@Override
...
...
@@ -189,7 +188,7 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
@Override
public
double
getCost
(
Session
session
,
int
[]
masks
,
TableFilter
filter
,
SortOrder
sortOrder
)
{
return
getCostRangeIndex
(
masks
,
table
Data
.
getRowCountApproximation
(),
filter
,
sortOrder
);
return
getCostRangeIndex
(
masks
,
table
.
getRowCountApproximation
(),
filter
,
sortOrder
);
}
@Override
...
...
@@ -253,18 +252,18 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
private
final
Iterator
<
SpatialKey
>
it
;
private
SpatialKey
current
;
private
final
RegularTable
tableData
;
private
final
Table
table
;
private
Session
session
;
public
SpatialCursor
(
Iterator
<
SpatialKey
>
it
,
RegularTable
tableData
,
Session
session
)
{
public
SpatialCursor
(
Iterator
<
SpatialKey
>
it
,
Table
table
,
Session
session
)
{
this
.
it
=
it
;
this
.
table
Data
=
tableData
;
this
.
table
=
table
;
this
.
session
=
session
;
}
@Override
public
Row
get
()
{
return
table
Data
.
getRow
(
session
,
current
.
getId
());
return
table
.
getRow
(
session
,
current
.
getId
());
}
@Override
...
...
h2/src/main/org/h2/mvstore/db/MVTable.java
浏览文件 @
47559bd1
...
...
@@ -26,6 +26,7 @@ import org.h2.index.Cursor;
import
org.h2.index.Index
;
import
org.h2.index.IndexType
;
import
org.h2.index.MultiVersionIndex
;
import
org.h2.index.SpatialTreeIndex
;
import
org.h2.message.DbException
;
import
org.h2.message.Trace
;
import
org.h2.mvstore.db.TransactionStore.Transaction
;
...
...
@@ -354,13 +355,7 @@ public class MVTable extends TableBase {
// ignore
}
/**
* Get the given row.
*
* @param session the session
* @param key the primary key
* @return the row
*/
@Override
public
Row
getRow
(
Session
session
,
long
key
)
{
return
primaryIndex
.
getRow
(
session
,
key
);
}
...
...
@@ -401,6 +396,9 @@ public class MVTable extends TableBase {
primaryIndex
.
setMainIndexColumn
(
mainIndexColumn
);
index
=
new
MVDelegateIndex
(
this
,
indexId
,
indexName
,
primaryIndex
,
indexType
);
}
else
if
(
indexType
.
isSpatial
())
{
index
=
new
SpatialTreeIndex
(
this
,
indexId
,
indexName
,
cols
,
indexType
,
true
,
create
,
session
);
}
else
{
index
=
new
MVSecondaryIndex
(
session
.
getDatabase
(),
this
,
indexId
,
...
...
h2/src/main/org/h2/mvstore/db/MVTableEngine.java
浏览文件 @
47559bd1
...
...
@@ -269,7 +269,7 @@ public class MVTableEngine implements TableEngine {
* @param maxCompactTime the maximum time in milliseconds to compact
*/
public
void
close
(
long
maxCompactTime
)
{
if
(!
store
.
isClosed
())
{
if
(!
store
.
isClosed
()
&&
store
.
getFileStore
()
!=
null
)
{
if
(!
store
.
getFileStore
().
isReadOnly
())
{
store
.
store
();
long
start
=
System
.
currentTimeMillis
();
...
...
h2/src/main/org/h2/table/RegularTable.java
浏览文件 @
47559bd1
...
...
@@ -101,13 +101,7 @@ public class RegularTable extends TableBase {
}
}
/**
* Read the given row.
*
* @param session the session
* @param key unique key
* @return the row
*/
@Override
public
Row
getRow
(
Session
session
,
long
key
)
{
return
scanIndex
.
getRow
(
session
,
key
);
}
...
...
h2/src/main/org/h2/table/Table.java
浏览文件 @
47559bd1
...
...
@@ -165,6 +165,17 @@ public abstract class Table extends SchemaObjectBase {
*/
public
abstract
Index
addIndex
(
Session
session
,
String
indexName
,
int
indexId
,
IndexColumn
[]
cols
,
IndexType
indexType
,
boolean
create
,
String
indexComment
);
/**
* Get the given row.
*
* @param session the session
* @param key the primary key
* @return the row
*/
public
Row
getRow
(
Session
session
,
long
key
)
{
return
null
;
}
/**
* Remove a row from the table and all indexes.
...
...
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
47559bd1
...
...
@@ -1247,10 +1247,12 @@ public abstract class TestBase {
ArrayList
<
String
>
list2
=
new
ArrayList
<
String
>();
while
(
rs1
.
next
())
{
String
s1
=
rs1
.
getString
(
1
);
s1
=
removeRowCount
(
s1
);
if
(!
rs2
.
next
())
{
fail
(
"expected: "
+
s1
);
}
String
s2
=
rs2
.
getString
(
1
);
s2
=
removeRowCount
(
s2
);
if
(!
s1
.
equals
(
s2
))
{
list1
.
add
(
s1
);
list2
.
add
(
s2
);
...
...
@@ -1258,12 +1260,20 @@ public abstract class TestBase {
}
for
(
String
s
:
list1
)
{
if
(!
list2
.
remove
(
s
))
{
fail
(
"only found in first: "
+
s
);
fail
(
"only found in first: "
+
s
+
" remaining: "
+
list2
);
}
}
assertEquals
(
0
,
list2
.
size
());
assertEquals
(
"remaining: "
+
list2
,
0
,
list2
.
size
());
assertFalse
(
rs2
.
next
());
}
private
static
String
removeRowCount
(
String
scriptLine
)
{
int
index
=
scriptLine
.
indexOf
(
"+/-"
);
if
(
index
>=
0
)
{
scriptLine
=
scriptLine
.
substring
(
index
);
}
return
scriptLine
;
}
/**
* Create a new object of the calling class.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论