Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
28932210
提交
28932210
authored
7月 15, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MVTableEngine workaround (and a new test).
上级
c084d2ca
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
32 行增加
和
51 行删除
+32
-51
TransactionStore.java
h2/src/main/org/h2/mvstore/db/TransactionStore.java
+13
-1
TestMVTableEngine.java
h2/src/test/org/h2/test/store/TestMVTableEngine.java
+19
-50
没有找到文件。
h2/src/main/org/h2/mvstore/db/TransactionStore.java
浏览文件 @
28932210
...
...
@@ -236,6 +236,10 @@ public class TransactionStore {
commitIfNeeded
();
long
[]
undoKey
=
new
long
[]
{
t
.
getId
(),
logId
};
Object
[]
op
=
undoLog
.
get
(
undoKey
);
if
(
op
==
null
)
{
int
todoImprove
;
continue
;
}
int
opType
=
(
Integer
)
op
[
0
];
if
(
opType
==
Transaction
.
OP_REMOVE
)
{
int
mapId
=
(
Integer
)
op
[
1
];
...
...
@@ -337,6 +341,10 @@ public class TransactionStore {
commitIfNeeded
();
long
[]
undoKey
=
new
long
[]
{
t
.
getId
(),
logId
};
Object
[]
op
=
undoLog
.
get
(
undoKey
);
if
(
op
==
null
)
{
int
todoImprove
;
continue
;
}
int
mapId
=
((
Integer
)
op
[
1
]).
intValue
();
MVMap
<
Object
,
VersionedValue
>
map
=
openMap
(
mapId
);
if
(
map
!=
null
)
{
...
...
@@ -379,11 +387,15 @@ public class TransactionStore {
while
(
logId
>=
toLogId
)
{
Object
[]
op
=
undoLog
.
get
(
new
long
[]
{
t
.
getId
(),
logId
});
logId
--;
if
(
op
==
null
)
{
int
todoImprove
;
continue
;
}
int
mapId
=
((
Integer
)
op
[
1
]).
intValue
();
// TODO open map by id if possible
Map
<
String
,
String
>
meta
=
store
.
getMetaMap
();
String
m
=
meta
.
get
(
"map."
+
mapId
);
logId
--;
if
(
m
==
null
)
{
// map was removed later on
}
else
{
...
...
h2/src/test/org/h2/test/store/TestMVTableEngine.java
浏览文件 @
28932210
...
...
@@ -27,7 +27,6 @@ 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
;
/**
...
...
@@ -46,7 +45,7 @@ public class TestMVTableEngine extends TestBase {
@Override
public
void
test
()
throws
Exception
{
// testS
peed
();
// testS
hrinkDatabaseFile
();
testRecover
();
testSeparateKey
();
testRollback
();
...
...
@@ -65,58 +64,28 @@ public class TestMVTableEngine extends TestBase {
testSimple
();
}
private
void
testSpeed
()
throws
Exception
{
String
dbName
;
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
dbName
=
"mvstore"
;
dbName
+=
";LOCK_MODE=0"
;
// dbName += ";LOG=0";
testSpeed
(
dbName
);
int
test
;
Profiler
prof
=
new
Profiler
().
startCollecting
();
dbName
=
"mvstore"
+
";MV_STORE=TRUE"
;
dbName
+=
";LOCK_MODE=0"
;
dbName
+=
";LOG=0"
;
testSpeed
(
dbName
);
System
.
out
.
println
(
prof
.
getTop
(
10
));
}
FileUtils
.
deleteRecursive
(
getBaseDir
(),
true
);
}
private
void
testSpeed
(
String
dbName
)
throws
Exception
{
private
void
testShrinkDatabaseFile
()
throws
Exception
{
FileUtils
.
deleteRecursive
(
getBaseDir
(),
true
);
String
dbName
=
"mvstore"
+
";MV_STORE=TRUE"
;
Connection
conn
;
Statement
stat
;
String
url
=
getURL
(
dbName
,
true
);
String
user
=
getUser
();
String
password
=
getPassword
();
//Profiler prof = new Profiler();
//prof.sumClasses=true;
//prof.startCollecting();
conn
=
DriverManager
.
getConnection
(
url
,
user
,
password
);
long
maxSize
=
0
;
for
(
int
i
=
0
;
i
<
20
;
i
++)
{
conn
=
getConnection
(
dbName
);
stat
=
conn
.
createStatement
();
long
time
=
System
.
currentTimeMillis
();
// stat.execute(
// "create table test(id int primary key, name varchar(255))" +
// "as select x, 'Hello World' from system_range(1, 200000)");
stat
.
execute
(
"create table test(id int primary key, name varchar)"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"insert into test values(?, ?)"
);
prep
.
setString
(
2
,
new
String
(
new
char
[
10
]).
replace
((
char
)
0
,
'x'
));
// for (int i = 0; i < 20000; i++) {
for
(
int
i
=
0
;
i
<
800000
;
i
++)
{
prep
.
setInt
(
1
,
i
);
prep
.
execute
();
}
System
.
out
.
println
((
System
.
currentTimeMillis
()
-
time
)
+
" "
+
dbName
+
" before"
);
stat
.
execute
(
"create table test(id int primary key, data varchar)"
);
stat
.
execute
(
"insert into test select x, space(1000) from system_range(1, 1000)"
);
stat
.
execute
(
"drop table test"
);
conn
.
close
();
//System.out.println(prof.getTop(10));
System
.
out
.
println
((
System
.
currentTimeMillis
()
-
time
)
+
" "
+
dbName
+
" after"
);
long
size
=
FileUtils
.
size
(
getBaseDir
()
+
"/mvstore"
+
Constants
.
SUFFIX_MV_FILE
);
if
(
i
<
10
)
{
maxSize
=
(
int
)
(
Math
.
max
(
size
,
maxSize
)
*
1.1
);
}
else
if
(
size
>
maxSize
)
{
fail
(
i
+
" size: "
+
size
+
" max: "
+
maxSize
);
}
}
}
private
void
testRecover
()
throws
Exception
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论