Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
f0d056d5
提交
f0d056d5
authored
8月 29, 2012
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
A persistent multi-version map (work in progress)
上级
2d531580
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
29 行增加
和
89 行删除
+29
-89
RtreeMap.java
h2/src/test/org/h2/test/store/RtreeMap.java
+4
-10
TestBtreeMapStore.java
h2/src/test/org/h2/test/store/TestBtreeMapStore.java
+22
-76
BtreeMap.java
h2/src/tools/org/h2/dev/store/btree/BtreeMap.java
+3
-3
没有找到文件。
h2/src/test/org/h2/test/store/RtreeMap.java
浏览文件 @
f0d056d5
...
...
@@ -108,11 +108,12 @@ public class RtreeMap<K, V> extends BtreeMap<K, V> {
Page
c2
=
remove
(
c
,
writeVersion
,
key
);
if
(
c2
==
null
)
{
// this child was deleted
p
.
remove
(
i
);
if
(
p
.
getKeyCount
()
==
0
)
{
if
(
p
.
getKeyCount
()
==
1
)
{
removePage
(
p
);
return
null
;
}
p
=
p
.
copyOnWrite
(
writeVersion
);
p
.
remove
(
i
);
}
else
if
(
oldSize
!=
c2
.
getTotalSize
())
{
p
=
p
.
copyOnWrite
(
writeVersion
);
Object
oldBounds
=
p
.
getKey
(
i
);
...
...
@@ -259,16 +260,11 @@ public class RtreeMap<K, V> extends BtreeMap<K, V> {
}
private
Page
split
(
Page
p
,
long
writeVersion
)
{
// if (p.getTotalSize() > 10000) {
// return
// }
return
quadraticSplit
|
p
.
getTotalSize
()
>
10000
?
return
quadraticSplit
?
splitQuadratic
(
p
,
writeVersion
)
:
splitLinear
(
p
,
writeVersion
);
}
public
static
int
splitLin
,
splitQuad
;
private
Page
splitLinear
(
Page
p
,
long
writeVersion
)
{
ArrayList
<
Object
>
keys
=
New
.
arrayList
();
for
(
int
i
=
0
;
i
<
p
.
getKeyCount
();
i
++)
{
...
...
@@ -276,10 +272,8 @@ public static int splitLin, splitQuad;
}
int
[]
extremes
=
keyType
.
getExtremes
(
keys
);
if
(
extremes
==
null
)
{
splitQuad
++;
return
splitQuadratic
(
p
,
writeVersion
);
}
splitLin
++;
Page
splitA
=
newPage
(
p
.
isLeaf
(),
writeVersion
);
Page
splitB
=
newPage
(
p
.
isLeaf
(),
writeVersion
);
move
(
p
,
splitA
,
extremes
[
0
]);
...
...
h2/src/test/org/h2/test/store/TestBtreeMapStore.java
浏览文件 @
f0d056d5
...
...
@@ -27,7 +27,6 @@ import org.h2.jaqu.bytecode.Null;
import
org.h2.store.fs.FileUtils
;
import
org.h2.test.TestBase
;
import
org.h2.util.New
;
import
org.h2.util.Profiler
;
/**
* Tests the tree map store.
...
...
@@ -44,14 +43,7 @@ public class TestBtreeMapStore extends TestBase {
}
public
void
test
()
{
// testRtreeMany();
// System.out.println("lin: " + RtreeMap.splitLin + " quad:" + RtreeMap.splitQuad);
// testRtreeMany();
// System.out.println("lin: " + RtreeMap.splitLin + " quad:" + RtreeMap.splitQuad);
// testRtreeMany();
// System.out.println("lin: " + RtreeMap.splitLin + " quad:" + RtreeMap.splitQuad);
// if(true) return;
//
testRtreeMany
();
testRtree
();
testRandomRtree
();
testCustomMapType
();
...
...
@@ -71,78 +63,37 @@ public class TestBtreeMapStore extends TestBase {
}
private
void
testRtreeMany
()
{
// quadratic:
// add: 796
// query: 161
// remove: 194
// linear: 50
// add: 345
// query: 244
// remove: 259
// MyTest
// add:197
// query:236
// delete:669
String
fileName
=
getBaseDir
()
+
"/testMeta.h3"
;
FileUtils
.
delete
(
fileName
);
BtreeMapStore
s
;
s
=
openStore
(
fileName
);
s
.
setMaxPageSize
(
50
);
//
s.setMaxPageSize(50);
RtreeMap
<
SpatialKey
,
String
>
r
=
s
.
openMap
(
"data"
,
"r"
,
"s2"
,
""
);
//
r.setQuadraticSplit(true);
//
r.setQuadraticSplit(true);
Random
rand
=
new
Random
(
1
);
int
len
=
1000000
;
long
t
=
System
.
currentTimeMillis
();
Profiler
prof
=
new
Profiler
();
//prof.startCollecting();
int
len
=
1000
;
// long t = System.currentTimeMillis();
// Profiler prof = new Profiler();
// prof.startCollecting();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
float
x
=
rand
.
nextFloat
(),
y
=
rand
.
nextFloat
();
float
p
=
(
float
)
(
rand
.
nextFloat
()
*
0.000001
);
SpatialKey
k
=
new
SpatialKey
(
i
,
x
-
p
,
x
+
p
,
y
-
p
,
y
+
p
);
r
.
add
(
k
,
""
+
i
);
if
(
i
>
0
&&
(
i
%
1000
0
)
==
0
)
{
if
(
i
>
0
&&
(
i
%
len
/
1
0
)
==
0
)
{
s
.
store
();
System
.
out
.
println
(
"store "
+
i
);
}
//
if (i > 0 && (i % 10000) == 0) {
//
render(r, getBaseDir() + "/test.png");
//
}
if
(
i
>
0
&&
(
i
%
10000
)
==
0
)
{
render
(
r
,
getBaseDir
()
+
"/test.png"
);
}
}
//System.out.println(prof.getTop(5));
// quadratic
// add: 77967
// query: 39521
// remove: 22292
// linear
// add: 46136
// query: 65454
// remove: 35514
// > 10000 quadratic
// add: 54660
// query: 62946
System
.
out
.
println
(
"add: "
+
(
System
.
currentTimeMillis
()
-
t
));
// System.out.println(prof.getTop(5));
// System.out.println("add: " + (System.currentTimeMillis() - t));
s
.
store
();
s
.
close
();
s
=
openStore
(
fileName
);
r
=
s
.
openMap
(
"data"
,
"r"
,
"s2"
,
""
);
t
=
System
.
currentTimeMillis
();
// t = System.currentTimeMillis();
rand
=
new
Random
(
1
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
float
x
=
rand
.
nextFloat
(),
y
=
rand
.
nextFloat
();
...
...
@@ -150,9 +101,7 @@ t = System.currentTimeMillis();
SpatialKey
k
=
new
SpatialKey
(
i
,
x
-
p
,
x
+
p
,
y
-
p
,
y
+
p
);
assertEquals
(
""
+
i
,
r
.
get
(
k
));
}
System
.
out
.
println
(
"query: "
+
(
System
.
currentTimeMillis
()
-
t
));
// System.out.println("query: " + (System.currentTimeMillis() - t));
assertEquals
(
len
,
r
.
size
());
int
count
=
0
;
for
(
SpatialKey
k
:
r
.
keySet
())
{
...
...
@@ -160,11 +109,9 @@ System.out.println("query: " + (System.currentTimeMillis() - t));
count
++;
}
assertEquals
(
len
,
count
);
t
=
System
.
currentTimeMillis
();
//Profiler prof = new Profiler();
//prof.startCollecting();
// t = System.currentTimeMillis();
// Profiler prof = new Profiler();
// prof.startCollecting();
rand
=
new
Random
(
1
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
float
x
=
rand
.
nextFloat
(),
y
=
rand
.
nextFloat
();
...
...
@@ -173,11 +120,9 @@ t = System.currentTimeMillis();
r
.
remove
(
k
);
}
assertEquals
(
0
,
r
.
size
());
// System.out.println(prof.getTop(5));
System
.
out
.
println
(
"remove: "
+
(
System
.
currentTimeMillis
()
-
t
));
s
.
close
();
// System.out.println(prof.getTop(5));
// System.out.println("remove: " + (System.currentTimeMillis() - t));
}
private
void
testRtree
()
{
...
...
@@ -264,6 +209,7 @@ System.out.println("remove: " + (System.currentTimeMillis() - t));
private
static
int
[]
scale
(
SpatialKey
b
,
SpatialKey
x
,
int
width
,
int
height
)
{
int
[]
rect
=
{
(
int
)
((
x
.
min
(
0
)
-
b
.
min
(
0
))
*
(
width
*
0.9
)
/
(
b
.
max
(
0
)
-
b
.
min
(
0
))
+
width
*
0.05
),
(
int
)
((
x
.
min
(
1
)
-
b
.
min
(
1
))
*
(
height
*
0.9
)
/
(
b
.
max
(
1
)
-
b
.
min
(
1
))
+
height
*
0.05
),
(
int
)
((
x
.
max
(
0
)
-
b
.
min
(
0
))
*
(
width
*
0.9
)
/
(
b
.
max
(
0
)
-
b
.
min
(
0
))
+
width
*
0.05
),
(
int
)
((
x
.
max
(
1
)
-
b
.
min
(
1
))
*
(
height
*
0.9
)
/
(
b
.
max
(
1
)
-
b
.
min
(
1
))
+
height
*
0.05
),
...
...
h2/src/tools/org/h2/dev/store/btree/BtreeMap.java
浏览文件 @
f0d056d5
...
...
@@ -357,12 +357,12 @@ public class BtreeMap<K, V> {
Page
c2
=
remove
(
c
,
writeVersion
,
key
);
if
(
c2
==
null
)
{
// this child was deleted
p
=
p
.
copyOnWrite
(
writeVersion
);
p
.
remove
(
index
);
if
(
p
.
getKeyCount
()
==
0
)
{
if
(
p
.
getKeyCount
()
==
1
)
{
removePage
(
p
);
p
=
p
.
getChildPage
(
0
);
}
p
=
p
.
copyOnWrite
(
writeVersion
);
p
.
remove
(
index
);
}
else
if
(
oldSize
!=
c2
.
getTotalSize
())
{
p
=
p
.
copyOnWrite
(
writeVersion
);
p
.
setChild
(
index
,
c2
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论