Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
1397fe53
提交
1397fe53
authored
12月 17, 2012
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MVStore: improved API thanks to Simo Tripodi.
上级
54d90c04
显示空白字符变更
内嵌
并排
正在显示
19 个修改的文件
包含
479 行增加
和
343 行删除
+479
-343
changelog.html
h2/src/docsrc/html/changelog.html
+1
-0
DataUtils.java
h2/src/main/org/h2/mvstore/DataUtils.java
+6
-2
MVMap.java
h2/src/main/org/h2/mvstore/MVMap.java
+74
-1
MVMapConcurrent.java
h2/src/main/org/h2/mvstore/MVMapConcurrent.java
+53
-0
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+24
-57
MVPrimaryIndex.java
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
+2
-3
MVSecondaryIndex.java
h2/src/main/org/h2/mvstore/db/MVSecondaryIndex.java
+4
-3
ValueDataTypeFactory.java
h2/src/main/org/h2/mvstore/db/ValueDataTypeFactory.java
+0
-5
MVRTreeMap.java
h2/src/main/org/h2/mvstore/rtree/MVRTreeMap.java
+51
-0
DataTypeFactory.java
h2/src/main/org/h2/mvstore/type/DataTypeFactory.java
+0
-11
ObjectDataTypeFactory.java
h2/src/main/org/h2/mvstore/type/ObjectDataTypeFactory.java
+0
-8
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+166
-166
TestBase.java
h2/src/test/org/h2/test/TestBase.java
+1
-1
SampleTypeFactory.java
h2/src/test/org/h2/test/store/SampleTypeFactory.java
+0
-5
SequenceMap.java
h2/src/test/org/h2/test/store/SequenceMap.java
+19
-0
TestConcurrent.java
h2/src/test/org/h2/test/store/TestConcurrent.java
+4
-4
TestMVRTree.java
h2/src/test/org/h2/test/store/TestMVRTree.java
+17
-15
TestMVStore.java
h2/src/test/org/h2/test/store/TestMVStore.java
+56
-61
TestMVTableEngine.java
h2/src/test/org/h2/test/store/TestMVTableEngine.java
+1
-1
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
1397fe53
...
...
@@ -31,6 +31,7 @@ Change Log
</li><li>
New connection setting "DEFAULT_TABLE_ENGINE" to use a specific
table engine if none is set explicitly. This is to simplify testing
the MVStore table engine.
</li><li>
MVStore: improved API thanks to Simo Tripodi.
</li><li>
MVStore: maps can now be renamed.
</li><li>
MVStore: store the file header also at the end of each chunk,
which results in a further reduced number of write operations.
...
...
h2/src/main/org/h2/mvstore/DataUtils.java
浏览文件 @
1397fe53
...
...
@@ -557,14 +557,18 @@ public class DataUtils {
return
new
IllegalStateException
(
message
+
version
());
}
public
static
IllegalStateException
illegalStateException
(
String
message
,
Exception
e
)
{
return
new
IllegalStateException
(
message
+
version
(),
e
);
public
static
IllegalStateException
illegalStateException
(
String
message
,
Exception
caus
e
)
{
return
new
IllegalStateException
(
message
+
version
(),
caus
e
);
}
public
static
IllegalArgumentException
illegalArgumentException
(
String
message
)
{
return
new
IllegalArgumentException
(
message
+
version
());
}
public
static
IllegalArgumentException
illegalArgumentException
(
String
message
,
Exception
cause
)
{
return
new
IllegalArgumentException
(
message
+
version
(),
cause
);
}
public
static
UnsupportedOperationException
unsupportedOperationException
(
String
message
)
{
return
new
UnsupportedOperationException
(
message
+
version
());
}
...
...
h2/src/main/org/h2/mvstore/MVMap.java
浏览文件 @
1397fe53
...
...
@@ -17,6 +17,7 @@ import java.util.Map;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentMap
;
import
org.h2.mvstore.type.DataType
;
import
org.h2.mvstore.type.ObjectDataType
;
import
org.h2.util.New
;
/**
...
...
@@ -47,7 +48,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
private
boolean
closed
;
private
boolean
readOnly
;
p
ublic
MVMap
(
DataType
keyType
,
DataType
valueType
)
{
p
rotected
MVMap
(
DataType
keyType
,
DataType
valueType
)
{
this
.
keyType
=
keyType
;
this
.
valueType
=
valueType
;
this
.
root
=
Page
.
createEmpty
(
this
,
-
1
);
...
...
@@ -1048,4 +1049,76 @@ public class MVMap<K, V> extends AbstractMap<K, V>
return
asString
(
null
);
}
/**
* A builder for maps.
*
* @param <M> the map type
* @param <K> the key type
* @param <V> the value type
*/
public
interface
MapBuilder
<
M
extends
MVMap
<
K
,
V
>,
K
,
V
>
{
/**
* Create a new map of the given type.
*
* @return the map
*/
public
M
create
();
}
/**
* A builder for this class.
*
* @param <K> the key type
* @param <V> the value type
*/
public
static
class
Builder
<
K
,
V
>
implements
MapBuilder
<
MVMap
<
K
,
V
>,
K
,
V
>
{
protected
DataType
keyType
;
protected
DataType
valueType
;
/**
* Create a new builder with the default key and value data types.
*/
public
Builder
()
{
// ignore
}
/**
* Set the key data type.
*
* @param keyType the key type
* @return this
*/
public
Builder
<
K
,
V
>
keyType
(
DataType
keyType
)
{
this
.
keyType
=
keyType
;
return
this
;
}
/**
* Set the key data type.
*
* @param valueType the key type
* @return this
*/
public
Builder
<
K
,
V
>
valueType
(
DataType
valueType
)
{
this
.
valueType
=
valueType
;
return
this
;
}
@Override
public
MVMap
<
K
,
V
>
create
()
{
if
(
keyType
==
null
)
{
keyType
=
new
ObjectDataType
();
}
if
(
valueType
==
null
)
{
valueType
=
new
ObjectDataType
();
}
return
new
MVMap
<
K
,
V
>(
keyType
,
valueType
);
}
}
}
h2/src/main/org/h2/mvstore/MVMapConcurrent.java
浏览文件 @
1397fe53
...
...
@@ -69,4 +69,57 @@ public class MVMapConcurrent<K, V> extends MVMap<K, V> {
return
result
;
}
/**
* A builder for this class.
*
* @param <K> the key type
* @param <V> the value type
*/
public
static
class
Builder
<
K
,
V
>
implements
MapBuilder
<
MVMapConcurrent
<
K
,
V
>,
K
,
V
>
{
protected
DataType
keyType
;
protected
DataType
valueType
;
/**
* Create a new builder with the default key and value data types.
*/
public
Builder
()
{
// ignore
}
/**
* Set the key data type.
*
* @param keyType the key type
* @return this
*/
public
Builder
<
K
,
V
>
keyType
(
DataType
keyType
)
{
this
.
keyType
=
keyType
;
return
this
;
}
/**
* Set the key data type.
*
* @param valueType the key type
* @return this
*/
public
Builder
<
K
,
V
>
valueType
(
DataType
valueType
)
{
this
.
valueType
=
valueType
;
return
this
;
}
@Override
public
MVMapConcurrent
<
K
,
V
>
create
()
{
if
(
keyType
==
null
)
{
keyType
=
new
ObjectDataType
();
}
if
(
valueType
==
null
)
{
valueType
=
new
ObjectDataType
();
}
return
new
MVMapConcurrent
<
K
,
V
>(
keyType
,
valueType
);
}
}
}
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
1397fe53
...
...
@@ -21,7 +21,6 @@ import org.h2.compress.CompressLZF;
import
org.h2.compress.Compressor
;
import
org.h2.mvstore.cache.CacheLongKeyLIRS
;
import
org.h2.mvstore.cache.FilePathCache
;
import
org.h2.mvstore.type.DataType
;
import
org.h2.mvstore.type.DataTypeFactory
;
import
org.h2.mvstore.type.ObjectDataTypeFactory
;
import
org.h2.mvstore.type.StringDataType
;
...
...
@@ -44,7 +43,8 @@ H:3,...
TODO:
- MVStore: improved API thanks to Simo Tripodi
- fix MVStore documentation, example code
- improve exception factory (fluent api)
- implement table engine for H2
- automated 'kill process' and 'power failure' test
- maybe split database into multiple files, to speed up compact
...
...
@@ -121,8 +121,6 @@ public class MVStore {
*/
static
final
int
BLOCK_SIZE
=
4
*
1024
;
private
final
HashMap
<
String
,
Object
>
config
;
private
final
String
fileName
;
private
final
DataTypeFactory
dataTypeFactory
;
...
...
@@ -187,7 +185,6 @@ public class MVStore {
private
boolean
closed
;
MVStore
(
HashMap
<
String
,
Object
>
config
)
{
this
.
config
=
config
;
this
.
fileName
=
(
String
)
config
.
get
(
"fileName"
);
DataTypeFactory
parent
=
new
ObjectDataTypeFactory
();
DataTypeFactory
f
=
(
DataTypeFactory
)
config
.
get
(
"dataTypeFactory"
);
...
...
@@ -242,67 +239,49 @@ public class MVStore {
}
/**
* Open a map with the previous key and value type (if the map already
* exists), or Object if not.
* Open a map with the default settings. The map is automatically create if
* it does not yet exist. If a map with this name is already open, this map
* is returned.
*
* @param <K> the key type
* @param <V> the value type
* @param name the name of the map
* @return the map
*/
@SuppressWarnings
(
"unchecked"
)
public
<
K
,
V
>
MVMap
<
K
,
V
>
openMap
(
String
name
)
{
return
(
MVMap
<
K
,
V
>)
openMap
(
name
,
Object
.
class
,
Object
.
class
);
return
openMap
(
name
,
new
MVMap
.
Builder
<
K
,
V
>()
);
}
/**
* Open a map.
* Open a map with the given builder. The map is automatically create if it
* does not yet exist. If a map with this name is already open, this map is
* returned.
*
* @param <K> the key type
* @param <V> the value type
* @param name the name of the map
* @param keyClass the key class
* @param valueClass the value class
* @param builder the map builder
* @return the map
*/
public
<
K
,
V
>
MVMap
<
K
,
V
>
openMap
(
String
name
,
Class
<
K
>
keyClass
,
Class
<
V
>
valueClass
)
{
checkOpen
();
DataType
keyType
=
getDataType
(
keyClass
);
DataType
valueType
=
getDataType
(
valueClass
);
MVMap
<
K
,
V
>
m
=
new
MVMap
<
K
,
V
>(
keyType
,
valueType
);
return
openMap
(
name
,
m
);
}
/**
* Open a map using the given template. The returned map is of the same type
* as the template, and contains the same key and value types. If a map with
* this name is already open, this map is returned. If it is not open,
* the template object is opened with the applicable configuration.
*
* @param <T> the map type
* @param name the name of the map
* @param template the template map
* @return the opened map
*/
@SuppressWarnings
(
"unchecked"
)
public
<
T
extends
MVMap
<
K
,
V
>,
K
,
V
>
T
openMap
(
String
name
,
T
template
)
{
public
<
M
extends
MVMap
<
K
,
V
>,
K
,
V
>
M
openMap
(
String
name
,
MVMap
.
MapBuilder
<
M
,
K
,
V
>
builder
)
{
checkOpen
();
MVMap
<
K
,
V
>
m
;
String
x
=
meta
.
get
(
"name."
+
name
);
int
id
;
long
root
;
HashMap
<
String
,
String
>
c
;
M
map
;
if
(
x
!=
null
)
{
id
=
Integer
.
parseInt
(
x
);
m
=
(
MVMap
<
K
,
V
>)
maps
.
get
(
id
);
if
(
m
!=
null
)
{
return
(
T
)
m
;
@SuppressWarnings
(
"unchecked"
)
M
old
=
(
M
)
maps
.
get
(
id
);
if
(
old
!=
null
)
{
return
old
;
}
m
=
template
;
m
ap
=
builder
.
create
()
;
String
config
=
meta
.
get
(
"map."
+
x
);
c
=
DataUtils
.
parseMap
(
config
);
c
.
put
(
"id"
,
x
);
m
.
open
(
this
,
c
);
m
ap
.
open
(
this
,
c
);
String
r
=
meta
.
get
(
"root."
+
id
);
root
=
r
==
null
?
0
:
Long
.
parseLong
(
r
);
}
else
{
...
...
@@ -310,15 +289,15 @@ public class MVStore {
id
=
++
lastMapId
;
c
.
put
(
"id"
,
Integer
.
toString
(
id
));
c
.
put
(
"createVersion"
,
Long
.
toString
(
currentVersion
));
m
=
template
;
m
.
open
(
this
,
c
);
meta
.
put
(
"map."
+
id
,
m
.
asString
(
name
));
m
ap
=
builder
.
create
()
;
m
ap
.
open
(
this
,
c
);
meta
.
put
(
"map."
+
id
,
m
ap
.
asString
(
name
));
meta
.
put
(
"name."
+
name
,
Integer
.
toString
(
id
));
root
=
0
;
}
m
.
setRootPos
(
root
,
-
1
);
maps
.
put
(
id
,
m
);
return
(
T
)
m
;
m
ap
.
setRootPos
(
root
,
-
1
);
maps
.
put
(
id
,
m
ap
);
return
map
;
}
/**
...
...
@@ -377,14 +356,6 @@ public class MVStore {
maps
.
remove
(
id
);
}
private
DataType
getDataType
(
Class
<?>
clazz
)
{
if
(
clazz
==
String
.
class
)
{
return
StringDataType
.
INSTANCE
;
}
String
s
=
dataTypeFactory
.
getDataType
(
clazz
);
return
dataTypeFactory
.
buildDataType
(
s
);
}
/**
* Mark a map as changed (containing unsaved changes).
*
...
...
@@ -1372,10 +1343,6 @@ public class MVStore {
}
}
public
String
toString
()
{
return
DataUtils
.
appendMap
(
new
StringBuilder
(),
config
).
toString
();
}
void
renameMap
(
MVMap
<?,
?>
map
,
String
newName
)
{
checkOpen
();
if
(
map
==
meta
)
{
...
...
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
浏览文件 @
1397fe53
...
...
@@ -18,7 +18,6 @@ import org.h2.index.Cursor;
import
org.h2.index.IndexType
;
import
org.h2.message.DbException
;
import
org.h2.mvstore.MVMap
;
import
org.h2.mvstore.type.ObjectDataType
;
import
org.h2.result.Row
;
import
org.h2.result.SearchRow
;
import
org.h2.result.SortOrder
;
...
...
@@ -47,8 +46,8 @@ public class MVPrimaryIndex extends BaseIndex {
}
ValueArrayDataType
t
=
new
ValueArrayDataType
(
db
.
getCompareMode
(),
db
,
sortTypes
);
map
=
new
MVMap
<
Long
,
Value
[]>(
new
ObjectDataType
(),
t
);
map
=
table
.
getStore
().
openMap
(
getName
()
+
"_"
+
getId
(),
map
);
map
=
table
.
getStore
().
openMap
(
getName
()
+
"_"
+
getId
(),
new
MVMap
.
Builder
<
Long
,
Value
[]>().
valueType
(
t
)
);
Long
k
=
map
.
lastKey
();
lastKey
=
k
==
null
?
0
:
k
;
}
...
...
h2/src/main/org/h2/mvstore/db/MVSecondaryIndex.java
浏览文件 @
1397fe53
...
...
@@ -17,7 +17,6 @@ import org.h2.index.Cursor;
import
org.h2.index.IndexType
;
import
org.h2.message.DbException
;
import
org.h2.mvstore.MVMap
;
import
org.h2.mvstore.type.ObjectDataType
;
import
org.h2.result.Row
;
import
org.h2.result.SearchRow
;
import
org.h2.result.SortOrder
;
...
...
@@ -52,10 +51,12 @@ public class MVSecondaryIndex extends BaseIndex {
sortTypes
[
i
]
=
columns
[
i
].
sortType
;
}
sortTypes
[
keyColumns
-
1
]
=
SortOrder
.
ASCENDING
;
String
name
=
getName
()
+
"_"
+
getId
();
ValueArrayDataType
t
=
new
ValueArrayDataType
(
db
.
getCompareMode
(),
db
,
sortTypes
);
map
=
new
MVMap
<
Value
[],
Long
>(
t
,
new
ObjectDataType
());
map
=
table
.
getStore
().
openMap
(
getName
()
+
"_"
+
getId
(),
map
);
map
=
table
.
getStore
().
openMap
(
name
,
new
MVMap
.
Builder
<
Value
[],
Long
>().
keyType
(
t
));
}
private
static
void
checkIndexColumnTypes
(
IndexColumn
[]
columns
)
{
...
...
h2/src/main/org/h2/mvstore/db/ValueDataTypeFactory.java
浏览文件 @
1397fe53
...
...
@@ -37,9 +37,4 @@ public class ValueDataTypeFactory implements DataTypeFactory {
return
parent
.
buildDataType
(
s
);
}
@Override
public
String
getDataType
(
Class
<?>
objectClass
)
{
return
parent
.
getDataType
(
objectClass
);
}
}
h2/src/main/org/h2/mvstore/rtree/MVRTreeMap.java
浏览文件 @
1397fe53
...
...
@@ -13,6 +13,8 @@ import org.h2.mvstore.CursorPos;
import
org.h2.mvstore.MVMap
;
import
org.h2.mvstore.Page
;
import
org.h2.mvstore.type.DataType
;
import
org.h2.mvstore.type.ObjectDataType
;
import
org.h2.mvstore.type.StringDataType
;
import
org.h2.util.New
;
/**
...
...
@@ -541,4 +543,53 @@ public class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
return
"rtree"
;
}
/**
* A builder for this class.
*
* @param <V> the value type
*/
public
static
class
Builder
<
V
>
implements
MVMap
.
MapBuilder
<
MVRTreeMap
<
V
>,
SpatialKey
,
V
>
{
private
int
dimensions
=
2
;
private
DataType
valueType
;
/**
* Create a new builder for maps with 2 dimensions.
*/
public
Builder
()
{
// default
}
/**
* Set the dimensions.
*
* @param dimensions the dimensions to use
* @return this
*/
public
Builder
<
V
>
dimensions
(
int
dimensions
)
{
this
.
dimensions
=
dimensions
;
return
this
;
}
/**
* Set the key data type.
*
* @param valueType the key type
* @return this
*/
public
Builder
<
V
>
valueType
(
StringDataType
valueType
)
{
this
.
valueType
=
valueType
;
return
this
;
}
public
MVRTreeMap
<
V
>
create
()
{
if
(
valueType
==
null
)
{
valueType
=
new
ObjectDataType
();
}
return
new
MVRTreeMap
<
V
>(
dimensions
,
valueType
);
}
}
}
h2/src/main/org/h2/mvstore/type/DataTypeFactory.java
浏览文件 @
1397fe53
...
...
@@ -26,15 +26,4 @@ public interface DataTypeFactory {
*/
DataType
buildDataType
(
String
dataType
);
/**
* Get the data type identifier for the given class.
* <p>
* To avoid conflict with the default factory, the returned string should
* start with the package name of the type factory.
*
* @param objectClass the class
* @return the data type identifier, or null if not supported
*/
String
getDataType
(
Class
<?>
objectClass
);
}
h2/src/main/org/h2/mvstore/type/ObjectDataTypeFactory.java
浏览文件 @
1397fe53
...
...
@@ -27,12 +27,4 @@ public class ObjectDataTypeFactory implements DataTypeFactory {
return
null
;
}
@Override
public
String
getDataType
(
Class
<?>
objectClass
)
{
if
(
objectClass
==
SpatialDataType
.
class
)
{
return
"s"
;
}
return
"o"
;
}
}
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
1397fe53
...
...
@@ -556,123 +556,123 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
beforeTest
();
// db
new
TestScriptSimple
().
runTest
(
this
);
new
TestScript
().
runTest
(
this
);
new
TestAlter
().
runTest
(
this
);
new
TestAlterSchemaRename
().
runTest
(
this
);
new
TestAutoRecompile
().
runTest
(
this
);
new
TestBitField
().
runTest
(
this
);
new
TestBackup
().
runTest
(
this
);
new
TestBigDb
().
runTest
(
this
);
new
TestBigResult
().
runTest
(
this
);
new
TestCases
().
runTest
(
this
);
new
TestCheckpoint
().
runTest
(
this
);
new
TestCluster
().
runTest
(
this
);
new
TestCompatibility
().
runTest
(
this
);
new
TestCsv
().
runTest
(
this
);
new
TestDateStorage
().
runTest
(
this
);
new
TestDeadlock
().
runTest
(
this
);
new
TestEncryptedDb
().
runTest
(
this
);
new
TestExclusive
().
runTest
(
this
);
new
TestFullText
().
runTest
(
this
);
new
TestFunctionOverload
().
runTest
(
this
);
new
TestFunctions
().
runTest
(
this
);
new
TestInit
().
runTest
(
this
);
new
TestIndex
().
runTest
(
this
);
new
TestLargeBlob
().
runTest
(
this
);
new
TestLinkedTable
().
runTest
(
this
);
new
TestListener
().
runTest
(
this
);
// verify
new
TestLob
().
runTest
(
this
);
new
TestMemoryUsage
().
runTest
(
this
);
new
TestMultiConn
().
runTest
(
this
);
new
TestMultiDimension
().
runTest
(
this
);
new
TestMultiThread
().
runTest
(
this
);
new
TestMultiThreadedKernel
().
runTest
(
this
);
new
TestOpenClose
().
runTest
(
this
);
new
TestOptimizations
().
runTest
(
this
);
new
TestOutOfMemory
().
runTest
(
this
);
new
TestPowerOff
().
runTest
(
this
);
new
TestQueryCache
().
runTest
(
this
);
new
TestReadOnly
().
runTest
(
this
);
new
TestRecursiveQueries
().
runTest
(
this
);
new
TestRights
().
runTest
(
this
);
// verify
new
TestRunscript
().
runTest
(
this
);
new
TestSQLInjection
().
runTest
(
this
);
// verify
new
TestSessionsLocks
().
runTest
(
this
);
new
TestSelectCountNonNullColumn
().
runTest
(
this
);
new
TestSequence
().
runTest
(
this
);
new
TestSpaceReuse
().
runTest
(
this
);
new
TestSpeed
().
runTest
(
this
);
new
TestTableEngines
().
runTest
(
this
);
new
TestTempTables
().
runTest
(
this
);
new
TestTransaction
().
runTest
(
this
);
new
TestTriggersConstraints
().
runTest
(
this
);
new
TestTwoPhaseCommit
().
runTest
(
this
);
new
TestView
().
runTest
(
this
);
new
TestViewAlterTable
().
runTest
(
this
);
new
TestViewDropView
().
runTest
(
this
);
// jaqu
new
AliasMapTest
().
runTest
(
this
);
new
AnnotationsTest
().
runTest
(
this
);
new
ClobTest
().
runTest
(
this
);
new
ModelsTest
().
runTest
(
this
);
new
SamplesTest
().
runTest
(
this
);
new
UpdateTest
().
runTest
(
this
);
// jdbc
new
TestBatchUpdates
().
runTest
(
this
);
new
TestCallableStatement
().
runTest
(
this
);
new
TestCancel
().
runTest
(
this
);
new
TestDatabaseEventListener
().
runTest
(
this
);
new
TestDriver
().
runTest
(
this
);
new
TestJavaObject
().
runTest
(
this
);
new
TestLimitUpdates
().
runTest
(
this
);
new
TestLobApi
().
runTest
(
this
);
new
TestManyJdbcObjects
().
runTest
(
this
);
new
TestMetaData
().
runTest
(
this
);
new
TestNativeSQL
().
runTest
(
this
);
new
TestPreparedStatement
().
runTest
(
this
);
new
TestResultSet
().
runTest
(
this
);
new
TestStatement
().
runTest
(
this
);
new
TestTransactionIsolation
().
runTest
(
this
);
new
TestUpdatableResultSet
().
runTest
(
this
);
new
TestZloty
().
runTest
(
this
);
// jdbcx
new
TestConnectionPool
().
runTest
(
this
);
new
TestDataSource
().
runTest
(
this
);
new
TestXA
().
runTest
(
this
);
new
TestXASimple
().
runTest
(
this
);
// server
new
TestAutoServer
().
runTest
(
this
);
new
TestNestedLoop
().
runTest
(
this
);
new
TestWeb
().
runTest
(
this
);
// mvcc & row level locking
new
TestMvcc1
().
runTest
(
this
);
new
TestMvcc2
().
runTest
(
this
);
new
TestMvcc3
().
runTest
(
this
);
new
TestMvccMultiThreaded
().
runTest
(
this
);
new
TestRowLocks
().
runTest
(
this
);
// synth
new
TestBtreeIndex
().
runTest
(
this
);
new
TestDiskFull
().
runTest
(
this
);
new
TestCrashAPI
().
runTest
(
this
);
new
TestFuzzOptimizations
().
runTest
(
this
);
new
TestLimit
().
runTest
(
this
);
new
TestRandomSQL
().
runTest
(
this
);
new
TestRandomCompare
().
runTest
(
this
);
new
TestKillRestart
().
runTest
(
this
);
new
TestKillRestartMulti
().
runTest
(
this
);
new
TestMultiThreaded
().
runTest
(
this
);
new
TestOuterJoins
().
runTest
(
this
);
new
TestNestedJoins
().
runTest
(
this
);
//
new TestScriptSimple().runTest(this);
//
new TestScript().runTest(this);
//
new TestAlter().runTest(this);
//
new TestAlterSchemaRename().runTest(this);
//
new TestAutoRecompile().runTest(this);
//
new TestBitField().runTest(this);
//
new TestBackup().runTest(this);
//
new TestBigDb().runTest(this);
//
new TestBigResult().runTest(this);
//
new TestCases().runTest(this);
//
new TestCheckpoint().runTest(this);
//
new TestCluster().runTest(this);
//
new TestCompatibility().runTest(this);
//
new TestCsv().runTest(this);
//
new TestDateStorage().runTest(this);
//
new TestDeadlock().runTest(this);
//
new TestEncryptedDb().runTest(this);
//
new TestExclusive().runTest(this);
//
new TestFullText().runTest(this);
//
new TestFunctionOverload().runTest(this);
//
new TestFunctions().runTest(this);
//
new TestInit().runTest(this);
//
new TestIndex().runTest(this);
//
new TestLargeBlob().runTest(this);
//
new TestLinkedTable().runTest(this);
//
new TestListener().runTest(this);
//
// verify
//
new TestLob().runTest(this);
//
new TestMemoryUsage().runTest(this);
//
new TestMultiConn().runTest(this);
//
new TestMultiDimension().runTest(this);
//
new TestMultiThread().runTest(this);
//
new TestMultiThreadedKernel().runTest(this);
//
new TestOpenClose().runTest(this);
//
new TestOptimizations().runTest(this);
//
new TestOutOfMemory().runTest(this);
//
new TestPowerOff().runTest(this);
//
new TestQueryCache().runTest(this);
//
new TestReadOnly().runTest(this);
//
new TestRecursiveQueries().runTest(this);
//
new TestRights().runTest(this);
//
// verify
//
new TestRunscript().runTest(this);
//
new TestSQLInjection().runTest(this);
//
// verify
//
new TestSessionsLocks().runTest(this);
//
new TestSelectCountNonNullColumn().runTest(this);
//
new TestSequence().runTest(this);
//
new TestSpaceReuse().runTest(this);
//
new TestSpeed().runTest(this);
//
new TestTableEngines().runTest(this);
//
new TestTempTables().runTest(this);
//
new TestTransaction().runTest(this);
//
new TestTriggersConstraints().runTest(this);
//
new TestTwoPhaseCommit().runTest(this);
//
new TestView().runTest(this);
//
new TestViewAlterTable().runTest(this);
//
new TestViewDropView().runTest(this);
//
//
// jaqu
//
new AliasMapTest().runTest(this);
//
new AnnotationsTest().runTest(this);
//
new ClobTest().runTest(this);
//
new ModelsTest().runTest(this);
//
new SamplesTest().runTest(this);
//
new UpdateTest().runTest(this);
//
//
// jdbc
//
new TestBatchUpdates().runTest(this);
//
new TestCallableStatement().runTest(this);
//
new TestCancel().runTest(this);
//
new TestDatabaseEventListener().runTest(this);
//
new TestDriver().runTest(this);
//
new TestJavaObject().runTest(this);
//
new TestLimitUpdates().runTest(this);
//
new TestLobApi().runTest(this);
//
new TestManyJdbcObjects().runTest(this);
//
new TestMetaData().runTest(this);
//
new TestNativeSQL().runTest(this);
//
new TestPreparedStatement().runTest(this);
//
new TestResultSet().runTest(this);
//
new TestStatement().runTest(this);
//
new TestTransactionIsolation().runTest(this);
//
new TestUpdatableResultSet().runTest(this);
//
new TestZloty().runTest(this);
//
//
// jdbcx
//
new TestConnectionPool().runTest(this);
//
new TestDataSource().runTest(this);
//
new TestXA().runTest(this);
//
new TestXASimple().runTest(this);
//
//
// server
//
new TestAutoServer().runTest(this);
//
new TestNestedLoop().runTest(this);
//
new TestWeb().runTest(this);
//
//
// mvcc & row level locking
//
new TestMvcc1().runTest(this);
//
new TestMvcc2().runTest(this);
//
new TestMvcc3().runTest(this);
//
new TestMvccMultiThreaded().runTest(this);
//
new TestRowLocks().runTest(this);
//
//
// synth
//
new TestBtreeIndex().runTest(this);
//
new TestDiskFull().runTest(this);
//
new TestCrashAPI().runTest(this);
//
new TestFuzzOptimizations().runTest(this);
//
new TestLimit().runTest(this);
//
new TestRandomSQL().runTest(this);
//
new TestRandomCompare().runTest(this);
//
new TestKillRestart().runTest(this);
//
new TestKillRestartMulti().runTest(this);
//
new TestMultiThreaded().runTest(this);
//
new TestOuterJoins().runTest(this);
//
new TestNestedJoins().runTest(this);
afterTest
();
}
...
...
@@ -691,55 +691,55 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
new
TestStreamStore
().
runTest
(
this
);
// unit
new
TestAutoReconnect
().
runTest
(
this
);
new
TestCache
().
runTest
(
this
);
new
TestClearReferences
().
runTest
(
this
);
new
TestCollation
().
runTest
(
this
);
new
TestCompress
().
runTest
(
this
);
new
TestConnectionInfo
().
runTest
(
this
);
new
TestDataPage
().
runTest
(
this
);
new
TestDate
().
runTest
(
this
);
new
TestDateIso8601
().
runTest
(
this
);
new
TestExit
().
runTest
(
this
);
new
TestFile
().
runTest
(
this
);
new
TestFileLock
().
runTest
(
this
);
new
TestFileLockProcess
().
runTest
(
this
);
new
TestFileLockSerialized
().
runTest
(
this
);
new
TestFtp
().
runTest
(
this
);
new
TestFileSystem
().
runTest
(
this
);
new
TestIntArray
().
runTest
(
this
);
new
TestIntIntHashMap
().
runTest
(
this
);
// verify
new
TestJmx
().
runTest
(
this
);
new
TestMathUtils
().
runTest
(
this
);
new
TestModifyOnWrite
().
runTest
(
this
);
new
TestOldVersion
().
runTest
(
this
);
new
TestNetUtils
().
runTest
(
this
);
new
TestObjectDeserialization
().
runTest
(
this
);
new
TestMultiThreadedKernel
().
runTest
(
this
);
new
TestOverflow
().
runTest
(
this
);
new
TestPageStore
().
runTest
(
this
);
new
TestPageStoreCoverage
().
runTest
(
this
);
new
TestPattern
().
runTest
(
this
);
new
TestPgServer
().
runTest
(
this
);
new
TestReader
().
runTest
(
this
);
new
TestRecovery
().
runTest
(
this
);
new
TestSampleApps
().
runTest
(
this
);
new
TestScriptReader
().
runTest
(
this
);
runTest
(
"org.h2.test.unit.TestServlet"
);
new
TestSecurity
().
runTest
(
this
);
new
TestShell
().
runTest
(
this
);
new
TestSort
().
runTest
(
this
);
new
TestStreams
().
runTest
(
this
);
new
TestStringCache
().
runTest
(
this
);
new
TestStringUtils
().
runTest
(
this
);
new
TestTools
().
runTest
(
this
);
new
TestTraceSystem
().
runTest
(
this
);
new
TestUpgrade
().
runTest
(
this
);
new
TestUtils
().
runTest
(
this
);
new
TestValue
().
runTest
(
this
);
new
TestValueHashMap
().
runTest
(
this
);
new
TestValueMemory
().
runTest
(
this
);
//
new TestAutoReconnect().runTest(this);
//
new TestCache().runTest(this);
//
new TestClearReferences().runTest(this);
//
new TestCollation().runTest(this);
//
new TestCompress().runTest(this);
//
new TestConnectionInfo().runTest(this);
//
new TestDataPage().runTest(this);
//
new TestDate().runTest(this);
//
new TestDateIso8601().runTest(this);
//
new TestExit().runTest(this);
//
new TestFile().runTest(this);
//
new TestFileLock().runTest(this);
//
new TestFileLockProcess().runTest(this);
//
new TestFileLockSerialized().runTest(this);
//
new TestFtp().runTest(this);
//
new TestFileSystem().runTest(this);
//
new TestIntArray().runTest(this);
//
new TestIntIntHashMap().runTest(this);
//
// verify
//
new TestJmx().runTest(this);
//
new TestMathUtils().runTest(this);
//
new TestModifyOnWrite().runTest(this);
//
new TestOldVersion().runTest(this);
//
new TestNetUtils().runTest(this);
//
new TestObjectDeserialization().runTest(this);
//
new TestMultiThreadedKernel().runTest(this);
//
new TestOverflow().runTest(this);
//
new TestPageStore().runTest(this);
//
new TestPageStoreCoverage().runTest(this);
//
new TestPattern().runTest(this);
//
new TestPgServer().runTest(this);
//
new TestReader().runTest(this);
//
new TestRecovery().runTest(this);
//
new TestSampleApps().runTest(this);
//
new TestScriptReader().runTest(this);
//
runTest("org.h2.test.unit.TestServlet");
//
new TestSecurity().runTest(this);
//
new TestShell().runTest(this);
//
new TestSort().runTest(this);
//
new TestStreams().runTest(this);
//
new TestStringCache().runTest(this);
//
new TestStringUtils().runTest(this);
//
new TestTools().runTest(this);
//
new TestTraceSystem().runTest(this);
//
new TestUpgrade().runTest(this);
//
new TestUtils().runTest(this);
//
new TestValue().runTest(this);
//
new TestValueHashMap().runTest(this);
//
new TestValueMemory().runTest(this);
}
private
void
runTest
(
String
className
)
{
...
...
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
1397fe53
...
...
@@ -267,7 +267,7 @@ public abstract class TestBase {
url
=
name
;
}
int
test
;
//
url = addOption(url, "DEFAULT_TABLE_ENGINE", MVTableEngine.class.getName());
url
=
addOption
(
url
,
"DEFAULT_TABLE_ENGINE"
,
MVTableEngine
.
class
.
getName
());
if
(!
config
.
memory
)
{
if
(
config
.
smallLog
&&
admin
)
{
url
=
addOption
(
url
,
"MAX_LOG_SIZE"
,
"1"
);
...
...
h2/src/test/org/h2/test/store/SampleTypeFactory.java
浏览文件 @
1397fe53
...
...
@@ -27,9 +27,4 @@ public class SampleTypeFactory implements DataTypeFactory {
return
parent
.
buildDataType
(
s
);
}
@Override
public
String
getDataType
(
Class
<?>
objectClass
)
{
return
parent
.
getDataType
(
objectClass
);
}
}
h2/src/test/org/h2/test/store/SequenceMap.java
浏览文件 @
1397fe53
...
...
@@ -71,4 +71,23 @@ public class SequenceMap extends MVMap<Long, Long> {
};
}
/**
* A builder for this class.
*/
public
static
class
Builder
implements
MapBuilder
<
SequenceMap
,
Long
,
Long
>
{
/**
* Create a new builder.
*/
public
Builder
()
{
// ignore
}
@Override
public
SequenceMap
create
()
{
return
new
SequenceMap
();
}
}
}
h2/src/test/org/h2/test/store/TestConcurrent.java
浏览文件 @
1397fe53
...
...
@@ -50,8 +50,8 @@ public class TestConcurrent extends TestMVStore {
*/
private
void
testConcurrentMap
()
throws
InterruptedException
{
final
MVStore
s
=
openStore
(
null
);
final
MVMap
<
Integer
,
Integer
>
cm
=
MVMapConcurrent
.
create
();
final
MVMap
<
Integer
,
Integer
>
m
=
s
.
openMap
(
"data"
,
cm
);
final
MVMap
<
Integer
,
Integer
>
m
=
s
.
openMap
(
"data"
,
new
MVMapConcurrent
.
Builder
<
Integer
,
Integer
>()
);
final
int
size
=
20
;
final
Random
rand
=
new
Random
(
1
);
Task
task
=
new
Task
()
{
...
...
@@ -210,7 +210,7 @@ public class TestConcurrent extends TestMVStore {
*/
private
void
testConcurrentWrite
()
throws
InterruptedException
{
final
MVStore
s
=
openStore
(
null
);
final
MVMap
<
Integer
,
Integer
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
Integer
.
class
);
final
MVMap
<
Integer
,
Integer
>
m
=
s
.
openMap
(
"data"
);
final
int
size
=
20
;
final
Random
rand
=
new
Random
(
1
);
Task
task
=
new
Task
()
{
...
...
@@ -265,7 +265,7 @@ public class TestConcurrent extends TestMVStore {
private
void
testConcurrentRead
()
throws
InterruptedException
{
final
MVStore
s
=
openStore
(
null
);
final
MVMap
<
Integer
,
Integer
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
Integer
.
class
);
final
MVMap
<
Integer
,
Integer
>
m
=
s
.
openMap
(
"data"
);
final
int
size
=
3
;
int
x
=
(
int
)
s
.
getCurrentVersion
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
...
...
h2/src/test/org/h2/test/store/TestMVRTree.java
浏览文件 @
1397fe53
...
...
@@ -23,7 +23,6 @@ import javax.imageio.stream.FileImageOutputStream;
import
org.h2.mvstore.MVStore
;
import
org.h2.mvstore.rtree.MVRTreeMap
;
import
org.h2.mvstore.rtree.SpatialKey
;
import
org.h2.mvstore.type.ObjectDataType
;
import
org.h2.mvstore.type.StringDataType
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.test.TestBase
;
...
...
@@ -54,12 +53,9 @@ public class TestMVRTree extends TestMVStore {
// create an in-memory store
MVStore
s
=
MVStore
.
open
(
null
);
// create an R-tree map
// the key has 2 dimensions, the value is a string
MVRTreeMap
<
String
>
r
=
MVRTreeMap
.
create
(
2
,
new
ObjectDataType
());
// open the map
r
=
s
.
openMap
(
"data"
,
r
);
// open an R-tree map
MVRTreeMap
<
String
>
r
=
s
.
openMap
(
"data"
,
new
MVRTreeMap
.
Builder
<
String
>());
// add two key-value pairs
// the first value is the key id (to make the key unique)
...
...
@@ -84,8 +80,9 @@ public class TestMVRTree extends TestMVStore {
MVStore
s
;
s
=
openStore
(
fileName
);
// s.setMaxPageSize(50);
MVRTreeMap
<
String
>
r
=
MVRTreeMap
.
create
(
2
,
StringDataType
.
INSTANCE
);
r
=
s
.
openMap
(
"data"
,
r
);
MVRTreeMap
<
String
>
r
=
s
.
openMap
(
"data"
,
new
MVRTreeMap
.
Builder
<
String
>().
dimensions
(
2
).
valueType
(
StringDataType
.
INSTANCE
));
// r.setQuadraticSplit(true);
Random
rand
=
new
Random
(
1
);
int
len
=
1000
;
...
...
@@ -109,8 +106,9 @@ public class TestMVRTree extends TestMVStore {
s
.
store
();
s
.
close
();
s
=
openStore
(
fileName
);
r
=
MVRTreeMap
.
create
(
2
,
StringDataType
.
INSTANCE
);
r
=
s
.
openMap
(
"data"
,
r
);
r
=
s
.
openMap
(
"data"
,
new
MVRTreeMap
.
Builder
<
String
>().
dimensions
(
2
).
valueType
(
StringDataType
.
INSTANCE
));
// t = System.currentTimeMillis();
rand
=
new
Random
(
1
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
...
...
@@ -148,8 +146,10 @@ public class TestMVRTree extends TestMVStore {
FileUtils
.
delete
(
fileName
);
MVStore
s
;
s
=
openStore
(
fileName
);
MVRTreeMap
<
String
>
r
=
MVRTreeMap
.
create
(
2
,
StringDataType
.
INSTANCE
);
r
=
s
.
openMap
(
"data"
,
r
);
MVRTreeMap
<
String
>
r
=
s
.
openMap
(
"data"
,
new
MVRTreeMap
.
Builder
<
String
>().
dimensions
(
2
).
valueType
(
StringDataType
.
INSTANCE
));
add
(
r
,
"Bern"
,
key
(
0
,
46.57
,
7.27
,
124381
));
add
(
r
,
"Basel"
,
key
(
1
,
47.34
,
7.36
,
170903
));
add
(
r
,
"Zurich"
,
key
(
2
,
47.22
,
8.33
,
376008
));
...
...
@@ -273,9 +273,11 @@ public class TestMVRTree extends TestMVStore {
String
fileName
=
getBaseDir
()
+
"/testRandom.h3"
;
FileUtils
.
delete
(
fileName
);
MVStore
s
=
openStore
(
fileName
);
MVRTreeMap
<
String
>
m
=
MVRTreeMap
.
create
(
2
,
StringDataType
.
INSTANCE
);
MVRTreeMap
<
String
>
m
=
s
.
openMap
(
"data"
,
new
MVRTreeMap
.
Builder
<
String
>());
m
.
setQuadraticSplit
(
quadraticSplit
);
m
=
s
.
openMap
(
"data"
,
m
);
HashMap
<
SpatialKey
,
String
>
map
=
new
HashMap
<
SpatialKey
,
String
>();
Random
rand
=
new
Random
(
1
);
int
operationCount
=
1000
;
...
...
h2/src/test/org/h2/test/store/TestMVStore.java
浏览文件 @
1397fe53
...
...
@@ -91,8 +91,7 @@ public class TestMVStore extends TestBase {
String
fileName
=
getBaseDir
()
+
"/testMapType.h3"
;
FileUtils
.
delete
(
fileName
);
MVStore
s
=
openStore
(
fileName
);
SequenceMap
seq
=
new
SequenceMap
();
seq
=
s
.
openMap
(
"data"
,
seq
);
SequenceMap
seq
=
s
.
openMap
(
"data"
,
new
SequenceMap
.
Builder
());
StringBuilder
buff
=
new
StringBuilder
();
for
(
long
x
:
seq
.
keySet
())
{
buff
.
append
(
x
).
append
(
';'
);
...
...
@@ -455,8 +454,7 @@ public class TestMVStore extends TestBase {
// long t = System.currentTimeMillis();
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
MVStore
s
=
openStore
(
fileName
);
Map
<
String
,
Integer
>
m
=
s
.
openMap
(
"data"
,
String
.
class
,
Integer
.
class
);
Map
<
String
,
Integer
>
m
=
s
.
openMap
(
"data"
);
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
Integer
x
=
m
.
get
(
"value"
);
m
.
put
(
"value"
,
x
==
null
?
0
:
x
+
1
);
...
...
@@ -474,7 +472,7 @@ public class TestMVStore extends TestBase {
FileUtils
.
delete
(
fileName
);
MVStore
s
=
openStore
(
fileName
);
s
.
setPageSize
(
6
);
MVMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
MVMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
);
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
m
.
put
(
i
,
"Hi"
);
}
...
...
@@ -508,7 +506,7 @@ public class TestMVStore extends TestBase {
MVStore
s
;
s
=
openStore
(
fileName
);
MVMap
<
String
,
String
>
m
;
m
=
s
.
openMap
(
"data"
,
String
.
class
,
String
.
class
);
m
=
s
.
openMap
(
"data"
);
long
first
=
s
.
getCurrentVersion
();
s
.
incrementVersion
();
m
.
put
(
"1"
,
"Hello"
);
...
...
@@ -547,7 +545,7 @@ public class TestMVStore extends TestBase {
s
.
close
();
s
=
openStore
(
fileName
);
m
=
s
.
openMap
(
"data"
,
String
.
class
,
String
.
class
);
m
=
s
.
openMap
(
"data"
);
assertEquals
(
"Hi"
,
m
.
get
(
"1"
));
assertEquals
(
null
,
m
.
get
(
"2"
));
...
...
@@ -563,7 +561,7 @@ public class TestMVStore extends TestBase {
MVStore
s
;
MVMap
<
Integer
,
String
>
m
;
s
=
openStore
(
fileName
);
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
m
=
s
.
openMap
(
"data"
);
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
m
.
put
(
i
,
"Hello World"
);
}
...
...
@@ -572,7 +570,7 @@ public class TestMVStore extends TestBase {
long
len
=
FileUtils
.
size
(
fileName
);
s
=
openStore
(
fileName
);
s
.
setRetentionTime
(
0
);
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
m
=
s
.
openMap
(
"data"
);
m
.
clear
();
s
.
store
();
s
.
compact
(
100
);
...
...
@@ -588,7 +586,7 @@ public class TestMVStore extends TestBase {
MVMap
<
Integer
,
String
>
m
;
s
=
openStore
(
fileName
);
s
.
setPageSize
(
700
);
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
m
=
s
.
openMap
(
"data"
);
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
m
.
put
(
i
,
"Hello World"
);
assertEquals
(
i
+
1
,
m
.
size
());
...
...
@@ -600,7 +598,7 @@ public class TestMVStore extends TestBase {
s
.
close
();
s
=
openStore
(
fileName
);
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
m
=
s
.
openMap
(
"data"
);
m
.
clear
();
assertEquals
(
0
,
m
.
size
());
s
.
store
();
...
...
@@ -622,9 +620,9 @@ public class TestMVStore extends TestBase {
assertEquals
(
45
,
s
.
getRetentionTime
());
assertEquals
(
0
,
s
.
getCurrentVersion
());
assertFalse
(
s
.
hasUnsavedChanges
());
MVMap
<
String
,
String
>
m
=
s
.
openMap
(
"data"
,
String
.
class
,
String
.
class
);
MVMap
<
String
,
String
>
m
=
s
.
openMap
(
"data"
);
assertTrue
(
s
.
hasUnsavedChanges
());
MVMap
<
String
,
String
>
m0
=
s
.
openMap
(
"data0"
,
String
.
class
,
String
.
class
);
MVMap
<
String
,
String
>
m0
=
s
.
openMap
(
"data0"
);
m
.
put
(
"1"
,
"Hello"
);
assertEquals
(
1
,
s
.
incrementVersion
());
s
.
rollbackTo
(
1
);
...
...
@@ -638,9 +636,9 @@ public class TestMVStore extends TestBase {
s
=
openStore
(
fileName
);
assertEquals
(
2
,
s
.
getCurrentVersion
());
meta
=
s
.
getMetaMap
();
m
=
s
.
openMap
(
"data"
,
String
.
class
,
String
.
class
);
m0
=
s
.
openMap
(
"data0"
,
String
.
class
,
String
.
class
);
MVMap
<
String
,
String
>
m1
=
s
.
openMap
(
"data1"
,
String
.
class
,
String
.
class
);
m
=
s
.
openMap
(
"data"
);
m0
=
s
.
openMap
(
"data0"
);
MVMap
<
String
,
String
>
m1
=
s
.
openMap
(
"data1"
);
m
.
put
(
"1"
,
"Hallo"
);
m0
.
put
(
"1"
,
"Hallo"
);
m1
.
put
(
"1"
,
"Hallo"
);
...
...
@@ -661,8 +659,8 @@ public class TestMVStore extends TestBase {
assertTrue
(
meta
.
get
(
"name.data"
)
!=
null
);
assertTrue
(
meta
.
get
(
"name.data0"
)
!=
null
);
assertNull
(
meta
.
get
(
"name.data1"
));
m
=
s
.
openMap
(
"data"
,
String
.
class
,
String
.
class
);
m0
=
s
.
openMap
(
"data0"
,
String
.
class
,
String
.
class
);
m
=
s
.
openMap
(
"data"
);
m0
=
s
.
openMap
(
"data0"
);
assertNull
(
m0
.
get
(
"1"
));
assertEquals
(
"Hello"
,
m
.
get
(
"1"
));
assertFalse
(
m0
.
isReadOnly
());
...
...
@@ -677,20 +675,20 @@ public class TestMVStore extends TestBase {
s
=
openStore
(
fileName
);
assertEquals
(
4
,
s
.
getCurrentVersion
());
m
=
s
.
openMap
(
"data"
,
String
.
class
,
String
.
class
);
m
=
s
.
openMap
(
"data"
);
m
.
put
(
"1"
,
"Hi"
);
s
.
store
();
s
.
close
();
s
=
openStore
(
fileName
);
m
=
s
.
openMap
(
"data"
,
String
.
class
,
String
.
class
);
m
=
s
.
openMap
(
"data"
);
assertEquals
(
"Hi"
,
m
.
get
(
"1"
));
s
.
rollbackTo
(
v4
);
assertEquals
(
"Hallo"
,
m
.
get
(
"1"
));
s
.
close
();
s
=
openStore
(
fileName
);
m
=
s
.
openMap
(
"data"
,
String
.
class
,
String
.
class
);
m
=
s
.
openMap
(
"data"
);
assertEquals
(
"Hallo"
,
m
.
get
(
"1"
));
s
.
close
();
}
...
...
@@ -701,14 +699,14 @@ public class TestMVStore extends TestBase {
MVStore
s
=
openStore
(
fileName
);
assertEquals
(
0
,
s
.
getCurrentVersion
());
s
.
setPageSize
(
5
);
MVMap
<
String
,
String
>
m
=
s
.
openMap
(
"data"
,
String
.
class
,
String
.
class
);
MVMap
<
String
,
String
>
m
=
s
.
openMap
(
"data"
);
s
.
rollbackTo
(
0
);
assertTrue
(
m
.
isClosed
());
assertEquals
(
0
,
s
.
getCurrentVersion
());
m
=
s
.
openMap
(
"data"
,
String
.
class
,
String
.
class
);
m
=
s
.
openMap
(
"data"
);
MVMap
<
String
,
String
>
m0
=
s
.
openMap
(
"data0"
,
String
.
class
,
String
.
class
);
MVMap
<
String
,
String
>
m2
=
s
.
openMap
(
"data2"
,
String
.
class
,
String
.
class
);
MVMap
<
String
,
String
>
m0
=
s
.
openMap
(
"data0"
);
MVMap
<
String
,
String
>
m2
=
s
.
openMap
(
"data2"
);
m
.
put
(
"1"
,
"Hello"
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
m2
.
put
(
""
+
i
,
"Test"
);
...
...
@@ -716,7 +714,7 @@ public class TestMVStore extends TestBase {
long
v1
=
s
.
incrementVersion
();
assertEquals
(
1
,
v1
);
assertEquals
(
1
,
s
.
getCurrentVersion
());
MVMap
<
String
,
String
>
m1
=
s
.
openMap
(
"data1"
,
String
.
class
,
String
.
class
);
MVMap
<
String
,
String
>
m1
=
s
.
openMap
(
"data1"
);
assertEquals
(
"Test"
,
m2
.
get
(
"1"
));
m
.
put
(
"1"
,
"Hallo"
);
m0
.
put
(
"1"
,
"Hallo"
);
...
...
@@ -742,7 +740,7 @@ public class TestMVStore extends TestBase {
FileUtils
.
delete
(
fileName
);
MVStore
s
=
openStore
(
fileName
);
MVMap
<
String
,
String
>
m
=
s
.
getMetaMap
();
MVMap
<
String
,
String
>
data
=
s
.
openMap
(
"data"
,
String
.
class
,
String
.
class
);
MVMap
<
String
,
String
>
data
=
s
.
openMap
(
"data"
);
data
.
put
(
"1"
,
"Hello"
);
data
.
put
(
"2"
,
"World"
);
s
.
store
();
...
...
@@ -751,15 +749,15 @@ public class TestMVStore extends TestBase {
assertFalse
(
m
.
containsKey
(
"chunk.2"
));
String
id
=
s
.
getMetaMap
().
get
(
"name.data"
);
assertEquals
(
"name:data"
,
m
.
get
(
"map."
+
id
));
assertEquals
(
"name:data
,key:o,value:o
"
,
m
.
get
(
"map."
+
id
));
assertTrue
(
m
.
containsKey
(
"chunk.1"
));
assertEquals
(
"Hello"
,
data
.
put
(
"1"
,
"Hallo"
));
s
.
store
();
assertEquals
(
"name:data"
,
m
.
get
(
"map."
+
id
));
assertEquals
(
"name:data
,key:o,value:o
"
,
m
.
get
(
"map."
+
id
));
assertTrue
(
m
.
get
(
"root.1"
).
length
()
>
0
);
assertTrue
(
m
.
containsKey
(
"chunk.1"
));
assertEquals
(
"id:1,length:2
46,maxLength:224
,maxLengthLive:0,"
+
"metaRoot:27487791092
2
,pageCount:2,"
+
assertEquals
(
"id:1,length:2
60,maxLength:288
,maxLengthLive:0,"
+
"metaRoot:27487791092
4
,pageCount:2,"
+
"start:8192,time:0,version:1"
,
m
.
get
(
"chunk.1"
));
assertTrue
(
m
.
containsKey
(
"chunk.2"
));
...
...
@@ -782,7 +780,7 @@ public class TestMVStore extends TestBase {
int
len
=
100
;
// TreeMap<Integer, String> m = new TreeMap<Integer, String>();
// HashMap<Integer, String> m = New.hashMap();
MVMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
MVMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
);
// t = System.currentTimeMillis();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
assertNull
(
m
.
put
(
i
,
"Hello World"
));
...
...
@@ -813,16 +811,13 @@ public class TestMVStore extends TestBase {
MVStore
s
=
openStore
(
fileName
);
// s.setCompressor(null);
s
.
setPageSize
(
40
);
MVMap
<
Integer
,
Object
[]>
m
=
new
MVMap
<
Integer
,
Object
[]>(
new
ObjectDataType
(),
new
RowDataType
(
new
DataType
[]
{
MVMap
<
Integer
,
Object
[]>
m
=
s
.
openMap
(
"data"
,
new
MVMap
.
Builder
<
Integer
,
Object
[]>()
.
valueType
(
new
RowDataType
(
new
DataType
[]
{
new
ObjectDataType
(),
StringDataType
.
INSTANCE
,
StringDataType
.
INSTANCE
})
);
StringDataType
.
INSTANCE
})));
m
=
s
.
openMap
(
"data"
,
m
);
// Profiler prof = new Profiler();
// prof.startCollecting();
// long t = System.currentTimeMillis();
...
...
@@ -852,7 +847,7 @@ public class TestMVStore extends TestBase {
s
.
close
();
s
=
openStore
(
fileName
);
MVMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
MVMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
);
int
count
=
2000
;
// Profiler p = new Profiler();
// p.startCollecting();
...
...
@@ -878,7 +873,7 @@ public class TestMVStore extends TestBase {
s
.
close
();
s
=
openStore
(
fileName
);
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
m
=
s
.
openMap
(
"data"
);
assertNull
(
m
.
get
(
0
));
for
(
int
i
=
1
;
i
<
count
;
i
++)
{
assertEquals
(
"hello "
+
i
,
m
.
get
(
i
));
...
...
@@ -901,7 +896,7 @@ public class TestMVStore extends TestBase {
for
(
int
j
=
0
;
j
<
20
;
j
++)
{
MVStore
s
=
openStore
(
fileName
);
s
.
setRetentionTime
(
0
);
MVMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
MVMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
);
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
m
.
put
(
j
+
i
,
"Hello "
+
j
);
}
...
...
@@ -919,7 +914,7 @@ public class TestMVStore extends TestBase {
// long len = FileUtils.size(fileName);
// System.out.println("len0: " + len);
MVStore
s
=
openStore
(
fileName
);
MVMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
MVMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
);
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
m
.
remove
(
i
);
}
...
...
@@ -929,7 +924,7 @@ public class TestMVStore extends TestBase {
// len = FileUtils.size(fileName);
// System.out.println("len1: " + len);
s
=
openStore
(
fileName
);
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
m
=
s
.
openMap
(
"data"
);
s
.
compact
(
80
);
s
.
close
();
// len = FileUtils.size(fileName);
...
...
@@ -943,7 +938,7 @@ public class TestMVStore extends TestBase {
for
(
int
j
=
0
;
j
<
20
;
j
++)
{
MVStore
s
=
openStore
(
fileName
);
s
.
setRetentionTime
(
0
);
MVMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
MVMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
m
.
put
(
i
,
"Hello"
);
}
...
...
@@ -968,7 +963,7 @@ public class TestMVStore extends TestBase {
String
fileName
=
getBaseDir
()
+
"/testRandom.h3"
;
FileUtils
.
delete
(
fileName
);
MVStore
s
=
openStore
(
fileName
);
MVMap
<
Integer
,
Integer
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
Integer
.
class
);
MVMap
<
Integer
,
Integer
>
m
=
s
.
openMap
(
"data"
);
TreeMap
<
Integer
,
Integer
>
map
=
new
TreeMap
<
Integer
,
Integer
>();
Random
r
=
new
Random
(
1
);
int
operationCount
=
1000
;
...
...
@@ -1031,24 +1026,24 @@ public class TestMVStore extends TestBase {
String
fileName
=
getBaseDir
()
+
"/testKeyValueClasses.h3"
;
FileUtils
.
delete
(
fileName
);
MVStore
s
=
openStore
(
fileName
);
MVMap
<
Integer
,
String
>
is
=
s
.
openMap
(
"intString"
,
Integer
.
class
,
String
.
class
);
MVMap
<
Integer
,
String
>
is
=
s
.
openMap
(
"intString"
);
is
.
put
(
1
,
"Hello"
);
MVMap
<
Integer
,
Integer
>
ii
=
s
.
openMap
(
"intInt"
,
Integer
.
class
,
Integer
.
class
);
MVMap
<
Integer
,
Integer
>
ii
=
s
.
openMap
(
"intInt"
);
ii
.
put
(
1
,
10
);
MVMap
<
String
,
Integer
>
si
=
s
.
openMap
(
"stringInt"
,
String
.
class
,
Integer
.
class
);
MVMap
<
String
,
Integer
>
si
=
s
.
openMap
(
"stringInt"
);
si
.
put
(
"Test"
,
10
);
MVMap
<
String
,
String
>
ss
=
s
.
openMap
(
"stringString"
,
String
.
class
,
String
.
class
);
MVMap
<
String
,
String
>
ss
=
s
.
openMap
(
"stringString"
);
ss
.
put
(
"Hello"
,
"World"
);
s
.
store
();
s
.
close
();
s
=
openStore
(
fileName
);
is
=
s
.
openMap
(
"intString"
,
Integer
.
class
,
String
.
class
);
is
=
s
.
openMap
(
"intString"
);
assertEquals
(
"Hello"
,
is
.
get
(
1
));
ii
=
s
.
openMap
(
"intInt"
,
Integer
.
class
,
Integer
.
class
);
ii
=
s
.
openMap
(
"intInt"
);
assertEquals
(
10
,
ii
.
get
(
1
).
intValue
());
si
=
s
.
openMap
(
"stringInt"
,
String
.
class
,
Integer
.
class
);
si
=
s
.
openMap
(
"stringInt"
);
assertEquals
(
10
,
si
.
get
(
"Test"
).
intValue
());
ss
=
s
.
openMap
(
"stringString"
,
String
.
class
,
String
.
class
);
ss
=
s
.
openMap
(
"stringString"
);
assertEquals
(
"World"
,
ss
.
get
(
"Hello"
));
s
.
close
();
}
...
...
@@ -1057,7 +1052,7 @@ public class TestMVStore extends TestBase {
String
fileName
=
getBaseDir
()
+
"/testIterate.h3"
;
FileUtils
.
delete
(
fileName
);
MVStore
s
=
openStore
(
fileName
);
MVMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
MVMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
);
Iterator
<
Integer
>
it
=
m
.
keyIterator
(
null
);
assertFalse
(
it
.
hasNext
());
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
...
...
@@ -1090,7 +1085,7 @@ public class TestMVStore extends TestBase {
String
fileName
=
getBaseDir
()
+
"/testCloseTwice.h3"
;
FileUtils
.
delete
(
fileName
);
MVStore
s
=
openStore
(
fileName
);
MVMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
MVMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
);
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
m
.
put
(
i
,
"hello "
+
i
);
}
...
...
@@ -1104,7 +1099,7 @@ public class TestMVStore extends TestBase {
String
fileName
=
getBaseDir
()
+
"/testSimple.h3"
;
FileUtils
.
delete
(
fileName
);
MVStore
s
=
openStore
(
fileName
);
MVMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
MVMap
<
Integer
,
String
>
m
=
s
.
openMap
(
"data"
);
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
m
.
put
(
i
,
"hello "
+
i
);
}
...
...
@@ -1119,7 +1114,7 @@ public class TestMVStore extends TestBase {
s
.
close
();
s
=
openStore
(
fileName
);
m
=
s
.
openMap
(
"data"
,
Integer
.
class
,
String
.
class
);
m
=
s
.
openMap
(
"data"
);
assertNull
(
m
.
get
(
0
));
for
(
int
i
=
1
;
i
<
3
;
i
++)
{
assertEquals
(
"hello "
+
i
,
m
.
get
(
i
));
...
...
h2/src/test/org/h2/test/store/TestMVTableEngine.java
浏览文件 @
1397fe53
...
...
@@ -28,7 +28,7 @@ public class TestMVTableEngine extends TestBase {
}
public
void
test
()
throws
Exception
{
//
testCase();
testCase
();
testSimple
();
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论