Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
b4047421
提交
b4047421
authored
4月 18, 2014
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MVStore: support for volatile maps (that don't store changes).
上级
8f043e40
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
53 行增加
和
7 行删除
+53
-7
changelog.html
h2/src/docsrc/html/changelog.html
+2
-1
MVMap.java
h2/src/main/org/h2/mvstore/MVMap.java
+22
-1
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+3
-0
MVPrimaryIndex.java
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
+3
-0
MVTableEngine.java
h2/src/main/org/h2/mvstore/db/MVTableEngine.java
+0
-5
TestMVStore.java
h2/src/test/org/h2/test/store/TestMVStore.java
+23
-0
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
b4047421
...
...
@@ -18,7 +18,8 @@ Change Log
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
MVStore mode: in-memory databases now also use the MVStore.
<ul><li>
MVStore: support for volatile maps (that don't store changes).
</li><li>
MVStore mode: in-memory databases now also use the MVStore.
</li><li>
In server mode, appending ";autocommit=false" to the database URL was working,
but the return value of Connection.getAutoCommit() was wrong.
</li><li>
OSGi: the import package declaration of org.h2 excluded version 1.4.
...
...
h2/src/main/org/h2/mvstore/MVMap.java
浏览文件 @
b4047421
...
...
@@ -58,6 +58,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
private
boolean
closed
;
private
boolean
readOnly
;
private
boolean
isVolatile
;
protected
MVMap
(
DataType
keyType
,
DataType
valueType
)
{
this
.
keyType
=
keyType
;
...
...
@@ -917,6 +918,26 @@ public class MVMap<K, V> extends AbstractMap<K, V>
return
readOnly
;
}
/**
* Set the volatile flag of the map.
*
* @param isVolatile the volatile flag
*/
public
void
setVolatile
(
boolean
isVolatile
)
{
this
.
isVolatile
=
isVolatile
;
}
/**
* Whether this is volatile map, meaning that changes
* are not persisted. By default (even if the store is not persisted),
* maps are not volatile.
*
* @return whether this map is volatile
*/
public
boolean
isVolatile
()
{
return
isVolatile
;
}
/**
* This method is called before writing to the map. The default
* implementation checks whether writing is allowed, and tries
...
...
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
b4047421
...
...
@@ -952,6 +952,9 @@ public class MVStore {
// the map was created after storing started
continue
;
}
if
(
m
.
isVolatile
())
{
continue
;
}
if
(
v
>=
0
&&
v
>=
lastStoredVersion
)
{
m
.
waitUntilWritten
(
storeVersion
);
MVMap
<?,
?>
r
=
m
.
openVersion
(
storeVersion
);
...
...
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
浏览文件 @
b4047421
...
...
@@ -74,6 +74,9 @@ public class MVPrimaryIndex extends BaseIndex {
mapName
=
"table."
+
getId
();
dataMap
=
mvTable
.
getTransaction
(
null
).
openMap
(
mapName
,
keyType
,
valueType
);
if
(!
table
.
isPersistData
())
{
dataMap
.
map
.
setVolatile
(
true
);
}
Value
k
=
dataMap
.
lastKey
();
lastKey
=
k
==
null
?
0
:
k
.
getLong
();
}
...
...
h2/src/main/org/h2/mvstore/db/MVTableEngine.java
浏览文件 @
b4047421
...
...
@@ -30,7 +30,6 @@ import org.h2.mvstore.db.TransactionStore.Transaction;
import
org.h2.store.InDoubtTransaction
;
import
org.h2.store.fs.FileChannelInputStream
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.table.RegularTable
;
import
org.h2.table.TableBase
;
import
org.h2.util.New
;
...
...
@@ -118,10 +117,6 @@ public class MVTableEngine implements TableEngine {
@Override
public
TableBase
createTable
(
CreateTableData
data
)
{
Database
db
=
data
.
session
.
getDatabase
();
if
(!
data
.
persistData
)
{
;
// TODO need in-memory tables for persistent stores
return
new
RegularTable
(
data
);
}
Store
store
=
init
(
db
);
MVTable
table
=
new
MVTable
(
data
,
store
);
table
.
init
(
data
.
session
);
...
...
h2/src/test/org/h2/test/store/TestMVStore.java
浏览文件 @
b4047421
...
...
@@ -52,6 +52,7 @@ public class TestMVStore extends TestBase {
public
void
test
()
throws
Exception
{
FileUtils
.
deleteRecursive
(
getBaseDir
(),
true
);
FileUtils
.
createDirectories
(
getBaseDir
());
testVolatileMap
();
testEntrySet
();
testCompressEmptyPage
();
testCompressed
();
...
...
@@ -110,6 +111,28 @@ public class TestMVStore extends TestBase {
testLargerThan2G
();
}
private
void
testVolatileMap
()
{
String
fileName
=
getBaseDir
()
+
"/testVolatile.h3"
;
MVStore
store
=
new
MVStore
.
Builder
().
fileName
(
fileName
).
open
();
MVMap
<
String
,
String
>
map
=
store
.
openMap
(
"test"
);
assertFalse
(
map
.
isVolatile
());
map
.
setVolatile
(
true
);
assertTrue
(
map
.
isVolatile
());
map
.
put
(
"1"
,
"Hello"
);
assertEquals
(
"Hello"
,
map
.
get
(
"1"
));
assertEquals
(
1
,
map
.
size
());
store
.
close
();
store
=
new
MVStore
.
Builder
().
fileName
(
fileName
).
open
();
assertTrue
(
store
.
hasMap
(
"test"
));
map
=
store
.
openMap
(
"test"
);
assertEquals
(
0
,
map
.
size
());
store
.
close
();
}
private
void
testEntrySet
()
{
MVStore
s
=
new
MVStore
.
Builder
().
open
();
MVMap
<
Integer
,
Integer
>
map
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论