Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
9e6867b0
提交
9e6867b0
authored
10月 30, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
The spatial index now works in MVCC mode when using the MVStore storage.
上级
b5ede1e6
全部展开
显示空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
436 行增加
和
28 行删除
+436
-28
changelog.html
h2/src/docsrc/html/changelog.html
+1
-0
SpatialTreeIndex.java
h2/src/main/org/h2/index/SpatialTreeIndex.java
+0
-1
MVPrimaryIndex.java
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
+1
-2
MVSecondaryIndex.java
h2/src/main/org/h2/mvstore/db/MVSecondaryIndex.java
+1
-2
MVSpatialIndex.java
h2/src/main/org/h2/mvstore/db/MVSpatialIndex.java
+383
-0
MVTable.java
h2/src/main/org/h2/mvstore/db/MVTable.java
+3
-4
MVTableEngine.java
h2/src/main/org/h2/mvstore/db/MVTableEngine.java
+3
-3
TransactionStore.java
h2/src/main/org/h2/mvstore/db/TransactionStore.java
+6
-7
ValueDataType.java
h2/src/main/org/h2/mvstore/db/ValueDataType.java
+20
-6
MVRTreeMap.java
h2/src/main/org/h2/mvstore/rtree/MVRTreeMap.java
+1
-1
SpatialKey.java
h2/src/main/org/h2/mvstore/rtree/SpatialKey.java
+16
-1
TestSpatial.java
h2/src/test/org/h2/test/db/TestSpatial.java
+1
-1
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
9e6867b0
...
@@ -21,6 +21,7 @@ Change Log
...
@@ -21,6 +21,7 @@ Change Log
<ul><li>
Subqueries or views with "order by" an alias expression could not be executed
<ul><li>
Subqueries or views with "order by" an alias expression could not be executed
due to a regression introduced in version 1.3.174.
due to a regression introduced in version 1.3.174.
</li><li>
Issue 73: MySQL compatibility: support REPLACE, patch by Cemo Koc.
</li><li>
Issue 73: MySQL compatibility: support REPLACE, patch by Cemo Koc.
</li><li>
The spatial index now works in MVCC mode when using the MVStore storage.
</li><li>
MVStore: concurrency problems have been fixed.
</li><li>
MVStore: concurrency problems have been fixed.
</li><li>
Improve error message when dropping an index that belongs to a constraint,
</li><li>
Improve error message when dropping an index that belongs to a constraint,
specify constraint in error message.
specify constraint in error message.
...
...
h2/src/main/org/h2/index/SpatialTreeIndex.java
浏览文件 @
9e6867b0
...
@@ -194,7 +194,6 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
...
@@ -194,7 +194,6 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
@Override
@Override
public
void
remove
(
Session
session
)
{
public
void
remove
(
Session
session
)
{
if
(!
treeMap
.
isClosed
())
{
if
(!
treeMap
.
isClosed
())
{
MVStore
store
=
session
.
getDatabase
().
getMvStore
().
getStore
();
store
.
removeMap
(
treeMap
);
store
.
removeMap
(
treeMap
);
}
}
}
}
...
...
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
浏览文件 @
9e6867b0
...
@@ -379,8 +379,7 @@ public class MVPrimaryIndex extends BaseIndex {
...
@@ -379,8 +379,7 @@ public class MVPrimaryIndex extends BaseIndex {
@Override
@Override
public
boolean
previous
()
{
public
boolean
previous
()
{
// TODO previous
throw
DbException
.
getUnsupportedException
(
"previous"
);
return
false
;
}
}
}
}
...
...
h2/src/main/org/h2/mvstore/db/MVSecondaryIndex.java
浏览文件 @
9e6867b0
...
@@ -342,8 +342,7 @@ public class MVSecondaryIndex extends BaseIndex {
...
@@ -342,8 +342,7 @@ public class MVSecondaryIndex extends BaseIndex {
@Override
@Override
public
boolean
previous
()
{
public
boolean
previous
()
{
// TODO previous
throw
DbException
.
getUnsupportedException
(
"previous"
);
return
false
;
}
}
}
}
...
...
h2/src/main/org/h2/mvstore/db/MVSpatialIndex.java
0 → 100644
浏览文件 @
9e6867b0
差异被折叠。
点击展开。
h2/src/main/org/h2/mvstore/db/MVTable.java
浏览文件 @
9e6867b0
...
@@ -26,7 +26,6 @@ import org.h2.index.Cursor;
...
@@ -26,7 +26,6 @@ import org.h2.index.Cursor;
import
org.h2.index.Index
;
import
org.h2.index.Index
;
import
org.h2.index.IndexType
;
import
org.h2.index.IndexType
;
import
org.h2.index.MultiVersionIndex
;
import
org.h2.index.MultiVersionIndex
;
import
org.h2.index.SpatialTreeIndex
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.message.Trace
;
import
org.h2.message.Trace
;
import
org.h2.mvstore.db.TransactionStore.Transaction
;
import
org.h2.mvstore.db.TransactionStore.Transaction
;
...
@@ -399,9 +398,9 @@ public class MVTable extends TableBase {
...
@@ -399,9 +398,9 @@ public class MVTable extends TableBase {
index
=
new
MVDelegateIndex
(
this
,
indexId
,
index
=
new
MVDelegateIndex
(
this
,
indexId
,
indexName
,
primaryIndex
,
indexType
);
indexName
,
primaryIndex
,
indexType
);
}
else
if
(
indexType
.
isSpatial
())
{
}
else
if
(
indexType
.
isSpatial
())
{
in
t
todo
;
in
dex
=
new
MVSpatialIndex
(
session
.
getDatabase
(),
index
=
new
SpatialTreeIndex
(
this
,
indexId
,
indexName
,
cols
,
this
,
indexId
,
index
Type
,
true
,
create
,
session
);
index
Name
,
cols
,
indexType
);
}
else
{
}
else
{
index
=
new
MVSecondaryIndex
(
session
.
getDatabase
(),
index
=
new
MVSecondaryIndex
(
session
.
getDatabase
(),
this
,
indexId
,
this
,
indexId
,
...
...
h2/src/main/org/h2/mvstore/db/MVTableEngine.java
浏览文件 @
9e6867b0
...
@@ -173,10 +173,10 @@ public class MVTableEngine implements TableEngine {
...
@@ -173,10 +173,10 @@ public class MVTableEngine implements TableEngine {
if
(
s
==
null
||
s
.
isReadOnly
())
{
if
(
s
==
null
||
s
.
isReadOnly
())
{
return
;
return
;
}
}
store
.
commit
();
if
(!
store
.
compact
(
50
))
{
store
.
compact
(
50
);
store
.
store
();
store
.
store
();
}
}
}
/**
/**
* Close the store, without persisting changes.
* Close the store, without persisting changes.
...
...
h2/src/main/org/h2/mvstore/db/TransactionStore.java
浏览文件 @
9e6867b0
...
@@ -170,7 +170,7 @@ public class TransactionStore {
...
@@ -170,7 +170,7 @@ public class TransactionStore {
public
synchronized
void
close
()
{
public
synchronized
void
close
()
{
// to avoid losing transaction ids
// to avoid losing transaction ids
settings
.
put
(
LAST_TRANSACTION_ID
,
""
+
lastTransactionId
);
settings
.
put
(
LAST_TRANSACTION_ID
,
""
+
lastTransactionId
);
store
.
commit
();
store
.
store
();
}
}
/**
/**
...
@@ -658,9 +658,8 @@ public class TransactionStore {
...
@@ -658,9 +658,8 @@ public class TransactionStore {
return
new
TransactionMap
<
K
,
V
>(
this
,
map
,
mapId
);
return
new
TransactionMap
<
K
,
V
>(
this
,
map
,
mapId
);
}
}
public
<
K
,
V
>
TransactionMap
<
K
,
V
>
openMap
(
String
name
,
MVMap
.
Builder
<
K
,
VersionedValue
>
builder
)
{
public
<
K
,
V
>
TransactionMap
<
K
,
V
>
openMap
(
MVMap
<
K
,
VersionedValue
>
map
)
{
checkNotClosed
();
checkNotClosed
();
MVMap
<
K
,
VersionedValue
>
map
=
store
.
store
.
openMap
(
name
,
builder
);
int
mapId
=
map
.
getId
();
int
mapId
=
map
.
getId
();
return
new
TransactionMap
<
K
,
V
>(
this
,
map
,
mapId
);
return
new
TransactionMap
<
K
,
V
>(
this
,
map
,
mapId
);
}
}
...
@@ -1214,11 +1213,11 @@ public class TransactionStore {
...
@@ -1214,11 +1213,11 @@ public class TransactionStore {
/**
/**
* Iterate over keys.
* Iterate over keys.
*
*
* @param
cursor the wrapped cursor
* @param
iterator the iterator to wrap
* @param includeUncommitted whether uncommitted entries should be included
* @param includeUncommitted whether uncommitted entries should be included
* @return the iterator
* @return the iterator
*/
*/
p
rivate
Iterator
<
K
>
wrapIterator
(
final
Cursor
<
K
>
curs
or
,
final
boolean
includeUncommitted
)
{
p
ublic
Iterator
<
K
>
wrapIterator
(
final
Iterator
<
K
>
iterat
or
,
final
boolean
includeUncommitted
)
{
return
new
Iterator
<
K
>()
{
return
new
Iterator
<
K
>()
{
private
K
current
;
private
K
current
;
...
@@ -1227,8 +1226,8 @@ public class TransactionStore {
...
@@ -1227,8 +1226,8 @@ public class TransactionStore {
}
}
private
void
fetchNext
()
{
private
void
fetchNext
()
{
while
(
curs
or
.
hasNext
())
{
while
(
iterat
or
.
hasNext
())
{
current
=
curs
or
.
next
();
current
=
iterat
or
.
next
();
if
(
includeUncommitted
)
{
if
(
includeUncommitted
)
{
return
;
return
;
}
}
...
...
h2/src/main/org/h2/mvstore/db/ValueDataType.java
浏览文件 @
9e6867b0
...
@@ -17,6 +17,8 @@ import org.h2.constant.ErrorCode;
...
@@ -17,6 +17,8 @@ import org.h2.constant.ErrorCode;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.mvstore.DataUtils
;
import
org.h2.mvstore.DataUtils
;
import
org.h2.mvstore.WriteBuffer
;
import
org.h2.mvstore.WriteBuffer
;
import
org.h2.mvstore.rtree.SpatialDataType
;
import
org.h2.mvstore.rtree.SpatialKey
;
import
org.h2.mvstore.type.DataType
;
import
org.h2.mvstore.type.DataType
;
import
org.h2.result.SortOrder
;
import
org.h2.result.SortOrder
;
import
org.h2.store.DataHandler
;
import
org.h2.store.DataHandler
;
...
@@ -68,10 +70,12 @@ public class ValueDataType implements DataType {
...
@@ -68,10 +70,12 @@ public class ValueDataType implements DataType {
private
static
final
int
LONG_NEG
=
67
;
private
static
final
int
LONG_NEG
=
67
;
private
static
final
int
STRING_0_31
=
68
;
private
static
final
int
STRING_0_31
=
68
;
private
static
final
int
BYTES_0_31
=
100
;
private
static
final
int
BYTES_0_31
=
100
;
private
static
final
int
SPATIAL_KEY_2D
=
132
;
final
DataHandler
handler
;
final
DataHandler
handler
;
final
CompareMode
compareMode
;
final
CompareMode
compareMode
;
final
int
[]
sortTypes
;
final
int
[]
sortTypes
;
final
SpatialDataType
spatialType
=
new
SpatialDataType
(
2
);
public
ValueDataType
(
CompareMode
compareMode
,
DataHandler
handler
,
int
[]
sortTypes
)
{
public
ValueDataType
(
CompareMode
compareMode
,
DataHandler
handler
,
int
[]
sortTypes
)
{
this
.
compareMode
=
compareMode
;
this
.
compareMode
=
compareMode
;
...
@@ -134,6 +138,9 @@ public class ValueDataType implements DataType {
...
@@ -134,6 +138,9 @@ public class ValueDataType implements DataType {
@Override
@Override
public
int
getMemory
(
Object
obj
)
{
public
int
getMemory
(
Object
obj
)
{
if
(
obj
instanceof
SpatialKey
)
{
return
spatialType
.
getMemory
(
obj
);
}
return
getMemory
((
Value
)
obj
);
return
getMemory
((
Value
)
obj
);
}
}
...
@@ -142,12 +149,17 @@ public class ValueDataType implements DataType {
...
@@ -142,12 +149,17 @@ public class ValueDataType implements DataType {
}
}
@Override
@Override
public
Value
read
(
ByteBuffer
buff
)
{
public
Object
read
(
ByteBuffer
buff
)
{
return
readValue
(
buff
);
return
readValue
(
buff
);
}
}
@Override
@Override
public
void
write
(
WriteBuffer
buff
,
Object
obj
)
{
public
void
write
(
WriteBuffer
buff
,
Object
obj
)
{
if
(
obj
instanceof
SpatialKey
)
{
buff
.
put
((
byte
)
SPATIAL_KEY_2D
);
spatialType
.
write
(
buff
,
obj
);
return
;
}
Value
x
=
(
Value
)
obj
;
Value
x
=
(
Value
)
obj
;
writeValue
(
buff
,
x
);
writeValue
(
buff
,
x
);
}
}
...
@@ -418,7 +430,7 @@ public class ValueDataType implements DataType {
...
@@ -418,7 +430,7 @@ public class ValueDataType implements DataType {
*
*
* @return the value
* @return the value
*/
*/
private
Value
readValue
(
ByteBuffer
buff
)
{
private
Object
readValue
(
ByteBuffer
buff
)
{
int
type
=
buff
.
get
()
&
255
;
int
type
=
buff
.
get
()
&
255
;
switch
(
type
)
{
switch
(
type
)
{
case
Value
.
NULL
:
case
Value
.
NULL
:
...
@@ -440,9 +452,9 @@ public class ValueDataType implements DataType {
...
@@ -440,9 +452,9 @@ public class ValueDataType implements DataType {
case
Value
.
SHORT
:
case
Value
.
SHORT
:
return
ValueShort
.
get
(
buff
.
getShort
());
return
ValueShort
.
get
(
buff
.
getShort
());
case
DECIMAL_0_1:
case
DECIMAL_0_1:
return
(
ValueDecimal
)
ValueDecimal
.
ZERO
;
return
ValueDecimal
.
ZERO
;
case
DECIMAL_0_1
+
1
:
case
DECIMAL_0_1
+
1
:
return
(
ValueDecimal
)
ValueDecimal
.
ONE
;
return
ValueDecimal
.
ONE
;
case
DECIMAL_SMALL_0:
case
DECIMAL_SMALL_0:
return
ValueDecimal
.
get
(
BigDecimal
.
valueOf
(
readVarLong
(
buff
)));
return
ValueDecimal
.
get
(
BigDecimal
.
valueOf
(
readVarLong
(
buff
)));
case
DECIMAL_SMALL:
{
case
DECIMAL_SMALL:
{
...
@@ -537,7 +549,7 @@ public class ValueDataType implements DataType {
...
@@ -537,7 +549,7 @@ public class ValueDataType implements DataType {
int
len
=
readVarInt
(
buff
);
int
len
=
readVarInt
(
buff
);
Value
[]
list
=
new
Value
[
len
];
Value
[]
list
=
new
Value
[
len
];
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
list
[
i
]
=
readValue
(
buff
);
list
[
i
]
=
(
Value
)
readValue
(
buff
);
}
}
return
ValueArray
.
get
(
list
);
return
ValueArray
.
get
(
list
);
}
}
...
@@ -553,7 +565,7 @@ public class ValueDataType implements DataType {
...
@@ -553,7 +565,7 @@ public class ValueDataType implements DataType {
}
}
Object
[]
o
=
new
Object
[
columns
];
Object
[]
o
=
new
Object
[
columns
];
for
(
int
i
=
0
;
i
<
columns
;
i
++)
{
for
(
int
i
=
0
;
i
<
columns
;
i
++)
{
o
[
i
]
=
readValue
(
buff
).
getObject
();
o
[
i
]
=
((
Value
)
readValue
(
buff
)
).
getObject
();
}
}
rs
.
addRow
(
o
);
rs
.
addRow
(
o
);
}
}
...
@@ -565,6 +577,8 @@ public class ValueDataType implements DataType {
...
@@ -565,6 +577,8 @@ public class ValueDataType implements DataType {
buff
.
get
(
b
,
0
,
len
);
buff
.
get
(
b
,
0
,
len
);
return
ValueGeometry
.
get
(
b
);
return
ValueGeometry
.
get
(
b
);
}
}
case
SPATIAL_KEY_2D:
return
spatialType
.
read
(
buff
);
default
:
default
:
if
(
type
>=
INT_0_15
&&
type
<
INT_0_15
+
16
)
{
if
(
type
>=
INT_0_15
&&
type
<
INT_0_15
+
16
)
{
return
ValueInt
.
get
(
type
-
INT_0_15
);
return
ValueInt
.
get
(
type
-
INT_0_15
);
...
...
h2/src/main/org/h2/mvstore/rtree/MVRTreeMap.java
浏览文件 @
9e6867b0
...
@@ -478,7 +478,7 @@ public class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
...
@@ -478,7 +478,7 @@ public class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
/**
/**
* A cursor to iterate over a subset of the keys.
* A cursor to iterate over a subset of the keys.
*/
*/
static
class
RTreeCursor
implements
Iterator
<
SpatialKey
>
{
public
static
class
RTreeCursor
implements
Iterator
<
SpatialKey
>
{
private
final
SpatialKey
filter
;
private
final
SpatialKey
filter
;
private
CursorPos
pos
;
private
CursorPos
pos
;
...
...
h2/src/main/org/h2/mvstore/rtree/SpatialKey.java
浏览文件 @
9e6867b0
...
@@ -91,10 +91,25 @@ public class SpatialKey {
...
@@ -91,10 +91,25 @@ public class SpatialKey {
@Override
@Override
public
boolean
equals
(
Object
other
)
{
public
boolean
equals
(
Object
other
)
{
if
(!(
other
instanceof
SpatialKey
))
{
if
(
other
==
this
)
{
return
true
;
}
else
if
(!(
other
instanceof
SpatialKey
))
{
return
false
;
return
false
;
}
}
SpatialKey
o
=
(
SpatialKey
)
other
;
SpatialKey
o
=
(
SpatialKey
)
other
;
if
(
id
!=
o
.
id
)
{
return
false
;
}
return
equalsIgnoringId
(
o
);
}
/**
* Check whether two objects are equals, but do not compare the id fields.
*
* @param o the other key
* @return true if the contents are the same
*/
public
boolean
equalsIgnoringId
(
SpatialKey
o
)
{
return
Arrays
.
equals
(
minMax
,
o
.
minMax
);
return
Arrays
.
equals
(
minMax
,
o
.
minMax
);
}
}
...
...
h2/src/test/org/h2/test/db/TestSpatial.java
浏览文件 @
9e6867b0
...
@@ -45,7 +45,7 @@ public class TestSpatial extends TestBase {
...
@@ -45,7 +45,7 @@ public class TestSpatial extends TestBase {
@Override
@Override
public
void
test
()
throws
SQLException
{
public
void
test
()
throws
SQLException
{
if
(
config
.
mvcc
)
{
if
(
!
config
.
mvStore
&&
config
.
mvcc
)
{
return
;
return
;
}
}
if
(
DataType
.
GEOMETRY_CLASS
!=
null
)
{
if
(
DataType
.
GEOMETRY_CLASS
!=
null
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论