Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
747b2489
提交
747b2489
authored
8月 24, 2012
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
A persistent multi-version map (work in progress): r-tree
上级
ccaa8179
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
24 行增加
和
11 行删除
+24
-11
RtreeMap.java
h2/src/test/org/h2/test/store/RtreeMap.java
+2
-5
TestBtreeMapStore.java
h2/src/test/org/h2/test/store/TestBtreeMapStore.java
+19
-3
BtreeMapStore.java
h2/src/tools/org/h2/dev/store/btree/BtreeMapStore.java
+3
-3
没有找到文件。
h2/src/test/org/h2/test/store/RtreeMap.java
浏览文件 @
747b2489
...
@@ -14,7 +14,7 @@ import org.h2.dev.store.btree.DataType;
...
@@ -14,7 +14,7 @@ import org.h2.dev.store.btree.DataType;
import
org.h2.dev.store.btree.Page
;
import
org.h2.dev.store.btree.Page
;
/**
/**
* An r-tree implementation.
* An r-tree implementation.
It uses the quadratic split algorithm.
*
*
* @param <K> the key class
* @param <K> the key class
* @param <V> the value class
* @param <V> the value class
...
@@ -38,10 +38,6 @@ public class RtreeMap<K, V> extends BtreeMap<K, V> {
...
@@ -38,10 +38,6 @@ public class RtreeMap<K, V> extends BtreeMap<K, V> {
return
(
V
)
getSpatial
(
root
,
key
);
return
(
V
)
getSpatial
(
root
,
key
);
}
}
private
boolean
overlap
(
Page
p
,
int
index
,
Object
key
)
{
return
keyType
.
isOverlap
(
p
.
getKey
(
index
),
key
);
}
private
boolean
contains
(
Page
p
,
int
index
,
Object
key
)
{
private
boolean
contains
(
Page
p
,
int
index
,
Object
key
)
{
return
keyType
.
contains
(
p
.
getKey
(
index
),
key
);
return
keyType
.
contains
(
p
.
getKey
(
index
),
key
);
}
}
...
@@ -205,6 +201,7 @@ public class RtreeMap<K, V> extends BtreeMap<K, V> {
...
@@ -205,6 +201,7 @@ public class RtreeMap<K, V> extends BtreeMap<K, V> {
throw
KEY_ALREADY_EXISTS
;
throw
KEY_ALREADY_EXISTS
;
}
}
}
}
p
=
p
.
copyOnWrite
(
writeVersion
);
p
.
insert
(
p
.
getKeyCount
(),
key
,
value
,
0
,
0
);
p
.
insert
(
p
.
getKeyCount
(),
key
,
value
,
0
,
0
);
return
p
;
return
p
;
}
}
...
...
h2/src/test/org/h2/test/store/TestBtreeMapStore.java
浏览文件 @
747b2489
...
@@ -65,19 +65,33 @@ public class TestBtreeMapStore extends TestBase {
...
@@ -65,19 +65,33 @@ public class TestBtreeMapStore extends TestBase {
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
BtreeMapStore
s
;
BtreeMapStore
s
;
s
=
openStore
(
fileName
);
s
=
openStore
(
fileName
);
// s.setMaxPageSize(
10
0);
// s.setMaxPageSize(
5
0);
RtreeMap
<
SpatialKey
,
String
>
r
=
s
.
openMap
(
"data"
,
"r"
,
"s2"
,
""
);
RtreeMap
<
SpatialKey
,
String
>
r
=
s
.
openMap
(
"data"
,
"r"
,
"s2"
,
""
);
Random
rand
=
new
Random
(
1
);
Random
rand
=
new
Random
(
1
);
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
int
len
=
1000
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
float
x
=
rand
.
nextFloat
(),
y
=
rand
.
nextFloat
();
float
x
=
rand
.
nextFloat
(),
y
=
rand
.
nextFloat
();
float
p
=
(
float
)
(
rand
.
nextFloat
()
*
0.01
);
float
p
=
(
float
)
(
rand
.
nextFloat
()
*
0.01
);
SpatialKey
k
=
SpatialKey
.
create
(
i
,
x
-
p
,
x
+
p
,
y
-
p
,
y
+
p
);
SpatialKey
k
=
SpatialKey
.
create
(
i
,
x
-
p
,
x
+
p
,
y
-
p
,
y
+
p
);
r
.
put
(
k
,
""
+
i
);
r
.
put
(
k
,
""
+
i
);
if
(
i
>
0
&&
i
%
10000
==
0
)
{
if
(
i
>
0
&&
(
i
%
100
)
==
0
)
{
s
.
store
();
}
if
(
i
>
0
&&
(
i
%
10000
)
==
0
)
{
render
(
r
,
getBaseDir
()
+
"/test.png"
);
render
(
r
,
getBaseDir
()
+
"/test.png"
);
}
}
}
}
s
.
store
();
s
.
close
();
s
.
close
();
s
=
openStore
(
fileName
);
r
=
s
.
openMap
(
"data"
,
"r"
,
"s2"
,
""
);
rand
=
new
Random
(
1
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
float
x
=
rand
.
nextFloat
(),
y
=
rand
.
nextFloat
();
float
p
=
(
float
)
(
rand
.
nextFloat
()
*
0.01
);
SpatialKey
k
=
SpatialKey
.
create
(
i
,
x
-
p
,
x
+
p
,
y
-
p
,
y
+
p
);
assertEquals
(
""
+
i
,
r
.
get
(
k
));
}
}
}
private
void
testRtree
()
{
private
void
testRtree
()
{
...
@@ -422,6 +436,8 @@ public class TestBtreeMapStore extends TestBase {
...
@@ -422,6 +436,8 @@ public class TestBtreeMapStore extends TestBase {
String
fileName
=
getBaseDir
()
+
"/testBtreeStore.h3"
;
String
fileName
=
getBaseDir
()
+
"/testBtreeStore.h3"
;
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
BtreeMapStore
s
=
openStore
(
fileName
);
BtreeMapStore
s
=
openStore
(
fileName
);
s
.
close
();
s
=
openStore
(
fileName
);
BtreeMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
BtreeMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
int
count
=
2000
;
int
count
=
2000
;
// Profiler p = new Profiler();
// Profiler p = new Profiler();
...
...
h2/src/tools/org/h2/dev/store/btree/BtreeMapStore.java
浏览文件 @
747b2489
...
@@ -41,12 +41,10 @@ TODO:
...
@@ -41,12 +41,10 @@ TODO:
- ability to diff / merge versions
- ability to diff / merge versions
- map.getVersion and opening old maps read-only
- map.getVersion and opening old maps read-only
- limited support for writing to old versions (branches)
- limited support for writing to old versions (branches)
- Serializer instead of DataType, (serialize, deserialize)
- implement complete java.util.Map interface
- implement complete java.util.Map interface
- maybe rename to MVStore, MVMap, TestMVStore
- maybe rename to MVStore, MVMap, TestMVStore
- atomic test-and-set (when supporting concurrent writes)
- atomic test-and-set (when supporting concurrent writes)
- support background writes (store old version)
- support background writes (store old version)
- re-use map ids that were not used for a very long time
- file header could be a regular chunk, end of file the second
- file header could be a regular chunk, end of file the second
- possibly split chunk data into immutable and mutable
- possibly split chunk data into immutable and mutable
- test with very small chunks, possibly speed up very small transactions
- test with very small chunks, possibly speed up very small transactions
...
@@ -285,7 +283,9 @@ public class BtreeMapStore {
...
@@ -285,7 +283,9 @@ public class BtreeMapStore {
writeHeader
();
writeHeader
();
}
else
{
}
else
{
readHeader
();
readHeader
();
readMeta
();
if
(
rootChunkStart
>
0
)
{
readMeta
();
}
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
convert
(
e
);
throw
convert
(
e
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论