Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
46188bab
提交
46188bab
authored
11 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MVTableEngine
上级
684c03ce
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
56 行增加
和
18 行删除
+56
-18
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+3
-2
MVSecondaryIndex.java
h2/src/main/org/h2/mvstore/db/MVSecondaryIndex.java
+4
-1
TransactionStore.java
h2/src/main/org/h2/mvstore/db/TransactionStore.java
+37
-7
ValueDataType.java
h2/src/main/org/h2/mvstore/db/ValueDataType.java
+0
-3
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+2
-0
TestMVStore.java
h2/src/test/org/h2/test/store/TestMVStore.java
+7
-5
TestMVTableEngine.java
h2/src/test/org/h2/test/store/TestMVTableEngine.java
+3
-0
没有找到文件。
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
46188bab
...
...
@@ -268,7 +268,7 @@ public class MVStore {
MVStore
(
HashMap
<
String
,
Object
>
config
)
{
this
.
compress
=
config
.
containsKey
(
"compress"
);
Object
o
=
config
.
get
(
"pageSplitSize"
);
pageSplitSize
=
o
==
null
?
6
*
1024
:
(
Integer
)
o
;
pageSplitSize
=
o
==
null
?
1
6
*
1024
:
(
Integer
)
o
;
o
=
config
.
get
(
"backgroundExceptionHandler"
);
this
.
backgroundExceptionHandler
=
(
UncaughtExceptionHandler
)
o
;
meta
=
new
MVMapConcurrent
<
String
,
String
>(
StringDataType
.
INSTANCE
,
...
...
@@ -1056,6 +1056,7 @@ public class MVStore {
chunks
.
remove
(
c
.
id
);
meta
.
remove
(
"chunk."
+
c
.
id
);
}
else
{
meta
.
put
(
"chunk."
+
c
.
id
,
c
.
asString
());
// remove this chunk in the next save operation
registerFreePage
(
storeVersion
+
1
,
c
.
id
,
0
,
0
);
}
...
...
@@ -2153,7 +2154,7 @@ public class MVStore {
/**
* Set the amount of memory a page should contain at most, in bytes,
* before it is split. The default is 6 KB. This is not a limit in the
* before it is split. The default is
1
6 KB. This is not a limit in the
* page size, as pages with one entry can get larger. It is just the
* point where pages that contain more than one entry are split.
*
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/db/MVSecondaryIndex.java
浏览文件 @
46188bab
...
...
@@ -159,7 +159,10 @@ public class MVSecondaryIndex extends BaseIndex {
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++)
{
Column
c
=
columns
[
i
];
int
idx
=
c
.
getColumnId
();
array
[
i
]
=
r
.
getValue
(
idx
);
Value
v
=
r
.
getValue
(
idx
);
if
(
v
!=
null
)
{
array
[
i
]
=
v
.
convertTo
(
c
.
getType
());
}
}
array
[
keyColumns
-
1
]
=
ValueLong
.
get
(
r
.
getKey
());
return
ValueArray
.
get
(
array
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/db/TransactionStore.java
浏览文件 @
46188bab
...
...
@@ -8,6 +8,7 @@ package org.h2.mvstore.db;
import
java.nio.ByteBuffer
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -53,6 +54,8 @@ public class TransactionStore {
* Key: [ transactionId, logId ], value: [ opType, mapId, key, oldValue ].
*/
final
MVMap
<
long
[],
Object
[]>
undoLog
;
;
// TODO should be <long, Object[]>
/**
* The lock timeout in milliseconds. 0 means timeout immediately.
...
...
@@ -73,6 +76,8 @@ public class TransactionStore {
private
long
firstOpenTransaction
=
-
1
;
private
HashMap
<
Integer
,
MVMap
<
Object
,
VersionedValue
>>
maps
=
New
.
hashMap
();
/**
* Create a new transaction store.
*
...
...
@@ -145,7 +150,7 @@ public class TransactionStore {
int
status
;
String
name
;
if
(
data
==
null
)
{
key
[
1
]
=
0
;
key
=
new
long
[]
{
key
[
0
],
0
}
;
if
(
undoLog
.
containsKey
(
key
))
{
status
=
Transaction
.
STATUS_OPEN
;
}
else
{
...
...
@@ -242,6 +247,11 @@ public class TransactionStore {
}
}
<
K
,
V
>
void
removeMap
(
TransactionMap
<
K
,
V
>
map
)
{
maps
.
remove
(
map
.
mapId
);
store
.
removeMap
(
map
.
map
);
}
/**
* Commit a transaction.
*
...
...
@@ -289,6 +299,10 @@ public class TransactionStore {
}
private
synchronized
MVMap
<
Object
,
VersionedValue
>
openMap
(
int
mapId
)
{
MVMap
<
Object
,
VersionedValue
>
map
=
maps
.
get
(
mapId
);
if
(
map
!=
null
)
{
return
map
;
}
// TODO open map by id if possible
Map
<
String
,
String
>
meta
=
store
.
getMetaMap
();
String
m
=
meta
.
get
(
"map."
+
mapId
);
...
...
@@ -301,7 +315,8 @@ public class TransactionStore {
MVMap
.
Builder
<
Object
,
VersionedValue
>
mapBuilder
=
new
MVMap
.
Builder
<
Object
,
VersionedValue
>().
keyType
(
dataType
).
valueType
(
vt
);
MVMap
<
Object
,
VersionedValue
>
map
=
store
.
openMap
(
mapName
,
mapBuilder
);
map
=
store
.
openMap
(
mapName
,
mapBuilder
);
maps
.
put
(
mapId
,
map
);
return
map
;
}
...
...
@@ -735,7 +750,12 @@ public class TransactionStore {
* @param map the map
*/
public
<
K
,
V
>
void
removeMap
(
TransactionMap
<
K
,
V
>
map
)
{
store
.
store
.
removeMap
(
map
.
map
);
store
.
removeMap
(
map
);
}
@Override
public
String
toString
()
{
return
""
+
transactionId
;
}
}
...
...
@@ -756,9 +776,12 @@ public class TransactionStore {
*/
final
MVMap
<
K
,
VersionedValue
>
map
;
private
Transaction
transaction
;
/**
* The map id.
*/
final
int
mapId
;
private
final
int
mapId
;
private
Transaction
transaction
;
/**
* If a record was read that was updated by this transaction, and the
...
...
@@ -1074,7 +1097,7 @@ public class TransactionStore {
return
data
;
}
}
// added
or updat
ed by another transaction
// added
, updated, or remov
ed by another transaction
boolean
open
=
transaction
.
store
.
isTransactionOpen
(
tx
);
if
(!
open
)
{
// it is committed
...
...
@@ -1087,7 +1110,8 @@ public class TransactionStore {
d
=
transaction
.
store
.
undoLog
.
get
(
x
);
}
if
(
d
==
null
)
{
// committed or rolled back in the meantime
// this entry was committed or rolled back
// in the meantime (the transaction might still be open)
data
=
map
.
get
(
key
);
}
else
{
data
=
(
VersionedValue
)
d
[
3
];
...
...
@@ -1298,6 +1322,12 @@ public class TransactionStore {
* The value.
*/
public
Object
value
;
@Override
public
String
toString
()
{
return
"{"
+
transactionId
+
"/"
+
logId
+
"}: "
+
value
;
}
}
/**
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/db/ValueDataType.java
浏览文件 @
46188bab
...
...
@@ -130,9 +130,6 @@ public class ValueDataType implements DataType {
if
(
a
==
b
)
{
return
0
;
}
int
dataType
=
Value
.
getHigherOrder
(
a
.
getType
(),
b
.
getType
());
a
=
a
.
convertTo
(
dataType
);
b
=
b
.
convertTo
(
dataType
);
return
a
.
compareTypeSave
(
b
,
compareMode
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
46188bab
...
...
@@ -486,6 +486,8 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
TestPerformance
.
main
(
"-init"
,
"-db"
,
"1"
,
"-size"
,
"1000"
);
prof
.
stopCollecting
();
System
.
out
.
println
(
prof
.
getTop
(
3
));
TestPerformance
.
main
(
"-init"
,
"-db"
,
"1"
,
"-size"
,
"1000"
);
TestPerformance
.
main
(
"-init"
,
"-db"
,
"9"
,
"-size"
,
"1000"
);
}
// Recover.execute("data", null);
// RunScript.execute("jdbc:h2:data/test2",
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/store/TestMVStore.java
浏览文件 @
46188bab
...
...
@@ -573,7 +573,7 @@ public class TestMVStore extends TestBase {
}
s
.
close
();
int
[]
expectedReadsForCacheSize
=
{
34
13
,
2590
,
1924
,
1440
,
111
2
,
956
,
918
34
06
,
2590
,
1924
,
1440
,
110
2
,
956
,
918
};
for
(
int
cacheSize
=
0
;
cacheSize
<=
6
;
cacheSize
+=
4
)
{
s
=
new
MVStore
.
Builder
().
...
...
@@ -905,10 +905,12 @@ public class TestMVStore extends TestBase {
map
.
put
(
1
,
"Hello World"
);
// System.out.println(map.get(1));
//
mark the changes as committed
s
.
c
ommit
();
//
close the store (this will persist changes)
s
.
c
lose
();
// close the store
s
=
MVStore
.
open
(
fileName
);
map
=
s
.
openMap
(
"data"
);
assertEquals
(
"Hello World"
,
map
.
get
(
1
));
s
.
close
();
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/store/TestMVTableEngine.java
浏览文件 @
46188bab
...
...
@@ -124,6 +124,9 @@ public class TestMVTableEngine extends TestBase {
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"
);
// this table is kept
stat
.
execute
(
"create table test"
+
i
+
"(id int primary key) "
+
"as select x from system_range(1, 1000)"
);
conn
.
close
();
long
size
=
FileUtils
.
size
(
getBaseDir
()
+
"/mvstore"
+
Constants
.
SUFFIX_MV_FILE
);
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论