Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
a73b01fb
提交
a73b01fb
authored
11 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MVStore: error codes; fix MVRTreeMap iterators
上级
9097e2ee
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
96 行增加
和
23 行删除
+96
-23
TestMVRTree.java
h2/src/test/org/h2/test/store/TestMVRTree.java
+72
-3
TestMVStore.java
h2/src/test/org/h2/test/store/TestMVStore.java
+5
-2
TestMVTableEngine.java
h2/src/test/org/h2/test/store/TestMVTableEngine.java
+19
-18
没有找到文件。
h2/src/test/org/h2/test/store/TestMVRTree.java
浏览文件 @
a73b01fb
...
...
@@ -51,6 +51,7 @@ public class TestMVRTree extends TestMVStore {
testMany
();
testSimple
();
testRandom
();
testRandomFind
();
}
private
void
testExample
()
{
...
...
@@ -272,6 +273,51 @@ public class TestMVRTree extends TestMVStore {
testRandom
(
true
);
testRandom
(
false
);
}
private
void
testRandomFind
()
{
MVStore
s
=
openStore
(
null
);
MVRTreeMap
<
Integer
>
m
=
s
.
openMap
(
"data"
,
new
MVRTreeMap
.
Builder
<
Integer
>());
int
max
=
100
;
for
(
int
x
=
0
;
x
<
max
;
x
++)
{
for
(
int
y
=
0
;
y
<
max
;
y
++)
{
int
id
=
x
*
max
+
y
;
SpatialKey
k
=
new
SpatialKey
(
id
,
x
,
x
,
y
,
y
);
m
.
put
(
k
,
id
);
}
}
Random
rand
=
new
Random
(
1
);
int
operationCount
=
1000
;
for
(
int
i
=
0
;
i
<
operationCount
;
i
++)
{
int
x1
=
rand
.
nextInt
(
max
),
y1
=
rand
.
nextInt
(
10
);
int
x2
=
rand
.
nextInt
(
10
),
y2
=
rand
.
nextInt
(
10
);
int
intersecting
=
Math
.
max
(
0
,
x2
-
x1
+
1
)
*
Math
.
max
(
0
,
y2
-
y1
+
1
);
int
contained
=
Math
.
max
(
0
,
x2
-
x1
-
1
)
*
Math
.
max
(
0
,
y2
-
y1
-
1
);
SpatialKey
k
=
new
SpatialKey
(
0
,
x1
,
x2
,
y1
,
y2
);
Iterator
<
SpatialKey
>
it
=
m
.
findContainedKeys
(
k
);
int
count
=
0
;
while
(
it
.
hasNext
())
{
SpatialKey
t
=
it
.
next
();
assertTrue
(
t
.
min
(
0
)
>
x1
);
assertTrue
(
t
.
min
(
1
)
>
y1
);
assertTrue
(
t
.
max
(
0
)
<
x2
);
assertTrue
(
t
.
max
(
1
)
<
y2
);
count
++;
}
assertEquals
(
contained
,
count
);
it
=
m
.
findIntersectingKeys
(
k
);
count
=
0
;
while
(
it
.
hasNext
())
{
SpatialKey
t
=
it
.
next
();
assertTrue
(
t
.
min
(
0
)
>=
x1
);
assertTrue
(
t
.
min
(
1
)
>=
y1
);
assertTrue
(
t
.
max
(
0
)
<=
x2
);
assertTrue
(
t
.
max
(
1
)
<=
y2
);
count
++;
}
assertEquals
(
intersecting
,
count
);
}
}
private
void
testRandom
(
boolean
quadraticSplit
)
{
String
fileName
=
getBaseDir
()
+
"/testRandom.h3"
;
...
...
@@ -284,8 +330,8 @@ public class TestMVRTree extends TestMVStore {
m
.
setQuadraticSplit
(
quadraticSplit
);
HashMap
<
SpatialKey
,
String
>
map
=
new
HashMap
<
SpatialKey
,
String
>();
Random
rand
=
new
Random
(
1
);
int
operationCount
=
1000
;
int
maxValue
=
30
;
int
operationCount
=
1000
0
;
int
maxValue
=
30
0
;
for
(
int
i
=
0
;
i
<
operationCount
;
i
++)
{
int
key
=
rand
.
nextInt
(
maxValue
);
Random
rk
=
new
Random
(
key
);
...
...
@@ -293,7 +339,8 @@ public class TestMVRTree extends TestMVStore {
float
p
=
(
float
)
(
rk
.
nextFloat
()
*
0.000001
);
SpatialKey
k
=
new
SpatialKey
(
key
,
x
-
p
,
x
+
p
,
y
-
p
,
y
+
p
);
String
v
=
""
+
rand
.
nextInt
();
switch
(
rand
.
nextInt
(
3
))
{
Iterator
<
SpatialKey
>
it
;
switch
(
rand
.
nextInt
(
5
))
{
case
0
:
log
(
i
+
": put "
+
k
+
" = "
+
v
+
" "
+
m
.
size
());
m
.
put
(
k
,
v
);
...
...
@@ -304,6 +351,28 @@ public class TestMVRTree extends TestMVStore {
m
.
remove
(
k
);
map
.
remove
(
k
);
break
;
case
2
:
{
p
=
(
float
)
(
rk
.
nextFloat
()
*
0.01
);
k
=
new
SpatialKey
(
key
,
x
-
p
,
x
+
p
,
y
-
p
,
y
+
p
);
it
=
m
.
findIntersectingKeys
(
k
);
while
(
it
.
hasNext
())
{
SpatialKey
n
=
it
.
next
();
String
a
=
map
.
get
(
n
);
assertFalse
(
a
==
null
);
}
break
;
}
case
3
:
{
p
=
(
float
)
(
rk
.
nextFloat
()
*
0.01
);
k
=
new
SpatialKey
(
key
,
x
-
p
,
x
+
p
,
y
-
p
,
y
+
p
);
it
=
m
.
findContainedKeys
(
k
);
while
(
it
.
hasNext
())
{
SpatialKey
n
=
it
.
next
();
String
a
=
map
.
get
(
n
);
assertFalse
(
a
==
null
);
}
break
;
}
default
:
String
a
=
map
.
get
(
k
);
String
b
=
m
.
get
(
k
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/store/TestMVStore.java
浏览文件 @
a73b01fb
...
...
@@ -14,6 +14,7 @@ import java.util.Random;
import
java.util.TreeMap
;
import
org.h2.mvstore.Cursor
;
import
org.h2.mvstore.DataUtils
;
import
org.h2.mvstore.MVMap
;
import
org.h2.mvstore.MVStore
;
import
org.h2.mvstore.type.DataType
;
...
...
@@ -265,7 +266,8 @@ public class TestMVStore extends TestBase {
encryptionKey
(
passwordChars
).
open
();
fail
();
}
catch
(
IllegalStateException
e
)
{
assertTrue
(
e
.
getCause
()
!=
null
);
assertEquals
(
DataUtils
.
ERROR_FILE_CORRUPT
,
DataUtils
.
getErrorCode
(
e
.
getMessage
()));
}
assertEquals
(
0
,
passwordChars
[
0
]);
assertEquals
(
0
,
passwordChars
[
1
]);
...
...
@@ -303,7 +305,8 @@ public class TestMVStore extends TestBase {
openStore
(
fileName
).
close
();
fail
();
}
catch
(
IllegalStateException
e
)
{
assertTrue
(
e
.
getCause
()
!=
null
);
assertEquals
(
DataUtils
.
ERROR_UNSUPPORTED_FORMAT
,
DataUtils
.
getErrorCode
(
e
.
getMessage
()));
}
FileUtils
.
delete
(
fileName
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/store/TestMVTableEngine.java
浏览文件 @
a73b01fb
...
...
@@ -27,6 +27,7 @@ import org.h2.tools.DeleteDbFiles;
import
org.h2.tools.Recover
;
import
org.h2.tools.Restore
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.Profiler
;
import
org.h2.util.Task
;
/**
...
...
@@ -72,13 +73,13 @@ public class TestMVTableEngine extends TestBase {
// dbName += ";LOG=0";
testSpeed
(
dbName
);
int
test
;
//
Profiler prof = new Profiler().startCollecting();
Profiler
prof
=
new
Profiler
().
startCollecting
();
dbName
=
"mvstore"
+
";
DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine
"
;
";
MV_STORE=TRUE
"
;
dbName
+=
";LOCK_MODE=0"
;
dbName
+=
";LOG=0"
;
testSpeed
(
dbName
);
//
System.out.println(prof.getTop(10));
System
.
out
.
println
(
prof
.
getTop
(
10
));
}
FileUtils
.
deleteRecursive
(
getBaseDir
(),
true
);
}
...
...
@@ -122,7 +123,7 @@ int test;
FileUtils
.
deleteRecursive
(
getBaseDir
(),
true
);
Connection
conn
;
Statement
stat
;
String
url
=
"mvstore;
default_table_engine=org.h2.mvstore.db.MVTableEngine
"
;
String
url
=
"mvstore;
MV_STORE=TRUE
"
;
url
=
getURL
(
url
,
true
);
conn
=
getConnection
(
url
);
stat
=
conn
.
createStatement
();
...
...
@@ -152,7 +153,7 @@ int test;
FileUtils
.
deleteRecursive
(
getBaseDir
(),
true
);
Connection
conn
;
Statement
stat
;
String
url
=
"mvstore;
default_table_engine=org.h2.mvstore.db.MVTableEngine
"
;
String
url
=
"mvstore;
MV_STORE=TRUE
"
;
conn
=
getConnection
(
url
);
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id identity)"
);
...
...
@@ -168,7 +169,7 @@ int test;
Connection
conn
;
Statement
stat
;
String
url
=
"mvstore;
default_table_engine=org.h2.mvstore.db.MVTableEngine
"
;
String
url
=
"mvstore;
MV_STORE=TRUE
"
;
conn
=
getConnection
(
url
);
stat
=
conn
.
createStatement
();
...
...
@@ -194,8 +195,8 @@ int test;
Connection
conn
;
Statement
stat
;
String
url
=
"mvstore;
default_table_engine=org.h2.mvstore.db.MVTableEngine
"
;
String
url2
=
"mvstore2;
default_table_engine=org.h2.mvstore.db.MVTableEngine
"
;
String
url
=
"mvstore;
MV_STORE=TRUE
"
;
String
url2
=
"mvstore2;
MV_STORE=TRUE
"
;
conn
=
getConnection
(
url
);
stat
=
conn
.
createStatement
();
...
...
@@ -206,7 +207,7 @@ int test;
stat
.
execute
(
"insert into test values(1)"
);
stat
.
execute
(
"shutdown immediately"
);
JdbcUtils
.
closeSilently
(
conn
);
conn
=
getConnection
(
url
);
stat
=
conn
.
createStatement
();
ResultSet
rs
=
stat
.
executeQuery
(
"select row_count_estimate "
+
...
...
@@ -252,7 +253,7 @@ int test;
Connection
conn
;
Statement
stat
;
conn
=
getConnection
(
"mvstore;
default_table_engine=org.h2.mvstore.db.MVTableEngine
"
);
conn
=
getConnection
(
"mvstore;
MV_STORE=TRUE
"
);
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(id int, parent int "
+
...
...
@@ -394,7 +395,7 @@ int test;
private
void
testBlob
()
throws
SQLException
,
IOException
{
FileUtils
.
deleteRecursive
(
getBaseDir
(),
true
);
String
dbName
=
"mvstore"
+
";
DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine
"
;
";
MV_STORE=TRUE
"
;
Connection
conn
;
Statement
stat
;
conn
=
getConnection
(
dbName
);
...
...
@@ -422,7 +423,7 @@ int test;
private
void
testEncryption
()
throws
Exception
{
FileUtils
.
deleteRecursive
(
getBaseDir
(),
true
);
String
dbName
=
"mvstore"
+
";
DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine
"
;
";
MV_STORE=TRUE
"
;
Connection
conn
;
Statement
stat
;
String
url
=
getURL
(
dbName
+
";CIPHER=AES"
,
true
);
...
...
@@ -443,7 +444,7 @@ int test;
private
void
testExclusiveLock
()
throws
Exception
{
FileUtils
.
deleteRecursive
(
getBaseDir
(),
true
);
String
dbName
=
"mvstore"
+
";
DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine
"
;
";
MV_STORE=TRUE
"
;
Connection
conn
,
conn2
;
Statement
stat
,
stat2
;
conn
=
getConnection
(
dbName
);
...
...
@@ -467,7 +468,7 @@ int test;
private
void
testReadOnly
()
throws
Exception
{
FileUtils
.
deleteRecursive
(
getBaseDir
(),
true
);
String
dbName
=
"mvstore"
+
";
DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine
"
;
";
MV_STORE=TRUE
"
;
Connection
conn
;
Statement
stat
;
conn
=
getConnection
(
dbName
);
...
...
@@ -485,7 +486,7 @@ int test;
private
void
testReuseDiskSpace
()
throws
Exception
{
FileUtils
.
deleteRecursive
(
getBaseDir
(),
true
);
String
dbName
=
"mvstore"
+
";
DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine
"
;
";
MV_STORE=TRUE
"
;
Connection
conn
;
Statement
stat
;
long
maxSize
=
0
;
...
...
@@ -511,7 +512,7 @@ int test;
private
void
testDataTypes
()
throws
Exception
{
FileUtils
.
deleteRecursive
(
getBaseDir
(),
true
);
String
dbName
=
"mvstore"
+
";
DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine
"
;
";
MV_STORE=TRUE
"
;
Connection
conn
=
getConnection
(
dbName
);
Statement
stat
=
conn
.
createStatement
();
...
...
@@ -661,7 +662,7 @@ int test;
private
void
testLocking
()
throws
Exception
{
FileUtils
.
deleteRecursive
(
getBaseDir
(),
true
);
String
dbName
=
"mvstore"
+
";
DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine
"
;
";
MV_STORE=TRUE
"
;
Connection
conn
=
getConnection
(
dbName
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"set lock_timeout 1000"
);
...
...
@@ -698,7 +699,7 @@ int test;
private
void
testSimple
()
throws
Exception
{
FileUtils
.
deleteRecursive
(
getBaseDir
(),
true
);
String
dbName
=
"mvstore"
+
";
DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine
"
;
";
MV_STORE=TRUE
"
;
Connection
conn
=
getConnection
(
dbName
);
Statement
stat
=
conn
.
createStatement
();
// create table test(id int, name varchar)
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论