Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
775b1b00
提交
775b1b00
authored
13 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
A persistent tree map (work in progress)
上级
4c584cef
全部展开
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
248 行增加
和
38 行删除
+248
-38
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+2
-1
TestTreeMapStore.java
h2/src/test/org/h2/test/unit/TestTreeMapStore.java
+25
-0
StoredMap.java
h2/src/tools/org/h2/dev/store/StoredMap.java
+22
-1
TreeMapStore.java
h2/src/tools/org/h2/dev/store/TreeMapStore.java
+199
-36
没有找到文件。
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
775b1b00
...
@@ -701,7 +701,8 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
...
@@ -701,7 +701,8 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
new
TestStringCache
().
runTest
(
this
);
new
TestStringCache
().
runTest
(
this
);
new
TestStringUtils
().
runTest
(
this
);
new
TestStringUtils
().
runTest
(
this
);
new
TestTools
().
runTest
(
this
);
new
TestTools
().
runTest
(
this
);
new
TestTreeMapStore
().
runTest
(
this
);
int
test
;
// new TestTreeMapStore().runTest(this);
new
TestTraceSystem
().
runTest
(
this
);
new
TestTraceSystem
().
runTest
(
this
);
new
TestUpgrade
().
runTest
(
this
);
new
TestUpgrade
().
runTest
(
this
);
new
TestUtils
().
runTest
(
this
);
new
TestUtils
().
runTest
(
this
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/unit/TestTreeMapStore.java
浏览文件 @
775b1b00
...
@@ -29,6 +29,7 @@ public class TestTreeMapStore extends TestBase {
...
@@ -29,6 +29,7 @@ public class TestTreeMapStore extends TestBase {
}
}
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
// testDefragment();
testReuseSpace
();
testReuseSpace
();
testRandom
();
testRandom
();
testKeyValueClasses
();
testKeyValueClasses
();
...
@@ -36,6 +37,30 @@ public class TestTreeMapStore extends TestBase {
...
@@ -36,6 +37,30 @@ public class TestTreeMapStore extends TestBase {
testSimple
();
testSimple
();
}
}
private
void
testDefragment
()
{
String
fileName
=
getBaseDir
()
+
"/data.h3"
;
FileUtils
.
delete
(
fileName
);
long
initialLength
=
0
;
for
(
int
j
=
0
;
j
<
10
;
j
++)
{
TreeMapStore
s
=
TreeMapStore
.
open
(
fileName
);
StoredMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
m
.
put
(
j
+
i
,
"Hello "
+
j
);
}
s
.
store
();
System
.
out
.
println
(
s
.
toString
());
s
.
compact
();
s
.
close
();
long
len
=
FileUtils
.
size
(
fileName
);
System
.
out
.
println
(
" len:"
+
len
);
// if (initialLength == 0) {
// initialLength = len;
// } else {
// assertTrue(len <= initialLength * 2);
// }
}
}
private
void
testReuseSpace
()
{
private
void
testReuseSpace
()
{
String
fileName
=
getBaseDir
()
+
"/data.h3"
;
String
fileName
=
getBaseDir
()
+
"/data.h3"
;
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/dev/store/StoredMap.java
浏览文件 @
775b1b00
...
@@ -43,6 +43,15 @@ public class StoredMap<K, V> {
...
@@ -43,6 +43,15 @@ public class StoredMap<K, V> {
}
}
}
}
static
Class
<?>
getClass
(
String
name
)
{
if
(
name
.
equals
(
"i"
))
{
return
Integer
.
class
;
}
else
if
(
name
.
equals
(
"s"
))
{
return
String
.
class
;
}
throw
new
RuntimeException
(
"Unknown class name "
+
name
);
}
static
<
K
,
V
>
StoredMap
<
K
,
V
>
open
(
TreeMapStore
store
,
String
name
,
Class
<
K
>
keyClass
,
Class
<
V
>
valueClass
)
{
static
<
K
,
V
>
StoredMap
<
K
,
V
>
open
(
TreeMapStore
store
,
String
name
,
Class
<
K
>
keyClass
,
Class
<
V
>
valueClass
)
{
return
new
StoredMap
<
K
,
V
>(
store
,
name
,
keyClass
,
valueClass
);
return
new
StoredMap
<
K
,
V
>(
store
,
name
,
keyClass
,
valueClass
);
}
}
...
@@ -60,6 +69,10 @@ public class StoredMap<K, V> {
...
@@ -60,6 +69,10 @@ public class StoredMap<K, V> {
return
(
V
)
(
n
==
null
?
null
:
n
.
getData
());
return
(
V
)
(
n
==
null
?
null
:
n
.
getData
());
}
}
Node
getNode
(
Object
key
)
{
return
Node
.
getNode
(
root
,
key
);
}
public
void
remove
(
K
key
)
{
public
void
remove
(
K
key
)
{
if
(!
isChanged
())
{
if
(!
isChanged
())
{
store
.
changed
(
name
,
this
);
store
.
changed
(
name
,
this
);
...
@@ -78,6 +91,7 @@ public class StoredMap<K, V> {
...
@@ -78,6 +91,7 @@ public class StoredMap<K, V> {
int
length
(
Object
obj
);
int
length
(
Object
obj
);
void
write
(
ByteBuffer
buff
,
Object
x
);
void
write
(
ByteBuffer
buff
,
Object
x
);
Object
read
(
ByteBuffer
buff
);
Object
read
(
ByteBuffer
buff
);
String
getName
();
}
}
/**
/**
...
@@ -112,6 +126,10 @@ public class StoredMap<K, V> {
...
@@ -112,6 +126,10 @@ public class StoredMap<K, V> {
TreeMapStore
.
writeVarInt
(
buff
,
(
Integer
)
x
);
TreeMapStore
.
writeVarInt
(
buff
,
(
Integer
)
x
);
}
}
public
String
getName
()
{
return
"i"
;
}
}
}
/**
/**
...
@@ -153,6 +171,10 @@ public class StoredMap<K, V> {
...
@@ -153,6 +171,10 @@ public class StoredMap<K, V> {
}
}
}
}
public
String
getName
()
{
return
"s"
;
}
}
}
KeyType
getKeyType
()
{
KeyType
getKeyType
()
{
...
@@ -183,7 +205,6 @@ public class StoredMap<K, V> {
...
@@ -183,7 +205,6 @@ public class StoredMap<K, V> {
root
=
readNode
(
rootPos
);
root
=
readNode
(
rootPos
);
}
}
public
Iterator
<
K
>
keyIterator
(
K
from
)
{
public
Iterator
<
K
>
keyIterator
(
K
from
)
{
return
new
Cursor
(
root
,
from
);
return
new
Cursor
(
root
,
from
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/dev/store/TreeMapStore.java
浏览文件 @
775b1b00
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论