Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
06e97e0e
提交
06e97e0e
authored
6月 05, 2012
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
A persistent tree map.
上级
4550a0f6
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
16 行增加
和
20 行删除
+16
-20
TestTreeMapStore.java
h2/src/test/org/h2/test/unit/TestTreeMapStore.java
+7
-8
BtreeMapStore.java
h2/src/tools/org/h2/dev/store/btree/BtreeMapStore.java
+9
-12
没有找到文件。
h2/src/test/org/h2/test/unit/TestTreeMapStore.java
浏览文件 @
06e97e0e
...
...
@@ -39,11 +39,10 @@ public class TestTreeMapStore extends TestBase {
}
private
void
testBtreeStore
()
{
String
fileName
=
getBaseDir
()
+
"/
data
.h3"
;
String
fileName
=
getBaseDir
()
+
"/
testBtreeStore
.h3"
;
FileUtils
.
delete
(
fileName
);
BtreeMapStore
s
=
BtreeMapStore
.
open
(
fileName
);
BtreeMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
// int count = 0;
int
count
=
2000
;
// Profiler p = new Profiler();
// p.startCollecting();
...
...
@@ -84,7 +83,7 @@ public class TestTreeMapStore extends TestBase {
}
private
void
testDefragment
()
{
String
fileName
=
getBaseDir
()
+
"/
data
.h3"
;
String
fileName
=
getBaseDir
()
+
"/
testDefragment
.h3"
;
FileUtils
.
delete
(
fileName
);
long
initialLength
=
0
;
for
(
int
j
=
0
;
j
<
20
;
j
++)
{
...
...
@@ -125,7 +124,7 @@ public class TestTreeMapStore extends TestBase {
}
private
void
testReuseSpace
()
{
String
fileName
=
getBaseDir
()
+
"/
data
.h3"
;
String
fileName
=
getBaseDir
()
+
"/
testReuseSpace
.h3"
;
FileUtils
.
delete
(
fileName
);
long
initialLength
=
0
;
for
(
int
j
=
0
;
j
<
10
;
j
++)
{
...
...
@@ -150,7 +149,7 @@ public class TestTreeMapStore extends TestBase {
}
private
void
testRandom
()
{
String
fileName
=
getBaseDir
()
+
"/
data
.h3"
;
String
fileName
=
getBaseDir
()
+
"/
testRandom
.h3"
;
FileUtils
.
delete
(
fileName
);
BtreeMapStore
s
=
BtreeMapStore
.
open
(
fileName
);
BtreeMap
<
Integer
,
Integer
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
Integer
.
class
);
...
...
@@ -198,7 +197,7 @@ public class TestTreeMapStore extends TestBase {
}
private
void
testKeyValueClasses
()
{
String
fileName
=
getBaseDir
()
+
"/
data
.h3"
;
String
fileName
=
getBaseDir
()
+
"/
testKeyValueClasses
.h3"
;
FileUtils
.
delete
(
fileName
);
BtreeMapStore
s
=
BtreeMapStore
.
open
(
fileName
);
BtreeMap
<
Integer
,
String
>
is
=
s
.
openMap
(
"intString"
,
Integer
.
class
,
String
.
class
);
...
...
@@ -235,7 +234,7 @@ public class TestTreeMapStore extends TestBase {
}
private
void
testIterate
()
{
String
fileName
=
getBaseDir
()
+
"/
data
.h3"
;
String
fileName
=
getBaseDir
()
+
"/
testIterate
.h3"
;
FileUtils
.
delete
(
fileName
);
BtreeMapStore
s
=
BtreeMapStore
.
open
(
fileName
);
BtreeMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
...
...
@@ -268,7 +267,7 @@ public class TestTreeMapStore extends TestBase {
}
private
void
testSimple
()
{
String
fileName
=
getBaseDir
()
+
"/
data
.h3"
;
String
fileName
=
getBaseDir
()
+
"/
testSimple
.h3"
;
FileUtils
.
delete
(
fileName
);
BtreeMapStore
s
=
BtreeMapStore
.
open
(
fileName
);
BtreeMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
...
...
h2/src/tools/org/h2/dev/store/btree/BtreeMapStore.java
浏览文件 @
06e97e0e
...
...
@@ -81,8 +81,6 @@ public class BtreeMapStore {
private
int
lastBlockId
;
private
int
loadCount
;
// TODO support quota (per map, per storage)
// TODO support r-tree
// TODO support triggers and events (possibly on a different layer)
...
...
@@ -210,16 +208,12 @@ public class BtreeMapStore {
}
}
public
String
toString
()
{
return
"cache size: "
+
cache
.
size
()
+
" loadCount: "
+
loadCount
+
"\n"
+
blocks
.
toString
().
replace
(
'\n'
,
' '
);
}
private
static
RuntimeException
convert
(
Exception
e
)
{
throw
new
RuntimeException
(
"Exception: "
+
e
,
e
);
}
/**
* Close the file.
* Close the file.
Uncommitted changes are ignored.
*/
public
void
close
()
{
store
();
...
...
@@ -249,14 +243,16 @@ public class BtreeMapStore {
}
/**
* Persist all changes to disk.
* Commit all changes and persist them to disk.
*
* @return the transaction id
*/
public
void
store
()
{
public
long
store
()
{
if
(!
meta
.
isChanged
()
&&
mapsChanged
.
size
()
==
0
)
{
// TODO truncate file if empty
return
;
return
transaction
;
}
commit
();
long
trans
=
commit
();
// the length estimate is not correct,
// as we don't know the exact positions and entry counts
...
...
@@ -359,6 +355,7 @@ public class BtreeMapStore {
writeHeader
();
mapsChanged
.
clear
();
temp
.
clear
();
return
trans
;
}
private
long
allocateBlock
(
long
length
)
{
...
...
@@ -697,7 +694,7 @@ public class BtreeMapStore {
*
* @param string the string to log
*/
public
void
log
(
String
string
)
{
void
log
(
String
string
)
{
// TODO logging
// System.out.println(string);
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论