Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
eda01e44
提交
eda01e44
authored
11月 28, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Documentation
上级
46f4961f
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
29 行增加
和
32 行删除
+29
-32
links.html
h2/src/docsrc/html/links.html
+5
-0
mvstore.html
h2/src/docsrc/html/mvstore.html
+23
-28
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+1
-4
没有找到文件。
h2/src/docsrc/html/links.html
浏览文件 @
eda01e44
...
@@ -156,6 +156,11 @@ HenPlus</a><br />
...
@@ -156,6 +156,11 @@ HenPlus</a><br />
HenPlus is a SQL shell written in Java.
HenPlus is a SQL shell written in Java.
</p>
</p>
<p><a
href=
"https://github.com/maginatics/jdbclint"
>
JDBC lint
</a><br
/>
Helps write correct and efficient code when using the JDBC API.
</p>
<p><a
href=
"http://www.openoffice.org"
>
<p><a
href=
"http://www.openoffice.org"
>
OpenOffice
</a><br
/>
OpenOffice
</a><br
/>
Base is OpenOffice.org's database application. It provides access to relational data sources.
Base is OpenOffice.org's database application. It provides access to relational data sources.
...
...
h2/src/docsrc/html/mvstore.html
浏览文件 @
eda01e44
...
@@ -53,10 +53,10 @@ MVStore
...
@@ -53,10 +53,10 @@ 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 work in progress, and is planned to be the next storage subsystem of H2.
But it can
be also
directly within an application, without using JDBC or SQL.
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
(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>
Old versions of the data can be read concurrently with all other operations.
...
@@ -86,7 +86,7 @@ MVMap<Integer, String> map = s.openMap("data");
...
@@ -86,7 +86,7 @@ MVMap<Integer, String> map = s.openMap("data");
map.put(1, "Hello World");
map.put(1, "Hello World");
System.out.println(map.get(1));
System.out.println(map.get(1));
// close the store (this will
store
changes)
// close the store (this will
persist
changes)
s.close();
s.close();
</pre>
</pre>
...
@@ -94,23 +94,21 @@ s.close();
...
@@ -94,23 +94,21 @@ s.close();
<p>
<p>
The
<code>
MVStore.Builder
</code>
provides a fluid interface
The
<code>
MVStore.Builder
</code>
provides a fluid interface
to build a store if more complex configuration options are used.
to build a store if more complex configuration options are used.
The following code contains all supported configuration options
:
Example usage
:
</p>
</p>
<pre>
<pre>
MVStore s = new MVStore.Builder().
MVStore s = new MVStore.Builder().
autoCommitDisabled().
backgroundExceptionListener(listener).
cacheSize(10).
compressData().
encryptionKey("007".toCharArray()).
fileName(fileName).
fileName(fileName).
fileStore(new FileStore()).
encryptionKey("007".toCharArray()).
pageSplitSize(6 * 1024).
compressData().
readOnly().
open();
open();
</pre>
</pre>
<ul><li>
autoCommitDisabled(): to disable auto-commit.
<p>
</li><li>
backgroundExceptionListener: a listener for
The list of available options is:
</p>
<ul><li>
autoCommitBufferSize: the size of the write buffer.
</li><li>
autoCommitDisabled: to disable auto-commit.
</li><li>
backgroundExceptionHandler: specify a handler for
exceptions that could occur while writing in the background.
exceptions that could occur while writing in the background.
</li><li>
cacheSize: the cache size in MB.
</li><li>
cacheSize: the cache size in MB.
</li><li>
compressData: compress the data when storing.
</li><li>
compressData: compress the data when storing.
...
@@ -180,10 +178,10 @@ the key of the map must also contain the primary key).
...
@@ -180,10 +178,10 @@ the key of the map must also contain the primary key).
<h3
id=
"versions"
>
Versions
</h3>
<h3
id=
"versions"
>
Versions
</h3>
<p>
<p>
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.
Old versions are readable until the old data was explicitly overwritten.
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).
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:
...
@@ -217,7 +215,6 @@ MVMap<Integer, String> oldMap =
...
@@ -217,7 +215,6 @@ MVMap<Integer, String> oldMap =
// this will print "Hello" and "World":
// this will print "Hello" and "World":
System.out.println(oldMap.get(1));
System.out.println(oldMap.get(1));
System.out.println(oldMap.get(2));
System.out.println(oldMap.get(2));
oldMap.close();
// print the newest version ("Hi")
// print the newest version ("Hi")
System.out.println(map.get(1));
System.out.println(map.get(1));
...
@@ -253,10 +250,11 @@ Except for persisting data, all features are supported in this mode
...
@@ -253,10 +250,11 @@ Except for persisting data, all features are supported in this mode
If a file name is specified, all operations occur in memory (with the same
If a file name is specified, all operations occur in memory (with the same
performance characteristics) until data is persisted.
performance characteristics) until data is persisted.
</p><p>
</p><p>
As in all map implementations,
changing the key object after an entry
As in all map implementations,
keys need to be immutable, that means
has been added to the map is not allowed (keys are immutable)
.
changing the key object after an entry has been added is not allowed
.
If a file name is specified, the value may also not be changed after
If a file name is specified, the value may also not be changed after
adding an entry, because it might be serialized at any time.
adding an entry, because it might be serialized
(which could happen at any time when autocommit is enabled).
</p>
</p>
<h3
id=
"dataTypes"
>
Pluggable Data Types
</h3>
<h3
id=
"dataTypes"
>
Pluggable Data Types
</h3>
...
@@ -267,7 +265,7 @@ and uses Java serialization for other objects. The following classes are current
...
@@ -267,7 +265,7 @@ and uses Java serialization for other objects. The following classes are current
String, UUID, Date
</code>
and arrays (both primitive arrays and object arrays).
String, UUID, Date
</code>
and arrays (both primitive arrays and object arrays).
</p><p>
</p><p>
Parameterized data types are supported
Parameterized data types are supported
(for example one could build a string data type that limits the length
for some reason
).
(for example one could build a string data type that limits the length).
</p><p>
</p><p>
The storage engine itself does not have any length limits, so that keys, values,
The storage engine itself does not have any length limits, so that keys, values,
pages, and chunks can be very big (as big as fits in memory).
pages, and chunks can be very big (as big as fits in memory).
...
@@ -329,12 +327,9 @@ this should improve write performance for file systems and storage systems
...
@@ -329,12 +327,9 @@ this should improve write performance for file systems and storage systems
that do not efficiently support small random writes, such as Btrfs, as well as SSDs.
that do not efficiently support small random writes, such as Btrfs, as well as SSDs.
(According to a test, write throughput of a common SSD increases with write block size,
(According to a test, write throughput of a common SSD increases with write block size,
until a block size of 2 MB, and then does not further increase.)
until a block size of 2 MB, and then does not further increase.)
By default, committed changes are automatically written once every second
By default, changes are automatically written when more than a number of pages are modified,
in a background thread, even if only little data was changed.
and once every second in a background thread, even if only little data was changed.
Changes can also be written explicitly by calling
<code>
store()
</code>
.
Changes can also be written explicitly by calling
<code>
commit()
</code>
.
To avoid running out of memory, uncommitted changes are also written when needed,
however they are rolled back when closing the store,
or at the latest (when the store was not closed normally) when opening the store.
</p><p>
</p><p>
When storing, all changed pages are serialized,
When storing, all changed pages are serialized,
optionally compressed using the LZF algorithm,
optionally compressed using the LZF algorithm,
...
@@ -461,8 +456,8 @@ The following exceptions can occur:
...
@@ -461,8 +456,8 @@ The following exceptions can occur:
so that the application can distinguish between different error cases.
so that the application can distinguish between different error cases.
</li><li><code>
IllegalArgumentException
</code>
if a method was called with an illegal argument.
</li><li><code>
IllegalArgumentException
</code>
if a method was called with an illegal argument.
</li><li><code>
UnsupportedOperationException
</code>
if a method was called that is not supported,
</li><li><code>
UnsupportedOperationException
</code>
if a method was called that is not supported,
for example trying to modify a read-only map
or view
.
for example trying to modify a read-only map.
</li><li><code>
ConcurrentModificationException
</code>
if
the object
is modified concurrently.
</li><li><code>
ConcurrentModificationException
</code>
if
a map
is modified concurrently.
</li></ul>
</li></ul>
<h3
id=
"storageEngine"
>
Storage Engine for H2
</h3>
<h3
id=
"storageEngine"
>
Storage Engine for H2
</h3>
...
...
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
eda01e44
...
@@ -57,10 +57,6 @@ MVTableEngine:
...
@@ -57,10 +57,6 @@ MVTableEngine:
TransactionStore:
TransactionStore:
MVStore:
MVStore:
- better document auto-commit (also when many unsaved pages)
advantages and disadvantages
- auto-commit when used in memory as well
- better document MVStore setters
- automated 'kill process' and 'power failure' test
- automated 'kill process' and 'power failure' test
- update checkstyle
- update checkstyle
- feature to auto-compact from time to time and on close
- feature to auto-compact from time to time and on close
...
@@ -132,6 +128,7 @@ MVStore:
...
@@ -132,6 +128,7 @@ MVStore:
- currently, uncommitted changes are stored if there are many transient changes,
- currently, uncommitted changes are stored if there are many transient changes,
and rolled back when opening - is this really needed?
and rolled back when opening - is this really needed?
- compact* should also store uncommitted changes (if there are any)
- compact* should also store uncommitted changes (if there are any)
- write a LSM-tree (log structured merge tree) utility on top of the MVStore
*/
*/
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论