Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
58dec4b5
提交
58dec4b5
authored
11月 30, 2012
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MVStore: compress is now disabled by default, and can be enabled on request.
上级
e15005f7
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
37 行增加
和
10 行删除
+37
-10
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+28
-10
MVStoreBuilder.java
h2/src/main/org/h2/mvstore/MVStoreBuilder.java
+9
-0
没有找到文件。
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
58dec4b5
...
@@ -23,8 +23,8 @@ import org.h2.mvstore.cache.CacheLongKeyLIRS;
...
@@ -23,8 +23,8 @@ import org.h2.mvstore.cache.CacheLongKeyLIRS;
import
org.h2.mvstore.cache.FilePathCache
;
import
org.h2.mvstore.cache.FilePathCache
;
import
org.h2.mvstore.type.DataType
;
import
org.h2.mvstore.type.DataType
;
import
org.h2.mvstore.type.DataTypeFactory
;
import
org.h2.mvstore.type.DataTypeFactory
;
import
org.h2.mvstore.type.ObjectTypeFactory
;
import
org.h2.mvstore.type.Object
Data
TypeFactory
;
import
org.h2.mvstore.type.StringType
;
import
org.h2.mvstore.type.String
Data
Type
;
import
org.h2.store.fs.FilePath
;
import
org.h2.store.fs.FilePath
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.util.New
;
import
org.h2.util.New
;
...
@@ -91,6 +91,8 @@ TODO:
...
@@ -91,6 +91,8 @@ TODO:
- dump values
- dump values
- tool to import / manipulate CSV files (maybe concurrently)
- tool to import / manipulate CSV files (maybe concurrently)
- map split / merge (fast if no overlap)
- map split / merge (fast if no overlap)
- auto-save if there are too many changes (required for StreamStore)
- StreamStore optimization: avoid copying bytes
*/
*/
...
@@ -149,6 +151,8 @@ public class MVStore {
...
@@ -149,6 +151,8 @@ public class MVStore {
private
HashMap
<
String
,
String
>
fileHeader
=
New
.
hashMap
();
private
HashMap
<
String
,
String
>
fileHeader
=
New
.
hashMap
();
private
ByteBuffer
writeBuffer
;
private
final
boolean
readOnly
;
private
final
boolean
readOnly
;
private
int
lastMapId
;
private
int
lastMapId
;
...
@@ -157,7 +161,9 @@ public class MVStore {
...
@@ -157,7 +161,9 @@ public class MVStore {
private
long
retainVersion
=
-
1
;
private
long
retainVersion
=
-
1
;
private
int
retainChunk
=
-
1
;
private
int
retainChunk
=
-
1
;
private
Compressor
compressor
;
private
final
Compressor
compressor
=
new
CompressLZF
();
private
final
boolean
compress
;
private
long
currentVersion
;
private
long
currentVersion
;
private
int
fileReadCount
;
private
int
fileReadCount
;
...
@@ -167,7 +173,7 @@ public class MVStore {
...
@@ -167,7 +173,7 @@ public class MVStore {
MVStore
(
HashMap
<
String
,
Object
>
config
)
{
MVStore
(
HashMap
<
String
,
Object
>
config
)
{
this
.
config
=
config
;
this
.
config
=
config
;
this
.
fileName
=
(
String
)
config
.
get
(
"fileName"
);
this
.
fileName
=
(
String
)
config
.
get
(
"fileName"
);
DataTypeFactory
parent
=
new
ObjectTypeFactory
();
DataTypeFactory
parent
=
new
Object
Data
TypeFactory
();
DataTypeFactory
f
=
(
DataTypeFactory
)
config
.
get
(
"dataTypeFactory"
);
DataTypeFactory
f
=
(
DataTypeFactory
)
config
.
get
(
"dataTypeFactory"
);
if
(
f
==
null
)
{
if
(
f
==
null
)
{
f
=
parent
;
f
=
parent
;
...
@@ -176,7 +182,7 @@ public class MVStore {
...
@@ -176,7 +182,7 @@ public class MVStore {
}
}
this
.
dataTypeFactory
=
f
;
this
.
dataTypeFactory
=
f
;
this
.
readOnly
=
"r"
.
equals
(
config
.
get
(
"openMode"
));
this
.
readOnly
=
"r"
.
equals
(
config
.
get
(
"openMode"
));
this
.
compress
or
=
"0"
.
equals
(
config
.
get
(
"compression"
))
?
null
:
new
CompressLZF
(
);
this
.
compress
=
"1"
.
equals
(
config
.
get
(
"compress"
)
);
if
(
fileName
!=
null
)
{
if
(
fileName
!=
null
)
{
Object
s
=
config
.
get
(
"cacheSize"
);
Object
s
=
config
.
get
(
"cacheSize"
);
int
mb
=
s
==
null
?
16
:
Integer
.
parseInt
(
s
.
toString
());
int
mb
=
s
==
null
?
16
:
Integer
.
parseInt
(
s
.
toString
());
...
@@ -343,7 +349,7 @@ public class MVStore {
...
@@ -343,7 +349,7 @@ public class MVStore {
private
DataType
getDataType
(
Class
<?>
clazz
)
{
private
DataType
getDataType
(
Class
<?>
clazz
)
{
if
(
clazz
==
String
.
class
)
{
if
(
clazz
==
String
.
class
)
{
return
StringType
.
INSTANCE
;
return
String
Data
Type
.
INSTANCE
;
}
}
if
(
dataTypeFactory
==
null
)
{
if
(
dataTypeFactory
==
null
)
{
throw
new
RuntimeException
(
"No data type factory set "
+
throw
new
RuntimeException
(
"No data type factory set "
+
...
@@ -366,7 +372,7 @@ public class MVStore {
...
@@ -366,7 +372,7 @@ public class MVStore {
* Open the store.
* Open the store.
*/
*/
void
open
()
{
void
open
()
{
meta
=
new
MVMap
<
String
,
String
>(
String
Type
.
INSTANCE
,
String
Type
.
INSTANCE
);
meta
=
new
MVMap
<
String
,
String
>(
String
DataType
.
INSTANCE
,
StringData
Type
.
INSTANCE
);
HashMap
<
String
,
String
>
c
=
New
.
hashMap
();
HashMap
<
String
,
String
>
c
=
New
.
hashMap
();
c
.
put
(
"id"
,
"0"
);
c
.
put
(
"id"
,
"0"
);
c
.
put
(
"name"
,
"meta"
);
c
.
put
(
"name"
,
"meta"
);
...
@@ -508,7 +514,6 @@ public class MVStore {
...
@@ -508,7 +514,6 @@ public class MVStore {
m
.
close
();
m
.
close
();
}
}
meta
=
null
;
meta
=
null
;
compressor
=
null
;
chunks
.
clear
();
chunks
.
clear
();
cache
.
clear
();
cache
.
clear
();
maps
.
clear
();
maps
.
clear
();
...
@@ -599,8 +604,17 @@ public class MVStore {
...
@@ -599,8 +604,17 @@ public class MVStore {
}
}
}
while
(
freedChunks
.
size
()
>
0
);
}
while
(
freedChunks
.
size
()
>
0
);
maxLength
+=
meta
.
getRoot
().
getMaxLengthTempRecursive
();
maxLength
+=
meta
.
getRoot
().
getMaxLengthTempRecursive
();
ByteBuffer
buff
;
ByteBuffer
buff
=
ByteBuffer
.
allocate
(
maxLength
);
if
(
maxLength
>
16
*
1024
*
1024
)
{
buff
=
ByteBuffer
.
allocate
(
maxLength
);
}
else
{
if
(
writeBuffer
!=
null
&&
writeBuffer
.
capacity
()
>=
maxLength
)
{
buff
=
writeBuffer
;
buff
.
clear
();
}
else
{
writeBuffer
=
buff
=
ByteBuffer
.
allocate
(
maxLength
+
1024
*
1024
);
}
}
// need to patch the header later
// need to patch the header later
c
.
writeHeader
(
buff
);
c
.
writeHeader
(
buff
);
c
.
maxLength
=
0
;
c
.
maxLength
=
0
;
...
@@ -1008,6 +1022,10 @@ public class MVStore {
...
@@ -1008,6 +1022,10 @@ public class MVStore {
return
compressor
;
return
compressor
;
}
}
boolean
getCompress
()
{
return
compress
;
}
public
boolean
getReuseSpace
()
{
public
boolean
getReuseSpace
()
{
return
reuseSpace
;
return
reuseSpace
;
}
}
...
...
h2/src/main/org/h2/mvstore/MVStoreBuilder.java
浏览文件 @
58dec4b5
...
@@ -75,6 +75,15 @@ public class MVStoreBuilder {
...
@@ -75,6 +75,15 @@ public class MVStoreBuilder {
return
set
(
"cacheSize"
,
Integer
.
toString
(
mb
));
return
set
(
"cacheSize"
,
Integer
.
toString
(
mb
));
}
}
/**
* Enable data compression using the LZF algorithm.
*
* @return this
*/
public
MVStoreBuilder
compressData
()
{
return
set
(
"compress"
,
"1"
);
}
/**
/**
* Use the given data type factory.
* Use the given data type factory.
*
*
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论