Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
8c93fb4d
提交
8c93fb4d
authored
11月 05, 2014
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MVStore: support for concurrent reads and writes is now enabled by default.
上级
65449074
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
32 行增加
和
55 行删除
+32
-55
changelog.html
h2/src/docsrc/html/changelog.html
+11
-4
mvstore.html
h2/src/docsrc/html/mvstore.html
+11
-20
MVTableEngine.java
h2/src/main/org/h2/mvstore/db/MVTableEngine.java
+1
-3
TransactionStore.java
h2/src/main/org/h2/mvstore/db/TransactionStore.java
+6
-21
LobStorageMap.java
h2/src/main/org/h2/store/LobStorageMap.java
+3
-7
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
8c93fb4d
...
@@ -17,15 +17,22 @@ Change Log
...
@@ -17,15 +17,22 @@ Change Log
<h1>
Change Log
</h1>
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
H2 Console and server mode: SSL is now disabled and TLS is used
<ul><li>
H2 Console: the built-in web server did not work properly
to protect against the POODLE SSLv3 vulnerability.
if an unknown file was requested.
</li><li>
MVStore: the jar file is renamed to "h2-mvstore-*.jar" and is
deployed to Maven separately.
</li><li>
MVStore: support for concurrent reads and writes is now enabled by default.
</li><li>
Server mode: the transfer buffer size has been changed from 16 KB to 64 KB,
after it was found that this improves performance on Linux quite a lot.
</li><li>
H2 Console and server mode: SSL is now disabled and TLS is used
to protect against the Poodle SSLv3 vulnerability.
The system property to disable secure anonymous connections is now
The system property to disable secure anonymous connections is now
"h2.enableAnonymousTLS".
"h2.enableAnonymousTLS".
The default certificate is still self-signed, so you need to manually install
The default certificate is still self-signed, so you need to manually install
another one if you want to avoid man in the middle attacks.
another one if you want to avoid man in the middle attacks.
</li><li>
MVStore: the R-tree did not correctly measure the memory usage.
</li><li>
MVStore: the R-tree did not correctly measure the memory usage.
</li><li>
MVStore: compacting a store with an R-tree did not always work.
</li><li>
MVStore: compacting a store with an R-tree did not always work.
<
ul
><li>
Issue 581: When running in LOCK_MODE=0,
<
/li
><li>
Issue 581: When running in LOCK_MODE=0,
JdbcDatabaseMetaData#supportsTransactionIsolationLevel(TRANSACTION_READ_UNCOMMITTED)
JdbcDatabaseMetaData#supportsTransactionIsolationLevel(TRANSACTION_READ_UNCOMMITTED)
should return false
should return false
</li></ul>
</li></ul>
...
...
h2/src/docsrc/html/mvstore.html
浏览文件 @
8c93fb4d
...
@@ -54,14 +54,15 @@ MVStore
...
@@ -54,14 +54,15 @@ MVStore
<h2
id=
"overview"
>
Overview
</h2>
<h2
id=
"overview"
>
Overview
</h2>
<p>
<p>
The MVStore is work in progress, and is planned to be the next storage subsystem of H2.
The MVStore is a persistent, log structured key-value store.
But it can also be used directly within an application, without using JDBC or SQL.
It is planned to be the next storage subsystem of H2,
but it can also be used directly within an application, without using JDBC or SQL.
</p>
</p>
<ul><li>
MVStore stands for "multi-version store".
<ul><li>
MVStore stands for "multi-version store".
</li><li>
Each store contains a number of maps that can be accessed using the
<code>
java.util.Map
</code>
interface.
</li><li>
Each store contains a number of maps that can be accessed using the
<code>
java.util.Map
</code>
interface.
</li><li>
Both file-based persistence and in-memory operation are supported.
</li><li>
Both file-based persistence and in-memory operation are supported.
</li><li>
It is intended to be fast, simple to use, and small.
</li><li>
It is intended to be fast, simple to use, and small.
</li><li>
Old versions of the data can be read concurrently with all other operations
.
</li><li>
Concurrent read and write operations are supported
.
</li><li>
Transactions are supported (including concurrent transactions and 2-phase commit).
</li><li>
Transactions are supported (including concurrent transactions and 2-phase commit).
</li><li>
The tool is very modular.
</li><li>
The tool is very modular.
It supports pluggable data types and serialization,
It supports pluggable data types and serialization,
...
@@ -185,8 +186,8 @@ the key of the map must also contain the primary key).
...
@@ -185,8 +186,8 @@ the key of the map must also contain the primary key).
A version is a snapshot of all the data of all maps at a given point in time.
A version is a snapshot of all the data of all maps at a given point in time.
Creating a snapshot is fast: only those pages that are changed after a snapshot are copied.
Creating a snapshot is fast: only those pages that are changed after a snapshot are copied.
This behavior is also called COW (copy on write).
This behavior is also called COW (copy on write).
Old versions are readable.
Rollback to an old version is supported.
Rollback to an old version is supported.
Old versions are readable until old data is purged.
</p><p>
</p><p>
The following sample code show how to create a store, open a map, add some data,
The following sample code show how to create a store, open a map, add some data,
and access the current and an old version:
and access the current and an old version:
...
@@ -241,8 +242,8 @@ For common use cases, the storage overhead of this utility is very small compare
...
@@ -241,8 +242,8 @@ For common use cases, the storage overhead of this utility is very small compare
<h3
id=
"inMemory"
>
In-Memory Performance and Usage
</h3>
<h3
id=
"inMemory"
>
In-Memory Performance and Usage
</h3>
<p>
<p>
Performance of in-memory operations is a
bit
slower than
Performance of in-memory operations is a
bout 50%
slower than
<code>
java.util.TreeMap
</code>
, and slower than
<code>
java.util.HashMap
</code>
.
<code>
java.util.TreeMap
</code>
.
</p><p>
</p><p>
The memory overhead for large maps is slightly better than for the regular
The memory overhead for large maps is slightly better than for the regular
map implementations, but there is a higher overhead per map.
map implementations, but there is a higher overhead per map.
...
@@ -296,28 +297,18 @@ and a multi-version R-tree map implementation for spatial operations.
...
@@ -296,28 +297,18 @@ and a multi-version R-tree map implementation for spatial operations.
<h3
id=
"caching"
>
Concurrent Operations and Caching
</h3>
<h3
id=
"caching"
>
Concurrent Operations and Caching
</h3>
<p>
<p>
The default map implementation supports concurrent reads on old versions of the data
.
Concurrent reads and writes are supported
.
All such read operations can occur in parallel. Concurrent reads from the page cache,
All such read operations can occur in parallel. Concurrent reads from the page cache,
as well as concurrent reads from the file system are supported.
as well as concurrent reads from the file system are supported.
Write operations first read the relevant pages from disk to memory
(this can happen concurrently), and only then modify the data.
The in-memory parts of write operations are synchronized.
Writing changes to the file can occur concurrently to modifying the data,
Writing changes to the file can occur concurrently to modifying the data,
as writing operates on a snapshot.
as writing operates on a snapshot.
</p><p>
</p><p>
Caching is done on the page level.
Caching is done on the page level.
The page cache is a concurrent LIRS cache, which should be resistant against scan operations.
The page cache is a concurrent LIRS cache, which should be resistant against scan operations.
</p><p>
</p><p>
The default map implementation does not support concurrent modification
operations on a map (the same as
<code>
HashMap
</code>
and
<code>
TreeMap
</code>
).
Similar to those classes, the map tries to detect concurrent modifications.
</p><p>
With the
<code>
MVMapConcurrent
</code>
implementation,
read operations even on the newest version can happen concurrently with all other
operations, without risk of corruption.
This comes with slightly reduced speed in single threaded mode,
the same as with other
<code>
ConcurrentHashMap
</code>
implementations.
Write operations first read the relevant pages from disk to memory
(this can happen concurrently), and only then modify the data.
The in-memory parts of write operations are synchronized.
</p><p>
For fully scalable concurrent write operations to a map (in-memory and to disk),
For fully scalable concurrent write operations to a map (in-memory and to disk),
the map could be split into multiple maps in different stores ('sharding').
the map could be split into multiple maps in different stores ('sharding').
The plan is to add such a mechanism later when needed.
The plan is to add such a mechanism later when needed.
...
...
h2/src/main/org/h2/mvstore/db/MVTableEngine.java
浏览文件 @
8c93fb4d
...
@@ -161,9 +161,7 @@ public class MVTableEngine implements TableEngine {
...
@@ -161,9 +161,7 @@ public class MVTableEngine implements TableEngine {
this
.
store
=
builder
.
open
();
this
.
store
=
builder
.
open
();
this
.
transactionStore
=
new
TransactionStore
(
this
.
transactionStore
=
new
TransactionStore
(
store
,
store
,
new
ValueDataType
(
null
,
db
,
null
),
new
ValueDataType
(
null
,
db
,
null
));
db
.
isMultiThreaded
()
);
}
}
public
MVStore
getStore
()
{
public
MVStore
getStore
()
{
...
...
h2/src/main/org/h2/mvstore/db/TransactionStore.java
浏览文件 @
8c93fb4d
...
@@ -15,7 +15,6 @@ import java.util.Map.Entry;
...
@@ -15,7 +15,6 @@ import java.util.Map.Entry;
import
org.h2.mvstore.Cursor
;
import
org.h2.mvstore.Cursor
;
import
org.h2.mvstore.DataUtils
;
import
org.h2.mvstore.DataUtils
;
import
org.h2.mvstore.MVMap
;
import
org.h2.mvstore.MVMap
;
import
org.h2.mvstore.MVMapConcurrent
;
import
org.h2.mvstore.MVStore
;
import
org.h2.mvstore.MVStore
;
import
org.h2.mvstore.WriteBuffer
;
import
org.h2.mvstore.WriteBuffer
;
import
org.h2.mvstore.type.DataType
;
import
org.h2.mvstore.type.DataType
;
...
@@ -50,11 +49,6 @@ public class TransactionStore {
...
@@ -50,11 +49,6 @@ public class TransactionStore {
*/
*/
final
MVMap
<
Long
,
Object
[]>
undoLog
;
final
MVMap
<
Long
,
Object
[]>
undoLog
;
/**
* Whether concurrent maps should be used.
*/
private
final
boolean
concurrent
;
/**
/**
* The map of maps.
* The map of maps.
*/
*/
...
@@ -78,7 +72,7 @@ public class TransactionStore {
...
@@ -78,7 +72,7 @@ public class TransactionStore {
* @param store the store
* @param store the store
*/
*/
public
TransactionStore
(
MVStore
store
)
{
public
TransactionStore
(
MVStore
store
)
{
this
(
store
,
new
ObjectDataType
()
,
false
);
this
(
store
,
new
ObjectDataType
());
}
}
/**
/**
...
@@ -86,12 +80,10 @@ public class TransactionStore {
...
@@ -86,12 +80,10 @@ public class TransactionStore {
*
*
* @param store the store
* @param store the store
* @param dataType the data type for map keys and values
* @param dataType the data type for map keys and values
* @param concurrent whether concurrent maps should be used
*/
*/
public
TransactionStore
(
MVStore
store
,
DataType
dataType
,
boolean
concurrent
)
{
public
TransactionStore
(
MVStore
store
,
DataType
dataType
)
{
this
.
store
=
store
;
this
.
store
=
store
;
this
.
dataType
=
dataType
;
this
.
dataType
=
dataType
;
this
.
concurrent
=
concurrent
;
preparedTransactions
=
store
.
openMap
(
"openTransactions"
,
preparedTransactions
=
store
.
openMap
(
"openTransactions"
,
new
MVMap
.
Builder
<
Integer
,
Object
[]>());
new
MVMap
.
Builder
<
Integer
,
Object
[]>());
VersionedValueType
oldValueType
=
new
VersionedValueType
(
dataType
);
VersionedValueType
oldValueType
=
new
VersionedValueType
(
dataType
);
...
@@ -363,17 +355,10 @@ public class TransactionStore {
...
@@ -363,17 +355,10 @@ public class TransactionStore {
}
}
VersionedValueType
vt
=
new
VersionedValueType
(
valueType
);
VersionedValueType
vt
=
new
VersionedValueType
(
valueType
);
MVMap
<
K
,
VersionedValue
>
map
;
MVMap
<
K
,
VersionedValue
>
map
;
if
(
concurrent
)
{
MVMapConcurrent
.
Builder
<
K
,
VersionedValue
>
builder
=
new
MVMapConcurrent
.
Builder
<
K
,
VersionedValue
>().
keyType
(
keyType
).
valueType
(
vt
);
map
=
store
.
openMap
(
name
,
builder
);
}
else
{
MVMap
.
Builder
<
K
,
VersionedValue
>
builder
=
MVMap
.
Builder
<
K
,
VersionedValue
>
builder
=
new
MVMap
.
Builder
<
K
,
VersionedValue
>().
new
MVMap
.
Builder
<
K
,
VersionedValue
>().
keyType
(
keyType
).
valueType
(
vt
);
keyType
(
keyType
).
valueType
(
vt
);
map
=
store
.
openMap
(
name
,
builder
);
map
=
store
.
openMap
(
name
,
builder
);
}
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
MVMap
<
Object
,
VersionedValue
>
m
=
(
MVMap
<
Object
,
VersionedValue
>)
map
;
MVMap
<
Object
,
VersionedValue
>
m
=
(
MVMap
<
Object
,
VersionedValue
>)
map
;
maps
.
put
(
map
.
getId
(),
m
);
maps
.
put
(
map
.
getId
(),
m
);
...
...
h2/src/main/org/h2/store/LobStorageMap.java
浏览文件 @
8c93fb4d
...
@@ -19,7 +19,6 @@ import org.h2.engine.Constants;
...
@@ -19,7 +19,6 @@ import org.h2.engine.Constants;
import
org.h2.engine.Database
;
import
org.h2.engine.Database
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.mvstore.MVMap
;
import
org.h2.mvstore.MVMap
;
import
org.h2.mvstore.MVMapConcurrent
;
import
org.h2.mvstore.MVStore
;
import
org.h2.mvstore.MVStore
;
import
org.h2.mvstore.StreamStore
;
import
org.h2.mvstore.StreamStore
;
import
org.h2.mvstore.db.MVTableEngine.Store
;
import
org.h2.mvstore.db.MVTableEngine.Store
;
...
@@ -91,12 +90,9 @@ public class LobStorageMap implements LobStorageInterface {
...
@@ -91,12 +90,9 @@ public class LobStorageMap implements LobStorageInterface {
}
else
{
}
else
{
mvStore
=
s
.
getStore
();
mvStore
=
s
.
getStore
();
}
}
lobMap
=
mvStore
.
openMap
(
"lobMap"
,
lobMap
=
mvStore
.
openMap
(
"lobMap"
);
new
MVMapConcurrent
.
Builder
<
Long
,
Object
[]>());
refMap
=
mvStore
.
openMap
(
"lobRef"
);
refMap
=
mvStore
.
openMap
(
"lobRef"
,
dataMap
=
mvStore
.
openMap
(
"lobData"
);
new
MVMapConcurrent
.
Builder
<
Object
[],
Boolean
>());
dataMap
=
mvStore
.
openMap
(
"lobData"
,
new
MVMapConcurrent
.
Builder
<
Long
,
byte
[]>());
streamStore
=
new
StreamStore
(
dataMap
);
streamStore
=
new
StreamStore
(
dataMap
);
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论