Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
5e703674
提交
5e703674
authored
8月 31, 2012
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
A persistent multi-version map (work in progress) - rename to MVStore / MVMap
上级
d5cc1876
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
124 行增加
和
125 行删除
+124
-125
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+2
-2
RtreeMap.java
h2/src/test/org/h2/test/store/RtreeMap.java
+4
-4
SequenceMap.java
h2/src/test/org/h2/test/store/SequenceMap.java
+4
-4
TestMVStore.java
h2/src/test/org/h2/test/store/TestMVStore.java
+51
-51
TestMapFactory.java
h2/src/test/org/h2/test/store/TestMapFactory.java
+3
-3
TestRtree.java
h2/src/test/org/h2/test/store/TestRtree.java
+6
-6
ChangeCursor.java
h2/src/tools/org/h2/dev/store/btree/ChangeCursor.java
+1
-1
Cursor.java
h2/src/tools/org/h2/dev/store/btree/Cursor.java
+2
-2
MVMap.java
h2/src/tools/org/h2/dev/store/btree/MVMap.java
+9
-9
MVStore.java
h2/src/tools/org/h2/dev/store/btree/MVStore.java
+35
-36
MapFactory.java
h2/src/tools/org/h2/dev/store/btree/MapFactory.java
+2
-2
Page.java
h2/src/tools/org/h2/dev/store/btree/Page.java
+5
-5
没有找到文件。
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
5e703674
...
@@ -105,7 +105,7 @@ import org.h2.test.server.TestWeb;
...
@@ -105,7 +105,7 @@ import org.h2.test.server.TestWeb;
import
org.h2.test.server.TestInit
;
import
org.h2.test.server.TestInit
;
import
org.h2.test.store.TestCacheLIRS
;
import
org.h2.test.store.TestCacheLIRS
;
import
org.h2.test.store.TestDataUtils
;
import
org.h2.test.store.TestDataUtils
;
import
org.h2.test.store.Test
BtreeMap
Store
;
import
org.h2.test.store.Test
MV
Store
;
import
org.h2.test.store.TestRtree
;
import
org.h2.test.store.TestRtree
;
import
org.h2.test.synth.TestBtreeIndex
;
import
org.h2.test.synth.TestBtreeIndex
;
import
org.h2.test.synth.TestCrashAPI
;
import
org.h2.test.synth.TestCrashAPI
;
...
@@ -665,7 +665,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
...
@@ -665,7 +665,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
private
void
testUnit
()
{
private
void
testUnit
()
{
// store
// store
new
Test
BtreeMap
Store
().
runTest
(
this
);
new
Test
MV
Store
().
runTest
(
this
);
new
TestCacheLIRS
().
runTest
(
this
);
new
TestCacheLIRS
().
runTest
(
this
);
new
TestDataUtils
().
runTest
(
this
);
new
TestDataUtils
().
runTest
(
this
);
new
TestRtree
().
runTest
(
this
);
new
TestRtree
().
runTest
(
this
);
...
...
h2/src/test/org/h2/test/store/RtreeMap.java
浏览文件 @
5e703674
...
@@ -7,8 +7,8 @@
...
@@ -7,8 +7,8 @@
package
org
.
h2
.
test
.
store
;
package
org
.
h2
.
test
.
store
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
org.h2.dev.store.btree.
Btree
Map
;
import
org.h2.dev.store.btree.
MV
Map
;
import
org.h2.dev.store.btree.
BtreeMap
Store
;
import
org.h2.dev.store.btree.
MV
Store
;
import
org.h2.dev.store.btree.Cursor
;
import
org.h2.dev.store.btree.Cursor
;
import
org.h2.dev.store.btree.CursorPos
;
import
org.h2.dev.store.btree.CursorPos
;
import
org.h2.dev.store.btree.DataType
;
import
org.h2.dev.store.btree.DataType
;
...
@@ -21,12 +21,12 @@ import org.h2.util.New;
...
@@ -21,12 +21,12 @@ import org.h2.util.New;
* @param <K> the key class
* @param <K> the key class
* @param <V> the value class
* @param <V> the value class
*/
*/
public
class
RtreeMap
<
K
,
V
>
extends
Btree
Map
<
K
,
V
>
{
public
class
RtreeMap
<
K
,
V
>
extends
MV
Map
<
K
,
V
>
{
private
final
SpatialType
keyType
;
private
final
SpatialType
keyType
;
private
boolean
quadraticSplit
;
private
boolean
quadraticSplit
;
RtreeMap
(
BtreeMap
Store
store
,
int
id
,
String
name
,
DataType
keyType
,
RtreeMap
(
MV
Store
store
,
int
id
,
String
name
,
DataType
keyType
,
DataType
valueType
,
long
createVersion
)
{
DataType
valueType
,
long
createVersion
)
{
super
(
store
,
id
,
name
,
keyType
,
valueType
,
createVersion
);
super
(
store
,
id
,
name
,
keyType
,
valueType
,
createVersion
);
this
.
keyType
=
(
SpatialType
)
keyType
;
this
.
keyType
=
(
SpatialType
)
keyType
;
...
...
h2/src/test/org/h2/test/store/SequenceMap.java
浏览文件 @
5e703674
...
@@ -9,8 +9,8 @@ package org.h2.test.store;
...
@@ -9,8 +9,8 @@ package org.h2.test.store;
import
java.util.AbstractSet
;
import
java.util.AbstractSet
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.Set
;
import
java.util.Set
;
import
org.h2.dev.store.btree.
Btree
Map
;
import
org.h2.dev.store.btree.
MV
Map
;
import
org.h2.dev.store.btree.
BtreeMap
Store
;
import
org.h2.dev.store.btree.
MV
Store
;
import
org.h2.dev.store.btree.DataType
;
import
org.h2.dev.store.btree.DataType
;
/**
/**
...
@@ -19,11 +19,11 @@ import org.h2.dev.store.btree.DataType;
...
@@ -19,11 +19,11 @@ import org.h2.dev.store.btree.DataType;
* @param <K> the key type
* @param <K> the key type
* @param <V> the key type
* @param <V> the key type
*/
*/
public
class
SequenceMap
<
K
,
V
>
extends
Btree
Map
<
K
,
V
>
{
public
class
SequenceMap
<
K
,
V
>
extends
MV
Map
<
K
,
V
>
{
int
min
=
1
,
max
=
10
;
int
min
=
1
,
max
=
10
;
SequenceMap
(
BtreeMap
Store
store
,
int
id
,
String
name
,
DataType
keyType
,
SequenceMap
(
MV
Store
store
,
int
id
,
String
name
,
DataType
keyType
,
DataType
valueType
,
long
createVersion
)
{
DataType
valueType
,
long
createVersion
)
{
super
(
store
,
id
,
name
,
keyType
,
valueType
,
createVersion
);
super
(
store
,
id
,
name
,
keyType
,
valueType
,
createVersion
);
setReadOnly
(
true
);
setReadOnly
(
true
);
...
...
h2/src/test/org/h2/test/store/Test
BtreeMap
Store.java
→
h2/src/test/org/h2/test/store/Test
MV
Store.java
浏览文件 @
5e703674
...
@@ -9,8 +9,8 @@ import java.util.ArrayList;
...
@@ -9,8 +9,8 @@ import java.util.ArrayList;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.Random
;
import
java.util.Random
;
import
java.util.TreeMap
;
import
java.util.TreeMap
;
import
org.h2.dev.store.btree.
Btree
Map
;
import
org.h2.dev.store.btree.
MV
Map
;
import
org.h2.dev.store.btree.
BtreeMap
Store
;
import
org.h2.dev.store.btree.
MV
Store
;
import
org.h2.jaqu.bytecode.Null
;
import
org.h2.jaqu.bytecode.Null
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
...
@@ -19,7 +19,7 @@ import org.h2.util.New;
...
@@ -19,7 +19,7 @@ import org.h2.util.New;
/**
/**
* Tests the tree map store.
* Tests the tree map store.
*/
*/
public
class
Test
BtreeMap
Store
extends
TestBase
{
public
class
Test
MV
Store
extends
TestBase
{
/**
/**
* Run just this test.
* Run just this test.
...
@@ -52,9 +52,9 @@ public class TestBtreeMapStore extends TestBase {
...
@@ -52,9 +52,9 @@ public class TestBtreeMapStore extends TestBase {
private
void
testIterateOverChanges
()
{
private
void
testIterateOverChanges
()
{
String
fileName
=
getBaseDir
()
+
"/testVersion.h3"
;
String
fileName
=
getBaseDir
()
+
"/testVersion.h3"
;
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
BtreeMap
Store
s
=
openStore
(
fileName
);
MV
Store
s
=
openStore
(
fileName
);
s
.
setMaxPageSize
(
6
);
s
.
setMaxPageSize
(
6
);
Btree
Map
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
MV
Map
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
for
(
int
i
=
0
;
i
<
60
;
i
++)
{
for
(
int
i
=
0
;
i
<
60
;
i
++)
{
m
.
put
(
i
,
"Hello"
);
m
.
put
(
i
,
"Hello"
);
}
}
...
@@ -79,9 +79,9 @@ public class TestBtreeMapStore extends TestBase {
...
@@ -79,9 +79,9 @@ public class TestBtreeMapStore extends TestBase {
private
void
testVersion
()
{
private
void
testVersion
()
{
String
fileName
=
getBaseDir
()
+
"/testVersion.h3"
;
String
fileName
=
getBaseDir
()
+
"/testVersion.h3"
;
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
BtreeMap
Store
s
;
MV
Store
s
;
s
=
openStore
(
fileName
);
s
=
openStore
(
fileName
);
Btree
Map
<
String
,
String
>
m
;
MV
Map
<
String
,
String
>
m
;
s
=
openStore
(
fileName
);
s
=
openStore
(
fileName
);
m
=
s
.
openMap
(
"data"
,
String
.
class
,
String
.
class
);
m
=
s
.
openMap
(
"data"
,
String
.
class
,
String
.
class
);
long
first
=
s
.
getCurrentVersion
();
long
first
=
s
.
getCurrentVersion
();
...
@@ -94,10 +94,10 @@ public class TestBtreeMapStore extends TestBase {
...
@@ -94,10 +94,10 @@ public class TestBtreeMapStore extends TestBase {
long
old
=
s
.
getCurrentVersion
();
long
old
=
s
.
getCurrentVersion
();
m
.
put
(
"1"
,
"Hallo"
);
m
.
put
(
"1"
,
"Hallo"
);
m
.
put
(
"2"
,
"Welt"
);
m
.
put
(
"2"
,
"Welt"
);
Btree
Map
<
String
,
String
>
mFirst
;
MV
Map
<
String
,
String
>
mFirst
;
mFirst
=
m
.
openVersion
(
first
);
mFirst
=
m
.
openVersion
(
first
);
assertEquals
(
0
,
mFirst
.
size
());
assertEquals
(
0
,
mFirst
.
size
());
Btree
Map
<
String
,
String
>
mOld
;
MV
Map
<
String
,
String
>
mOld
;
assertEquals
(
"Hallo"
,
m
.
get
(
"1"
));
assertEquals
(
"Hallo"
,
m
.
get
(
"1"
));
assertEquals
(
"Welt"
,
m
.
get
(
"2"
));
assertEquals
(
"Welt"
,
m
.
get
(
"2"
));
mOld
=
m
.
openVersion
(
old
);
mOld
=
m
.
openVersion
(
old
);
...
@@ -130,8 +130,8 @@ public class TestBtreeMapStore extends TestBase {
...
@@ -130,8 +130,8 @@ public class TestBtreeMapStore extends TestBase {
private
void
testTruncateFile
()
{
private
void
testTruncateFile
()
{
String
fileName
=
getBaseDir
()
+
"/testTruncate.h3"
;
String
fileName
=
getBaseDir
()
+
"/testTruncate.h3"
;
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
BtreeMap
Store
s
;
MV
Store
s
;
Btree
Map
<
Integer
,
String
>
m
;
MV
Map
<
Integer
,
String
>
m
;
s
=
openStore
(
fileName
);
s
=
openStore
(
fileName
);
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
...
@@ -153,8 +153,8 @@ public class TestBtreeMapStore extends TestBase {
...
@@ -153,8 +153,8 @@ public class TestBtreeMapStore extends TestBase {
private
void
testFastDelete
()
{
private
void
testFastDelete
()
{
String
fileName
=
getBaseDir
()
+
"/testFastDelete.h3"
;
String
fileName
=
getBaseDir
()
+
"/testFastDelete.h3"
;
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
BtreeMap
Store
s
;
MV
Store
s
;
Btree
Map
<
Integer
,
String
>
m
;
MV
Map
<
Integer
,
String
>
m
;
s
=
openStore
(
fileName
);
s
=
openStore
(
fileName
);
s
.
setMaxPageSize
(
100
);
s
.
setMaxPageSize
(
100
);
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
...
@@ -181,16 +181,16 @@ public class TestBtreeMapStore extends TestBase {
...
@@ -181,16 +181,16 @@ public class TestBtreeMapStore extends TestBase {
private
void
testRollbackStored
()
{
private
void
testRollbackStored
()
{
String
fileName
=
getBaseDir
()
+
"/testRollback.h3"
;
String
fileName
=
getBaseDir
()
+
"/testRollback.h3"
;
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
Btree
Map
<
String
,
String
>
meta
;
MV
Map
<
String
,
String
>
meta
;
BtreeMap
Store
s
=
openStore
(
fileName
);
MV
Store
s
=
openStore
(
fileName
);
assertEquals
(-
1
,
s
.
getRetainChunk
());
assertEquals
(-
1
,
s
.
getRetainChunk
());
s
.
setRetainChunk
(
0
);
s
.
setRetainChunk
(
0
);
assertEquals
(
0
,
s
.
getRetainChunk
());
assertEquals
(
0
,
s
.
getRetainChunk
());
assertEquals
(
1
,
s
.
getCurrentVersion
());
assertEquals
(
1
,
s
.
getCurrentVersion
());
assertFalse
(
s
.
hasUnsavedChanges
());
assertFalse
(
s
.
hasUnsavedChanges
());
Btree
Map
<
String
,
String
>
m
=
s
.
openMap
(
"data"
,
String
.
class
,
String
.
class
);
MV
Map
<
String
,
String
>
m
=
s
.
openMap
(
"data"
,
String
.
class
,
String
.
class
);
assertTrue
(
s
.
hasUnsavedChanges
());
assertTrue
(
s
.
hasUnsavedChanges
());
Btree
Map
<
String
,
String
>
m0
=
s
.
openMap
(
"data0"
,
String
.
class
,
String
.
class
);
MV
Map
<
String
,
String
>
m0
=
s
.
openMap
(
"data0"
,
String
.
class
,
String
.
class
);
m
.
put
(
"1"
,
"Hello"
);
m
.
put
(
"1"
,
"Hello"
);
assertEquals
(
1
,
s
.
commit
());
assertEquals
(
1
,
s
.
commit
());
s
.
rollbackTo
(
1
);
s
.
rollbackTo
(
1
);
...
@@ -207,7 +207,7 @@ public class TestBtreeMapStore extends TestBase {
...
@@ -207,7 +207,7 @@ public class TestBtreeMapStore extends TestBase {
meta
=
s
.
getMetaMap
();
meta
=
s
.
getMetaMap
();
m
=
s
.
openMap
(
"data"
,
String
.
class
,
String
.
class
);
m
=
s
.
openMap
(
"data"
,
String
.
class
,
String
.
class
);
m0
=
s
.
openMap
(
"data0"
,
String
.
class
,
String
.
class
);
m0
=
s
.
openMap
(
"data0"
,
String
.
class
,
String
.
class
);
Btree
Map
<
String
,
String
>
m1
=
s
.
openMap
(
"data1"
,
String
.
class
,
String
.
class
);
MV
Map
<
String
,
String
>
m1
=
s
.
openMap
(
"data1"
,
String
.
class
,
String
.
class
);
m
.
put
(
"1"
,
"Hallo"
);
m
.
put
(
"1"
,
"Hallo"
);
m0
.
put
(
"1"
,
"Hallo"
);
m0
.
put
(
"1"
,
"Hallo"
);
m1
.
put
(
"1"
,
"Hallo"
);
m1
.
put
(
"1"
,
"Hallo"
);
...
@@ -267,17 +267,17 @@ public class TestBtreeMapStore extends TestBase {
...
@@ -267,17 +267,17 @@ public class TestBtreeMapStore extends TestBase {
private
void
testRollbackInMemory
()
{
private
void
testRollbackInMemory
()
{
String
fileName
=
getBaseDir
()
+
"/testRollback.h3"
;
String
fileName
=
getBaseDir
()
+
"/testRollback.h3"
;
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
BtreeMap
Store
s
=
openStore
(
fileName
);
MV
Store
s
=
openStore
(
fileName
);
assertEquals
(
1
,
s
.
getCurrentVersion
());
assertEquals
(
1
,
s
.
getCurrentVersion
());
s
.
setMaxPageSize
(
5
);
s
.
setMaxPageSize
(
5
);
Btree
Map
<
String
,
String
>
m
=
s
.
openMap
(
"data"
,
String
.
class
,
String
.
class
);
MV
Map
<
String
,
String
>
m
=
s
.
openMap
(
"data"
,
String
.
class
,
String
.
class
);
s
.
rollbackTo
(
0
);
s
.
rollbackTo
(
0
);
assertTrue
(
m
.
isClosed
());
assertTrue
(
m
.
isClosed
());
assertEquals
(
1
,
s
.
getCurrentVersion
());
assertEquals
(
1
,
s
.
getCurrentVersion
());
m
=
s
.
openMap
(
"data"
,
String
.
class
,
String
.
class
);
m
=
s
.
openMap
(
"data"
,
String
.
class
,
String
.
class
);
Btree
Map
<
String
,
String
>
m0
=
s
.
openMap
(
"data0"
,
String
.
class
,
String
.
class
);
MV
Map
<
String
,
String
>
m0
=
s
.
openMap
(
"data0"
,
String
.
class
,
String
.
class
);
Btree
Map
<
String
,
String
>
m2
=
s
.
openMap
(
"data2"
,
String
.
class
,
String
.
class
);
MV
Map
<
String
,
String
>
m2
=
s
.
openMap
(
"data2"
,
String
.
class
,
String
.
class
);
m
.
put
(
"1"
,
"Hello"
);
m
.
put
(
"1"
,
"Hello"
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
m2
.
put
(
""
+
i
,
"Test"
);
m2
.
put
(
""
+
i
,
"Test"
);
...
@@ -285,7 +285,7 @@ public class TestBtreeMapStore extends TestBase {
...
@@ -285,7 +285,7 @@ public class TestBtreeMapStore extends TestBase {
long
v1
=
s
.
commit
();
long
v1
=
s
.
commit
();
assertEquals
(
1
,
v1
);
assertEquals
(
1
,
v1
);
assertEquals
(
2
,
s
.
getCurrentVersion
());
assertEquals
(
2
,
s
.
getCurrentVersion
());
Btree
Map
<
String
,
String
>
m1
=
s
.
openMap
(
"data1"
,
String
.
class
,
String
.
class
);
MV
Map
<
String
,
String
>
m1
=
s
.
openMap
(
"data1"
,
String
.
class
,
String
.
class
);
assertEquals
(
"Test"
,
m2
.
get
(
"1"
));
assertEquals
(
"Test"
,
m2
.
get
(
"1"
));
m
.
put
(
"1"
,
"Hallo"
);
m
.
put
(
"1"
,
"Hallo"
);
m0
.
put
(
"1"
,
"Hallo"
);
m0
.
put
(
"1"
,
"Hallo"
);
...
@@ -309,10 +309,10 @@ public class TestBtreeMapStore extends TestBase {
...
@@ -309,10 +309,10 @@ public class TestBtreeMapStore extends TestBase {
private
void
testMeta
()
{
private
void
testMeta
()
{
String
fileName
=
getBaseDir
()
+
"/testMeta.h3"
;
String
fileName
=
getBaseDir
()
+
"/testMeta.h3"
;
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
BtreeMap
Store
s
=
openStore
(
fileName
);
MV
Store
s
=
openStore
(
fileName
);
Btree
Map
<
String
,
String
>
m
=
s
.
getMetaMap
();
MV
Map
<
String
,
String
>
m
=
s
.
getMetaMap
();
s
.
setRetainChunk
(
0
);
s
.
setRetainChunk
(
0
);
Btree
Map
<
String
,
String
>
data
=
s
.
openMap
(
"data"
,
String
.
class
,
String
.
class
);
MV
Map
<
String
,
String
>
data
=
s
.
openMap
(
"data"
,
String
.
class
,
String
.
class
);
data
.
put
(
"1"
,
"Hello"
);
data
.
put
(
"1"
,
"Hello"
);
data
.
put
(
"2"
,
"World"
);
data
.
put
(
"2"
,
"World"
);
s
.
store
();
s
.
store
();
...
@@ -332,13 +332,13 @@ public class TestBtreeMapStore extends TestBase {
...
@@ -332,13 +332,13 @@ public class TestBtreeMapStore extends TestBase {
private
void
testInMemory
()
{
private
void
testInMemory
()
{
for
(
int
j
=
0
;
j
<
1
;
j
++)
{
for
(
int
j
=
0
;
j
<
1
;
j
++)
{
BtreeMap
Store
s
=
openStore
(
null
);
MV
Store
s
=
openStore
(
null
);
// s.setMaxPageSize(10);
// s.setMaxPageSize(10);
// long t;
// long t;
int
len
=
100
;
int
len
=
100
;
// TreeMap<Integer, String> m = new TreeMap<Integer, String>();
// TreeMap<Integer, String> m = new TreeMap<Integer, String>();
// HashMap<Integer, String> m = New.hashMap();
// HashMap<Integer, String> m = New.hashMap();
Btree
Map
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
MV
Map
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
// t = System.currentTimeMillis();
// t = System.currentTimeMillis();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
m
.
put
(
i
,
"Hello World"
);
m
.
put
(
i
,
"Hello World"
);
...
@@ -365,10 +365,10 @@ public class TestBtreeMapStore extends TestBase {
...
@@ -365,10 +365,10 @@ public class TestBtreeMapStore extends TestBase {
int
len
=
1000
;
int
len
=
1000
;
for
(
int
j
=
0
;
j
<
5
;
j
++)
{
for
(
int
j
=
0
;
j
<
5
;
j
++)
{
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
BtreeMap
Store
s
=
openStore
(
fileName
);
MV
Store
s
=
openStore
(
fileName
);
// s.setCompressor(null);
// s.setCompressor(null);
s
.
setMaxPageSize
(
40
);
s
.
setMaxPageSize
(
40
);
Btree
Map
<
Integer
,
Object
[]>
m
=
s
.
openMap
(
"data"
,
""
,
"i"
,
"r(i,,)"
);
MV
Map
<
Integer
,
Object
[]>
m
=
s
.
openMap
(
"data"
,
""
,
"i"
,
"r(i,,)"
);
// Profiler prof = new Profiler();
// Profiler prof = new Profiler();
// prof.startCollecting();
// prof.startCollecting();
// long t = System.currentTimeMillis();
// long t = System.currentTimeMillis();
...
@@ -394,10 +394,10 @@ public class TestBtreeMapStore extends TestBase {
...
@@ -394,10 +394,10 @@ public class TestBtreeMapStore extends TestBase {
private
void
testBtreeStore
()
{
private
void
testBtreeStore
()
{
String
fileName
=
getBaseDir
()
+
"/testBtreeStore.h3"
;
String
fileName
=
getBaseDir
()
+
"/testBtreeStore.h3"
;
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
BtreeMap
Store
s
=
openStore
(
fileName
);
MV
Store
s
=
openStore
(
fileName
);
s
.
close
();
s
.
close
();
s
=
openStore
(
fileName
);
s
=
openStore
(
fileName
);
Btree
Map
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
MV
Map
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
int
count
=
2000
;
int
count
=
2000
;
// Profiler p = new Profiler();
// Profiler p = new Profiler();
// p.startCollecting();
// p.startCollecting();
...
@@ -443,8 +443,8 @@ public class TestBtreeMapStore extends TestBase {
...
@@ -443,8 +443,8 @@ public class TestBtreeMapStore extends TestBase {
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
long
initialLength
=
0
;
long
initialLength
=
0
;
for
(
int
j
=
0
;
j
<
20
;
j
++)
{
for
(
int
j
=
0
;
j
<
20
;
j
++)
{
BtreeMap
Store
s
=
openStore
(
fileName
);
MV
Store
s
=
openStore
(
fileName
);
Btree
Map
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
MV
Map
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
m
.
put
(
j
+
i
,
"Hello "
+
j
);
m
.
put
(
j
+
i
,
"Hello "
+
j
);
}
}
...
@@ -461,8 +461,8 @@ public class TestBtreeMapStore extends TestBase {
...
@@ -461,8 +461,8 @@ public class TestBtreeMapStore extends TestBase {
}
}
// long len = FileUtils.size(fileName);
// long len = FileUtils.size(fileName);
// System.out.println("len0: " + len);
// System.out.println("len0: " + len);
BtreeMap
Store
s
=
openStore
(
fileName
);
MV
Store
s
=
openStore
(
fileName
);
Btree
Map
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
MV
Map
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
m
.
remove
(
i
);
m
.
remove
(
i
);
}
}
...
@@ -484,8 +484,8 @@ public class TestBtreeMapStore extends TestBase {
...
@@ -484,8 +484,8 @@ public class TestBtreeMapStore extends TestBase {
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
long
initialLength
=
0
;
long
initialLength
=
0
;
for
(
int
j
=
0
;
j
<
20
;
j
++)
{
for
(
int
j
=
0
;
j
<
20
;
j
++)
{
BtreeMap
Store
s
=
openStore
(
fileName
);
MV
Store
s
=
openStore
(
fileName
);
Btree
Map
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
MV
Map
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
m
.
put
(
i
,
"Hello"
);
m
.
put
(
i
,
"Hello"
);
}
}
...
@@ -508,8 +508,8 @@ public class TestBtreeMapStore extends TestBase {
...
@@ -508,8 +508,8 @@ public class TestBtreeMapStore extends TestBase {
private
void
testRandom
()
{
private
void
testRandom
()
{
String
fileName
=
getBaseDir
()
+
"/testRandom.h3"
;
String
fileName
=
getBaseDir
()
+
"/testRandom.h3"
;
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
BtreeMap
Store
s
=
openStore
(
fileName
);
MV
Store
s
=
openStore
(
fileName
);
Btree
Map
<
Integer
,
Integer
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
Integer
.
class
);
MV
Map
<
Integer
,
Integer
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
Integer
.
class
);
TreeMap
<
Integer
,
Integer
>
map
=
new
TreeMap
<
Integer
,
Integer
>();
TreeMap
<
Integer
,
Integer
>
map
=
new
TreeMap
<
Integer
,
Integer
>();
Random
r
=
new
Random
(
1
);
Random
r
=
new
Random
(
1
);
int
operationCount
=
1000
;
int
operationCount
=
1000
;
...
@@ -560,14 +560,14 @@ public class TestBtreeMapStore extends TestBase {
...
@@ -560,14 +560,14 @@ public class TestBtreeMapStore extends TestBase {
private
void
testKeyValueClasses
()
{
private
void
testKeyValueClasses
()
{
String
fileName
=
getBaseDir
()
+
"/testKeyValueClasses.h3"
;
String
fileName
=
getBaseDir
()
+
"/testKeyValueClasses.h3"
;
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
BtreeMap
Store
s
=
openStore
(
fileName
);
MV
Store
s
=
openStore
(
fileName
);
Btree
Map
<
Integer
,
String
>
is
=
s
.
openMap
(
"intString"
,
Integer
.
class
,
String
.
class
);
MV
Map
<
Integer
,
String
>
is
=
s
.
openMap
(
"intString"
,
Integer
.
class
,
String
.
class
);
is
.
put
(
1
,
"Hello"
);
is
.
put
(
1
,
"Hello"
);
Btree
Map
<
Integer
,
Integer
>
ii
=
s
.
openMap
(
"intInt"
,
Integer
.
class
,
Integer
.
class
);
MV
Map
<
Integer
,
Integer
>
ii
=
s
.
openMap
(
"intInt"
,
Integer
.
class
,
Integer
.
class
);
ii
.
put
(
1
,
10
);
ii
.
put
(
1
,
10
);
Btree
Map
<
String
,
Integer
>
si
=
s
.
openMap
(
"stringInt"
,
String
.
class
,
Integer
.
class
);
MV
Map
<
String
,
Integer
>
si
=
s
.
openMap
(
"stringInt"
,
String
.
class
,
Integer
.
class
);
si
.
put
(
"Test"
,
10
);
si
.
put
(
"Test"
,
10
);
Btree
Map
<
String
,
String
>
ss
=
s
.
openMap
(
"stringString"
,
String
.
class
,
String
.
class
);
MV
Map
<
String
,
String
>
ss
=
s
.
openMap
(
"stringString"
,
String
.
class
,
String
.
class
);
ss
.
put
(
"Hello"
,
"World"
);
ss
.
put
(
"Hello"
,
"World"
);
try
{
try
{
s
.
openMap
(
"invalid"
,
Null
.
class
,
Integer
.
class
);
s
.
openMap
(
"invalid"
,
Null
.
class
,
Integer
.
class
);
...
@@ -598,8 +598,8 @@ public class TestBtreeMapStore extends TestBase {
...
@@ -598,8 +598,8 @@ public class TestBtreeMapStore extends TestBase {
private
void
testIterate
()
{
private
void
testIterate
()
{
String
fileName
=
getBaseDir
()
+
"/testIterate.h3"
;
String
fileName
=
getBaseDir
()
+
"/testIterate.h3"
;
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
BtreeMap
Store
s
=
openStore
(
fileName
);
MV
Store
s
=
openStore
(
fileName
);
Btree
Map
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
MV
Map
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
Iterator
<
Integer
>
it
=
m
.
keyIterator
(
null
);
Iterator
<
Integer
>
it
=
m
.
keyIterator
(
null
);
assertFalse
(
it
.
hasNext
());
assertFalse
(
it
.
hasNext
());
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
...
@@ -631,8 +631,8 @@ public class TestBtreeMapStore extends TestBase {
...
@@ -631,8 +631,8 @@ public class TestBtreeMapStore extends TestBase {
private
void
testSimple
()
{
private
void
testSimple
()
{
String
fileName
=
getBaseDir
()
+
"/testSimple.h3"
;
String
fileName
=
getBaseDir
()
+
"/testSimple.h3"
;
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
BtreeMap
Store
s
=
openStore
(
fileName
);
MV
Store
s
=
openStore
(
fileName
);
Btree
Map
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
MV
Map
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
m
.
put
(
i
,
"hello "
+
i
);
m
.
put
(
i
,
"hello "
+
i
);
}
}
...
@@ -655,8 +655,8 @@ public class TestBtreeMapStore extends TestBase {
...
@@ -655,8 +655,8 @@ public class TestBtreeMapStore extends TestBase {
s
.
close
();
s
.
close
();
}
}
protected
static
BtreeMap
Store
openStore
(
String
fileName
)
{
protected
static
MV
Store
openStore
(
String
fileName
)
{
BtreeMapStore
store
=
BtreeMap
Store
.
open
(
fileName
,
new
TestMapFactory
());
MVStore
store
=
MV
Store
.
open
(
fileName
,
new
TestMapFactory
());
store
.
setMaxPageSize
(
10
);
store
.
setMaxPageSize
(
10
);
return
store
;
return
store
;
}
}
...
...
h2/src/test/org/h2/test/store/TestMapFactory.java
浏览文件 @
5e703674
...
@@ -5,8 +5,8 @@
...
@@ -5,8 +5,8 @@
*/
*/
package
org
.
h2
.
test
.
store
;
package
org
.
h2
.
test
.
store
;
import
org.h2.dev.store.btree.
Btree
Map
;
import
org.h2.dev.store.btree.
MV
Map
;
import
org.h2.dev.store.btree.
BtreeMap
Store
;
import
org.h2.dev.store.btree.
MV
Store
;
import
org.h2.dev.store.btree.DataType
;
import
org.h2.dev.store.btree.DataType
;
import
org.h2.dev.store.btree.MapFactory
;
import
org.h2.dev.store.btree.MapFactory
;
import
org.h2.dev.store.btree.StringType
;
import
org.h2.dev.store.btree.StringType
;
...
@@ -17,7 +17,7 @@ import org.h2.dev.store.btree.StringType;
...
@@ -17,7 +17,7 @@ import org.h2.dev.store.btree.StringType;
public
class
TestMapFactory
implements
MapFactory
{
public
class
TestMapFactory
implements
MapFactory
{
@Override
@Override
public
<
K
,
V
>
BtreeMap
<
K
,
V
>
buildMap
(
String
mapType
,
BtreeMap
Store
store
,
public
<
K
,
V
>
MVMap
<
K
,
V
>
buildMap
(
String
mapType
,
MV
Store
store
,
int
id
,
String
name
,
DataType
keyType
,
DataType
valueType
,
int
id
,
String
name
,
DataType
keyType
,
DataType
valueType
,
long
createVersion
)
{
long
createVersion
)
{
if
(
mapType
.
equals
(
"s"
))
{
if
(
mapType
.
equals
(
"s"
))
{
...
...
h2/src/test/org/h2/test/store/TestRtree.java
浏览文件 @
5e703674
...
@@ -14,7 +14,7 @@ import java.util.Random;
...
@@ -14,7 +14,7 @@ import java.util.Random;
import
javax.imageio.ImageIO
;
import
javax.imageio.ImageIO
;
import
javax.imageio.ImageWriter
;
import
javax.imageio.ImageWriter
;
import
javax.imageio.stream.FileImageOutputStream
;
import
javax.imageio.stream.FileImageOutputStream
;
import
org.h2.dev.store.btree.
BtreeMap
Store
;
import
org.h2.dev.store.btree.
MV
Store
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.util.New
;
import
org.h2.util.New
;
...
@@ -22,7 +22,7 @@ import org.h2.util.New;
...
@@ -22,7 +22,7 @@ import org.h2.util.New;
/**
/**
* Tests the r-tree.
* Tests the r-tree.
*/
*/
public
class
TestRtree
extends
Test
BtreeMap
Store
{
public
class
TestRtree
extends
Test
MV
Store
{
/**
/**
* Run just this test.
* Run just this test.
...
@@ -43,7 +43,7 @@ public class TestRtree extends TestBtreeMapStore {
...
@@ -43,7 +43,7 @@ public class TestRtree extends TestBtreeMapStore {
private
void
testRtreeMany
()
{
private
void
testRtreeMany
()
{
String
fileName
=
getBaseDir
()
+
"/testRtree.h3"
;
String
fileName
=
getBaseDir
()
+
"/testRtree.h3"
;
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
BtreeMap
Store
s
;
MV
Store
s
;
s
=
openStore
(
fileName
);
s
=
openStore
(
fileName
);
// s.setMaxPageSize(50);
// s.setMaxPageSize(50);
RtreeMap
<
SpatialKey
,
String
>
r
=
s
.
openMap
(
"data"
,
"r"
,
"s2"
,
""
);
RtreeMap
<
SpatialKey
,
String
>
r
=
s
.
openMap
(
"data"
,
"r"
,
"s2"
,
""
);
...
@@ -106,7 +106,7 @@ public class TestRtree extends TestBtreeMapStore {
...
@@ -106,7 +106,7 @@ public class TestRtree extends TestBtreeMapStore {
private
void
testRtree
()
{
private
void
testRtree
()
{
String
fileName
=
getBaseDir
()
+
"/testRtree.h3"
;
String
fileName
=
getBaseDir
()
+
"/testRtree.h3"
;
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
BtreeMap
Store
s
;
MV
Store
s
;
s
=
openStore
(
fileName
);
s
=
openStore
(
fileName
);
RtreeMap
<
SpatialKey
,
String
>
r
=
s
.
openMap
(
"data"
,
"r"
,
"s2"
,
""
);
RtreeMap
<
SpatialKey
,
String
>
r
=
s
.
openMap
(
"data"
,
"r"
,
"s2"
,
""
);
add
(
r
,
"Bern"
,
46.57
,
7.27
,
124381
);
add
(
r
,
"Bern"
,
46.57
,
7.27
,
124381
);
...
@@ -198,7 +198,7 @@ public class TestRtree extends TestBtreeMapStore {
...
@@ -198,7 +198,7 @@ public class TestRtree extends TestBtreeMapStore {
private
void
testRandomRtree
()
{
private
void
testRandomRtree
()
{
String
fileName
=
getBaseDir
()
+
"/testRtreeRandom.h3"
;
String
fileName
=
getBaseDir
()
+
"/testRtreeRandom.h3"
;
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
BtreeMap
Store
s
=
openStore
(
fileName
);
MV
Store
s
=
openStore
(
fileName
);
RtreeMap
<
SpatialKey
,
String
>
m
=
s
.
openMap
(
"data"
,
"r"
,
"s2"
,
""
);
RtreeMap
<
SpatialKey
,
String
>
m
=
s
.
openMap
(
"data"
,
"r"
,
"s2"
,
""
);
HashMap
<
SpatialKey
,
String
>
map
=
new
HashMap
<
SpatialKey
,
String
>();
HashMap
<
SpatialKey
,
String
>
map
=
new
HashMap
<
SpatialKey
,
String
>();
Random
rand
=
new
Random
(
1
);
Random
rand
=
new
Random
(
1
);
...
@@ -240,7 +240,7 @@ public class TestRtree extends TestBtreeMapStore {
...
@@ -240,7 +240,7 @@ public class TestRtree extends TestBtreeMapStore {
private
void
testCustomMapType
()
{
private
void
testCustomMapType
()
{
String
fileName
=
getBaseDir
()
+
"/testMapType.h3"
;
String
fileName
=
getBaseDir
()
+
"/testMapType.h3"
;
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
BtreeMap
Store
s
;
MV
Store
s
;
s
=
openStore
(
fileName
);
s
=
openStore
(
fileName
);
SequenceMap
<
Integer
,
String
>
seq
=
s
.
openMap
(
"data"
,
"s"
,
"i"
,
""
);
SequenceMap
<
Integer
,
String
>
seq
=
s
.
openMap
(
"data"
,
"s"
,
"i"
,
""
);
StringBuilder
buff
=
new
StringBuilder
();
StringBuilder
buff
=
new
StringBuilder
();
...
...
h2/src/tools/org/h2/dev/store/btree/ChangeCursor.java
浏览文件 @
5e703674
...
@@ -16,7 +16,7 @@ public class ChangeCursor<K, V> extends Cursor<K, V> {
...
@@ -16,7 +16,7 @@ public class ChangeCursor<K, V> extends Cursor<K, V> {
private
final
long
minVersion
;
private
final
long
minVersion
;
ChangeCursor
(
Btree
Map
<
K
,
V
>
map
,
long
minVersion
)
{
ChangeCursor
(
MV
Map
<
K
,
V
>
map
,
long
minVersion
)
{
super
(
map
);
super
(
map
);
this
.
minVersion
=
minVersion
;
this
.
minVersion
=
minVersion
;
}
}
...
...
h2/src/tools/org/h2/dev/store/btree/Cursor.java
浏览文件 @
5e703674
...
@@ -17,12 +17,12 @@ import java.util.Iterator;
...
@@ -17,12 +17,12 @@ import java.util.Iterator;
*/
*/
public
class
Cursor
<
K
,
V
>
implements
Iterator
<
K
>
{
public
class
Cursor
<
K
,
V
>
implements
Iterator
<
K
>
{
protected
final
Btree
Map
<
K
,
V
>
map
;
protected
final
MV
Map
<
K
,
V
>
map
;
protected
final
ArrayList
<
CursorPos
>
parents
=
new
ArrayList
<
CursorPos
>();
protected
final
ArrayList
<
CursorPos
>
parents
=
new
ArrayList
<
CursorPos
>();
protected
CursorPos
currentPos
;
protected
CursorPos
currentPos
;
protected
K
current
;
protected
K
current
;
Cursor
(
Btree
Map
<
K
,
V
>
map
)
{
Cursor
(
MV
Map
<
K
,
V
>
map
)
{
this
.
map
=
map
;
this
.
map
=
map
;
}
}
...
...
h2/src/tools/org/h2/dev/store/btree/
Btree
Map.java
→
h2/src/tools/org/h2/dev/store/btree/
MV
Map.java
浏览文件 @
5e703674
...
@@ -17,9 +17,9 @@ import java.util.TreeMap;
...
@@ -17,9 +17,9 @@ import java.util.TreeMap;
* @param <K> the key class
* @param <K> the key class
* @param <V> the value class
* @param <V> the value class
*/
*/
public
class
Btree
Map
<
K
,
V
>
{
public
class
MV
Map
<
K
,
V
>
{
protected
final
BtreeMap
Store
store
;
protected
final
MV
Store
store
;
protected
Page
root
;
protected
Page
root
;
private
final
int
id
;
private
final
int
id
;
...
@@ -36,7 +36,7 @@ public class BtreeMap<K, V> {
...
@@ -36,7 +36,7 @@ public class BtreeMap<K, V> {
private
boolean
closed
;
private
boolean
closed
;
private
boolean
readOnly
;
private
boolean
readOnly
;
protected
BtreeMap
(
BtreeMap
Store
store
,
int
id
,
String
name
,
protected
MVMap
(
MV
Store
store
,
int
id
,
String
name
,
DataType
keyType
,
DataType
valueType
,
long
createVersion
)
{
DataType
keyType
,
DataType
valueType
,
long
createVersion
)
{
this
.
store
=
store
;
this
.
store
=
store
;
this
.
id
=
id
;
this
.
id
=
id
;
...
@@ -469,19 +469,19 @@ public class BtreeMap<K, V> {
...
@@ -469,19 +469,19 @@ public class BtreeMap<K, V> {
@Override
@Override
public
Iterator
<
K
>
iterator
()
{
public
Iterator
<
K
>
iterator
()
{
Cursor
<
K
,
V
>
c
=
new
Cursor
<
K
,
V
>(
Btree
Map
.
this
);
Cursor
<
K
,
V
>
c
=
new
Cursor
<
K
,
V
>(
MV
Map
.
this
);
c
.
start
(
root
,
null
);
c
.
start
(
root
,
null
);
return
c
;
return
c
;
}
}
@Override
@Override
public
int
size
()
{
public
int
size
()
{
return
Btree
Map
.
this
.
size
();
return
MV
Map
.
this
.
size
();
}
}
@Override
@Override
public
boolean
contains
(
Object
o
)
{
public
boolean
contains
(
Object
o
)
{
return
Btree
Map
.
this
.
containsKey
(
o
);
return
MV
Map
.
this
.
containsKey
(
o
);
}
}
};
};
...
@@ -505,7 +505,7 @@ public class BtreeMap<K, V> {
...
@@ -505,7 +505,7 @@ public class BtreeMap<K, V> {
return
name
;
return
name
;
}
}
BtreeMap
Store
getStore
()
{
MV
Store
getStore
()
{
return
store
;
return
store
;
}
}
...
@@ -597,7 +597,7 @@ public class BtreeMap<K, V> {
...
@@ -597,7 +597,7 @@ public class BtreeMap<K, V> {
store
.
removePage
(
p
.
getPos
());
store
.
removePage
(
p
.
getPos
());
}
}
public
Btree
Map
<
K
,
V
>
openVersion
(
long
version
)
{
public
MV
Map
<
K
,
V
>
openVersion
(
long
version
)
{
if
(
version
<
createVersion
)
{
if
(
version
<
createVersion
)
{
throw
new
IllegalArgumentException
(
"Unknown version"
);
throw
new
IllegalArgumentException
(
"Unknown version"
);
}
}
...
@@ -605,7 +605,7 @@ public class BtreeMap<K, V> {
...
@@ -605,7 +605,7 @@ public class BtreeMap<K, V> {
return
store
.
openMapVersion
(
version
,
name
);
return
store
.
openMapVersion
(
version
,
name
);
}
}
Page
root
=
oldRoots
.
get
(
version
);
Page
root
=
oldRoots
.
get
(
version
);
BtreeMap
<
K
,
V
>
m
=
new
Btree
Map
<
K
,
V
>(
store
,
id
,
name
,
keyType
,
valueType
,
createVersion
);
MVMap
<
K
,
V
>
m
=
new
MV
Map
<
K
,
V
>(
store
,
id
,
name
,
keyType
,
valueType
,
createVersion
);
m
.
readOnly
=
true
;
m
.
readOnly
=
true
;
m
.
root
=
root
;
m
.
root
=
root
;
return
m
;
return
m
;
...
...
h2/src/tools/org/h2/dev/store/btree/
BtreeMap
Store.java
→
h2/src/tools/org/h2/dev/store/btree/
MV
Store.java
浏览文件 @
5e703674
...
@@ -39,7 +39,6 @@ blockSize=4096
...
@@ -39,7 +39,6 @@ blockSize=4096
TODO:
TODO:
- implement complete java.util.Map interface
- implement complete java.util.Map interface
- maybe rename to MVStore, MVMap, TestMVStore
- limited support for writing to old versions (branches)
- limited support for writing to old versions (branches)
- 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)
...
@@ -63,7 +62,7 @@ TODO:
...
@@ -63,7 +62,7 @@ TODO:
/**
/**
* A persistent storage for tree maps.
* A persistent storage for tree maps.
*/
*/
public
class
BtreeMap
Store
{
public
class
MV
Store
{
public
static
final
boolean
ASSERT
=
false
;
public
static
final
boolean
ASSERT
=
false
;
...
@@ -92,13 +91,13 @@ public class BtreeMapStore {
...
@@ -92,13 +91,13 @@ public class BtreeMapStore {
*/
*/
private
HashMap
<
Long
,
HashMap
<
Integer
,
Chunk
>>
freedChunks
=
New
.
hashMap
();
private
HashMap
<
Long
,
HashMap
<
Integer
,
Chunk
>>
freedChunks
=
New
.
hashMap
();
private
Btree
Map
<
String
,
String
>
meta
;
private
MV
Map
<
String
,
String
>
meta
;
private
HashMap
<
String
,
Btree
Map
<?,
?>>
maps
=
New
.
hashMap
();
private
HashMap
<
String
,
MV
Map
<?,
?>>
maps
=
New
.
hashMap
();
/**
/**
* The set of maps with potentially unsaved changes.
* The set of maps with potentially unsaved changes.
*/
*/
private
HashMap
<
Integer
,
Btree
Map
<?,
?>>
mapsChanged
=
New
.
hashMap
();
private
HashMap
<
Integer
,
MV
Map
<?,
?>>
mapsChanged
=
New
.
hashMap
();
private
int
lastMapId
;
private
int
lastMapId
;
private
boolean
reuseSpace
=
true
;
private
boolean
reuseSpace
=
true
;
...
@@ -110,7 +109,7 @@ public class BtreeMapStore {
...
@@ -110,7 +109,7 @@ public class BtreeMapStore {
private
int
readCount
;
private
int
readCount
;
private
int
writeCount
;
private
int
writeCount
;
private
BtreeMap
Store
(
String
fileName
,
MapFactory
mapFactory
)
{
private
MV
Store
(
String
fileName
,
MapFactory
mapFactory
)
{
this
.
fileName
=
fileName
;
this
.
fileName
=
fileName
;
this
.
mapFactory
=
mapFactory
;
this
.
mapFactory
=
mapFactory
;
}
}
...
@@ -121,7 +120,7 @@ public class BtreeMapStore {
...
@@ -121,7 +120,7 @@ public class BtreeMapStore {
* @param fileName the file name
* @param fileName the file name
* @return the store
* @return the store
*/
*/
public
static
BtreeMap
Store
open
(
String
fileName
)
{
public
static
MV
Store
open
(
String
fileName
)
{
return
open
(
fileName
,
null
);
return
open
(
fileName
,
null
);
}
}
...
@@ -132,16 +131,16 @@ public class BtreeMapStore {
...
@@ -132,16 +131,16 @@ public class BtreeMapStore {
* @param mapFactory the map factory
* @param mapFactory the map factory
* @return the store
* @return the store
*/
*/
public
static
BtreeMap
Store
open
(
String
fileName
,
MapFactory
mapFactory
)
{
public
static
MV
Store
open
(
String
fileName
,
MapFactory
mapFactory
)
{
BtreeMapStore
s
=
new
BtreeMap
Store
(
fileName
,
mapFactory
);
MVStore
s
=
new
MV
Store
(
fileName
,
mapFactory
);
s
.
open
();
s
.
open
();
return
s
;
return
s
;
}
}
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
<
T
extends
Btree
Map
<?,
?>>
T
openMapVersion
(
long
version
,
String
name
)
{
<
T
extends
MV
Map
<?,
?>>
T
openMapVersion
(
long
version
,
String
name
)
{
// TODO reduce copy & pasted source code
// TODO reduce copy & pasted source code
Btree
Map
<
String
,
String
>
oldMeta
=
getMetaMap
(
version
);
MV
Map
<
String
,
String
>
oldMeta
=
getMetaMap
(
version
);
String
types
=
oldMeta
.
get
(
"map."
+
name
);
String
types
=
oldMeta
.
get
(
"map."
+
name
);
String
[]
idTypeList
=
StringUtils
.
arraySplit
(
types
,
'/'
,
false
);
String
[]
idTypeList
=
StringUtils
.
arraySplit
(
types
,
'/'
,
false
);
int
id
=
Integer
.
parseInt
(
idTypeList
[
0
]);
int
id
=
Integer
.
parseInt
(
idTypeList
[
0
]);
...
@@ -151,7 +150,7 @@ public class BtreeMapStore {
...
@@ -151,7 +150,7 @@ public class BtreeMapStore {
String
valueType
=
idTypeList
[
4
];
String
valueType
=
idTypeList
[
4
];
String
r
=
oldMeta
.
get
(
"root."
+
id
);
String
r
=
oldMeta
.
get
(
"root."
+
id
);
long
root
=
r
==
null
?
0
:
Long
.
parseLong
(
r
);
long
root
=
r
==
null
?
0
:
Long
.
parseLong
(
r
);
Btree
Map
<?,
?>
m
=
buildMap
(
mapType
,
id
,
name
,
keyType
,
valueType
,
createVersion
);
MV
Map
<?,
?>
m
=
buildMap
(
mapType
,
id
,
name
,
keyType
,
valueType
,
createVersion
);
m
.
setRootPos
(
root
);
m
.
setRootPos
(
root
);
return
(
T
)
m
;
return
(
T
)
m
;
}
}
...
@@ -167,8 +166,8 @@ public class BtreeMapStore {
...
@@ -167,8 +166,8 @@ public class BtreeMapStore {
* @return the map
* @return the map
*/
*/
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
public
<
T
extends
Btree
Map
<?,
?>>
T
openMap
(
String
name
,
String
mapType
,
String
keyType
,
String
valueType
)
{
public
<
T
extends
MV
Map
<?,
?>>
T
openMap
(
String
name
,
String
mapType
,
String
keyType
,
String
valueType
)
{
Btree
Map
<?,
?>
m
=
maps
.
get
(
name
);
MV
Map
<?,
?>
m
=
maps
.
get
(
name
);
if
(
m
==
null
)
{
if
(
m
==
null
)
{
String
identifier
=
meta
.
get
(
"map."
+
name
);
String
identifier
=
meta
.
get
(
"map."
+
name
);
int
id
;
int
id
;
...
@@ -198,11 +197,11 @@ public class BtreeMapStore {
...
@@ -198,11 +197,11 @@ public class BtreeMapStore {
return
(
T
)
m
;
return
(
T
)
m
;
}
}
private
Btree
Map
<?,
?>
buildMap
(
String
mapType
,
int
id
,
String
name
,
String
keyType
,
String
valueType
,
long
createVersion
)
{
private
MV
Map
<?,
?>
buildMap
(
String
mapType
,
int
id
,
String
name
,
String
keyType
,
String
valueType
,
long
createVersion
)
{
DataType
k
=
buildDataType
(
keyType
);
DataType
k
=
buildDataType
(
keyType
);
DataType
v
=
buildDataType
(
valueType
);
DataType
v
=
buildDataType
(
valueType
);
if
(
mapType
.
equals
(
""
))
{
if
(
mapType
.
equals
(
""
))
{
return
new
Btree
Map
<
Object
,
Object
>(
this
,
id
,
name
,
k
,
v
,
createVersion
);
return
new
MV
Map
<
Object
,
Object
>(
this
,
id
,
name
,
k
,
v
,
createVersion
);
}
}
return
getMapFactory
().
buildMap
(
mapType
,
this
,
id
,
name
,
k
,
v
,
createVersion
);
return
getMapFactory
().
buildMap
(
mapType
,
this
,
id
,
name
,
k
,
v
,
createVersion
);
}
}
...
@@ -218,18 +217,18 @@ public class BtreeMapStore {
...
@@ -218,18 +217,18 @@ public class BtreeMapStore {
*
*
* @return the metadata map
* @return the metadata map
*/
*/
public
Btree
Map
<
String
,
String
>
getMetaMap
()
{
public
MV
Map
<
String
,
String
>
getMetaMap
()
{
return
meta
;
return
meta
;
}
}
private
Btree
Map
<
String
,
String
>
getMetaMap
(
long
version
)
{
private
MV
Map
<
String
,
String
>
getMetaMap
(
long
version
)
{
Chunk
c
=
getChunkForVersion
(
version
);
Chunk
c
=
getChunkForVersion
(
version
);
if
(
c
==
null
)
{
if
(
c
==
null
)
{
throw
new
IllegalArgumentException
(
"Unknown version: "
+
version
);
throw
new
IllegalArgumentException
(
"Unknown version: "
+
version
);
}
}
// TODO avoid duplicate code
// TODO avoid duplicate code
c
=
readChunkHeader
(
c
.
start
);
c
=
readChunkHeader
(
c
.
start
);
BtreeMap
<
String
,
String
>
oldMeta
=
new
Btree
Map
<
String
,
String
>(
this
,
0
,
"old-meta"
,
STRING_TYPE
,
STRING_TYPE
,
0
);
MVMap
<
String
,
String
>
oldMeta
=
new
MV
Map
<
String
,
String
>(
this
,
0
,
"old-meta"
,
STRING_TYPE
,
STRING_TYPE
,
0
);
oldMeta
.
setRootPos
(
c
.
metaRootPos
);
oldMeta
.
setRootPos
(
c
.
metaRootPos
);
return
oldMeta
;
return
oldMeta
;
}
}
...
@@ -255,16 +254,16 @@ public class BtreeMapStore {
...
@@ -255,16 +254,16 @@ public class BtreeMapStore {
* @param valueClass the value class
* @param valueClass the value class
* @return the map
* @return the map
*/
*/
public
<
K
,
V
>
Btree
Map
<
K
,
V
>
openMap
(
String
name
,
Class
<
K
>
keyClass
,
Class
<
V
>
valueClass
)
{
public
<
K
,
V
>
MV
Map
<
K
,
V
>
openMap
(
String
name
,
Class
<
K
>
keyClass
,
Class
<
V
>
valueClass
)
{
String
keyType
=
getDataType
(
keyClass
);
String
keyType
=
getDataType
(
keyClass
);
String
valueType
=
getDataType
(
valueClass
);
String
valueType
=
getDataType
(
valueClass
);
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
BtreeMap
<
K
,
V
>
m
=
(
Btree
Map
<
K
,
V
>)
openMap
(
name
,
""
,
keyType
,
valueType
);
MVMap
<
K
,
V
>
m
=
(
MV
Map
<
K
,
V
>)
openMap
(
name
,
""
,
keyType
,
valueType
);
return
m
;
return
m
;
}
}
void
removeMap
(
String
name
)
{
void
removeMap
(
String
name
)
{
Btree
Map
<?,
?>
m
=
maps
.
remove
(
name
);
MV
Map
<?,
?>
m
=
maps
.
remove
(
name
);
mapsChanged
.
remove
(
m
);
mapsChanged
.
remove
(
m
);
}
}
...
@@ -294,12 +293,12 @@ public class BtreeMapStore {
...
@@ -294,12 +293,12 @@ public class BtreeMapStore {
*
*
* @param map the map
* @param map the map
*/
*/
void
markChanged
(
Btree
Map
<?,
?>
map
)
{
void
markChanged
(
MV
Map
<?,
?>
map
)
{
mapsChanged
.
put
(
map
.
getId
(),
map
);
mapsChanged
.
put
(
map
.
getId
(),
map
);
}
}
private
void
open
()
{
private
void
open
()
{
meta
=
new
Btree
Map
<
String
,
String
>(
this
,
0
,
"meta"
,
STRING_TYPE
,
STRING_TYPE
,
0
);
meta
=
new
MV
Map
<
String
,
String
>(
this
,
0
,
"meta"
,
STRING_TYPE
,
STRING_TYPE
,
0
);
if
(
fileName
==
null
)
{
if
(
fileName
==
null
)
{
return
;
return
;
}
}
...
@@ -391,7 +390,7 @@ public class BtreeMapStore {
...
@@ -391,7 +390,7 @@ public class BtreeMapStore {
try
{
try
{
log
(
"file close"
);
log
(
"file close"
);
file
.
close
();
file
.
close
();
for
(
Btree
Map
<?,
?>
m
:
New
.
arrayList
(
maps
.
values
()))
{
for
(
MV
Map
<?,
?>
m
:
New
.
arrayList
(
maps
.
values
()))
{
m
.
close
();
m
.
close
();
}
}
meta
=
null
;
meta
=
null
;
...
@@ -473,7 +472,7 @@ public class BtreeMapStore {
...
@@ -473,7 +472,7 @@ public class BtreeMapStore {
}
}
int
count
=
0
;
int
count
=
0
;
int
maxLength
=
1
+
4
+
4
+
8
;
int
maxLength
=
1
+
4
+
4
+
8
;
for
(
Btree
Map
<?,
?>
m
:
mapsChanged
.
values
())
{
for
(
MV
Map
<?,
?>
m
:
mapsChanged
.
values
())
{
if
(
m
==
meta
||
!
m
.
hasUnsavedChanges
())
{
if
(
m
==
meta
||
!
m
.
hasUnsavedChanges
())
{
continue
;
continue
;
}
}
...
@@ -495,7 +494,7 @@ public class BtreeMapStore {
...
@@ -495,7 +494,7 @@ public class BtreeMapStore {
buff
.
putInt
(
0
);
buff
.
putInt
(
0
);
buff
.
putInt
(
0
);
buff
.
putInt
(
0
);
buff
.
putLong
(
0
);
buff
.
putLong
(
0
);
for
(
Btree
Map
<?,
?>
m
:
mapsChanged
.
values
())
{
for
(
MV
Map
<?,
?>
m
:
mapsChanged
.
values
())
{
if
(
m
==
meta
||
!
m
.
hasUnsavedChanges
())
{
if
(
m
==
meta
||
!
m
.
hasUnsavedChanges
())
{
continue
;
continue
;
}
}
...
@@ -627,7 +626,7 @@ public class BtreeMapStore {
...
@@ -627,7 +626,7 @@ public class BtreeMapStore {
if
(
mapsChanged
.
size
()
==
0
)
{
if
(
mapsChanged
.
size
()
==
0
)
{
return
false
;
return
false
;
}
}
for
(
Btree
Map
<?,
?>
m
:
mapsChanged
.
values
())
{
for
(
MV
Map
<?,
?>
m
:
mapsChanged
.
values
())
{
if
(
m
.
hasUnsavedChanges
())
{
if
(
m
.
hasUnsavedChanges
())
{
return
true
;
return
true
;
}
}
...
@@ -755,7 +754,7 @@ public class BtreeMapStore {
...
@@ -755,7 +754,7 @@ public class BtreeMapStore {
// to ensure a chunk will be written
// to ensure a chunk will be written
// (even if there is nothing to move)
// (even if there is nothing to move)
meta
.
put
(
"chunk."
+
move
.
id
,
move
.
toString
());
meta
.
put
(
"chunk."
+
move
.
id
,
move
.
toString
());
BtreeMap
<
String
,
String
>
oldMeta
=
new
Btree
Map
<
String
,
String
>(
this
,
0
,
"old-meta"
,
STRING_TYPE
,
STRING_TYPE
,
0
);
MVMap
<
String
,
String
>
oldMeta
=
new
MV
Map
<
String
,
String
>(
this
,
0
,
"old-meta"
,
STRING_TYPE
,
STRING_TYPE
,
0
);
oldMeta
.
setRootPos
(
move
.
metaRootPos
);
oldMeta
.
setRootPos
(
move
.
metaRootPos
);
Iterator
<
String
>
it
=
oldMeta
.
keyIterator
(
"map."
);
Iterator
<
String
>
it
=
oldMeta
.
keyIterator
(
"map."
);
while
(
it
.
hasNext
())
{
while
(
it
.
hasNext
())
{
...
@@ -766,7 +765,7 @@ public class BtreeMapStore {
...
@@ -766,7 +765,7 @@ public class BtreeMapStore {
String
s
=
oldMeta
.
get
(
k
);
String
s
=
oldMeta
.
get
(
k
);
k
=
k
.
substring
(
"map."
.
length
());
k
=
k
.
substring
(
"map."
.
length
());
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
BtreeMap
<
Object
,
Object
>
data
=
(
Btree
Map
<
Object
,
Object
>)
maps
.
get
(
k
);
MVMap
<
Object
,
Object
>
data
=
(
MV
Map
<
Object
,
Object
>)
maps
.
get
(
k
);
if
(
data
==
null
)
{
if
(
data
==
null
)
{
continue
;
continue
;
}
}
...
@@ -777,7 +776,7 @@ public class BtreeMapStore {
...
@@ -777,7 +776,7 @@ public class BtreeMapStore {
DataType
vt
=
buildDataType
(
idTypeList
[
4
]);
DataType
vt
=
buildDataType
(
idTypeList
[
4
]);
long
oldDataRoot
=
Long
.
parseLong
(
oldMeta
.
get
(
"root."
+
id
));
long
oldDataRoot
=
Long
.
parseLong
(
oldMeta
.
get
(
"root."
+
id
));
if
(
oldDataRoot
!=
0
)
{
if
(
oldDataRoot
!=
0
)
{
BtreeMap
<?,
?>
oldData
=
new
Btree
Map
<
Object
,
Object
>(
this
,
id
,
"old-"
+
k
,
kt
,
vt
,
0
);
MVMap
<?,
?>
oldData
=
new
MV
Map
<
Object
,
Object
>(
this
,
id
,
"old-"
+
k
,
kt
,
vt
,
0
);
oldData
.
setRootPos
(
oldDataRoot
);
oldData
.
setRootPos
(
oldDataRoot
);
Iterator
<?>
dataIt
=
oldData
.
keyIterator
(
null
);
Iterator
<?>
dataIt
=
oldData
.
keyIterator
(
null
);
while
(
dataIt
.
hasNext
())
{
while
(
dataIt
.
hasNext
())
{
...
@@ -812,7 +811,7 @@ public class BtreeMapStore {
...
@@ -812,7 +811,7 @@ public class BtreeMapStore {
* @param pos the page position
* @param pos the page position
* @return the page
* @return the page
*/
*/
Page
readPage
(
Btree
Map
<?,
?>
map
,
long
pos
)
{
Page
readPage
(
MV
Map
<?,
?>
map
,
long
pos
)
{
Page
p
=
cache
.
get
(
pos
);
Page
p
=
cache
.
get
(
pos
);
if
(
p
==
null
)
{
if
(
p
==
null
)
{
long
filePos
=
getFilePosition
(
pos
);
long
filePos
=
getFilePosition
(
pos
);
...
@@ -926,7 +925,7 @@ public class BtreeMapStore {
...
@@ -926,7 +925,7 @@ public class BtreeMapStore {
}
}
// also, all check referenced by this version
// also, all check referenced by this version
// need to be available in the file
// need to be available in the file
Btree
Map
<
String
,
String
>
oldMeta
=
getMetaMap
(
version
);
MV
Map
<
String
,
String
>
oldMeta
=
getMetaMap
(
version
);
if
(
oldMeta
==
null
)
{
if
(
oldMeta
==
null
)
{
return
false
;
return
false
;
}
}
...
@@ -954,7 +953,7 @@ public class BtreeMapStore {
...
@@ -954,7 +953,7 @@ public class BtreeMapStore {
throw
new
IllegalArgumentException
(
"Unknown version: "
+
version
);
throw
new
IllegalArgumentException
(
"Unknown version: "
+
version
);
}
}
// TODO could remove newer temporary pages on rollback
// TODO could remove newer temporary pages on rollback
for
(
Btree
Map
<?,
?>
m
:
mapsChanged
.
values
())
{
for
(
MV
Map
<?,
?>
m
:
mapsChanged
.
values
())
{
m
.
rollbackTo
(
version
);
m
.
rollbackTo
(
version
);
}
}
for
(
long
v
=
currentVersion
;
v
>=
version
;
v
--)
{
for
(
long
v
=
currentVersion
;
v
>=
version
;
v
--)
{
...
@@ -983,7 +982,7 @@ public class BtreeMapStore {
...
@@ -983,7 +982,7 @@ public class BtreeMapStore {
readMeta
();
readMeta
();
}
}
}
}
for
(
Btree
Map
<?,
?>
m
:
maps
.
values
())
{
for
(
MV
Map
<?,
?>
m
:
maps
.
values
())
{
if
(
m
.
getCreateVersion
()
>
version
)
{
if
(
m
.
getCreateVersion
()
>
version
)
{
m
.
close
();
m
.
close
();
removeMap
(
m
.
getName
());
removeMap
(
m
.
getName
());
...
@@ -1000,7 +999,7 @@ public class BtreeMapStore {
...
@@ -1000,7 +999,7 @@ public class BtreeMapStore {
private
void
revertTemp
()
{
private
void
revertTemp
()
{
freedChunks
.
clear
();
freedChunks
.
clear
();
for
(
Btree
Map
<?,
?>
m
:
mapsChanged
.
values
())
{
for
(
MV
Map
<?,
?>
m
:
mapsChanged
.
values
())
{
m
.
revertTemp
();
m
.
revertTemp
();
}
}
mapsChanged
.
clear
();
mapsChanged
.
clear
();
...
...
h2/src/tools/org/h2/dev/store/btree/MapFactory.java
浏览文件 @
5e703674
...
@@ -23,8 +23,8 @@ public interface MapFactory {
...
@@ -23,8 +23,8 @@ public interface MapFactory {
* @param createVersion when the map was created
* @param createVersion when the map was created
* @return the map
* @return the map
*/
*/
<
K
,
V
>
Btree
Map
<
K
,
V
>
buildMap
(
<
K
,
V
>
MV
Map
<
K
,
V
>
buildMap
(
String
mapType
,
BtreeMap
Store
store
,
int
id
,
String
name
,
String
mapType
,
MV
Store
store
,
int
id
,
String
name
,
DataType
keyType
,
DataType
valueType
,
long
createVersion
);
DataType
keyType
,
DataType
valueType
,
long
createVersion
);
/**
/**
...
...
h2/src/tools/org/h2/dev/store/btree/Page.java
浏览文件 @
5e703674
...
@@ -27,7 +27,7 @@ public class Page {
...
@@ -27,7 +27,7 @@ public class Page {
private
static
final
int
SHARED_KEYS
=
1
,
SHARED_VALUES
=
2
,
SHARED_CHILDREN
=
4
,
SHARED_COUNTS
=
8
;
private
static
final
int
SHARED_KEYS
=
1
,
SHARED_VALUES
=
2
,
SHARED_CHILDREN
=
4
,
SHARED_COUNTS
=
8
;
private
final
Btree
Map
<?,
?>
map
;
private
final
MV
Map
<?,
?>
map
;
private
final
long
version
;
private
final
long
version
;
private
long
pos
;
private
long
pos
;
private
long
totalCount
;
private
long
totalCount
;
...
@@ -49,7 +49,7 @@ public class Page {
...
@@ -49,7 +49,7 @@ public class Page {
private
Page
[]
childrenPages
;
private
Page
[]
childrenPages
;
private
long
[]
counts
;
private
long
[]
counts
;
private
Page
(
Btree
Map
<?,
?>
map
,
long
version
)
{
private
Page
(
MV
Map
<?,
?>
map
,
long
version
)
{
this
.
map
=
map
;
this
.
map
=
map
;
this
.
version
=
version
;
this
.
version
=
version
;
}
}
...
@@ -64,7 +64,7 @@ public class Page {
...
@@ -64,7 +64,7 @@ public class Page {
* @param children the children
* @param children the children
* @return the page
* @return the page
*/
*/
public
static
Page
create
(
Btree
Map
<?,
?>
map
,
long
version
,
public
static
Page
create
(
MV
Map
<?,
?>
map
,
long
version
,
int
keyCount
,
Object
[]
keys
,
int
keyCount
,
Object
[]
keys
,
Object
[]
values
,
long
[]
children
,
Page
[]
childrenPages
,
long
[]
counts
,
Object
[]
values
,
long
[]
children
,
Page
[]
childrenPages
,
long
[]
counts
,
long
totalCount
,
int
sharedFlags
)
{
long
totalCount
,
int
sharedFlags
)
{
...
@@ -89,7 +89,7 @@ public class Page {
...
@@ -89,7 +89,7 @@ public class Page {
* @param buff the source buffer
* @param buff the source buffer
* @return the page
* @return the page
*/
*/
static
Page
read
(
FileChannel
file
,
Btree
Map
<?,
?>
map
,
static
Page
read
(
FileChannel
file
,
MV
Map
<?,
?>
map
,
long
filePos
,
long
pos
)
{
long
filePos
,
long
pos
)
{
int
maxLength
=
DataUtils
.
getPageMaxLength
(
pos
),
length
=
maxLength
;
int
maxLength
=
DataUtils
.
getPageMaxLength
(
pos
),
length
=
maxLength
;
ByteBuffer
buff
;
ByteBuffer
buff
;
...
@@ -300,7 +300,7 @@ public class Page {
...
@@ -300,7 +300,7 @@ public class Page {
}
}
public
long
getTotalCount
()
{
public
long
getTotalCount
()
{
if
(
BtreeMap
Store
.
ASSERT
)
{
if
(
MV
Store
.
ASSERT
)
{
long
check
=
0
;
long
check
=
0
;
if
(
isLeaf
())
{
if
(
isLeaf
())
{
check
=
keyCount
;
check
=
keyCount
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论