Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
80050699
Unverified
提交
80050699
authored
4月 08, 2018
作者:
Andrei Tokar
提交者:
GitHub
4月 08, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1030 from h2database/mv_nb
Make MVMap to operate in non-blocking fashion
上级
ca14d3bc
68ef8e9c
全部展开
显示空白字符变更
内嵌
并排
正在显示
25 个修改的文件
包含
3021 行增加
和
2509 行删除
+3021
-2509
Constants.java
h2/src/main/org/h2/engine/Constants.java
+5
-0
Session.java
h2/src/main/org/h2/engine/Session.java
+15
-4
ConcurrentArrayList.java
h2/src/main/org/h2/mvstore/ConcurrentArrayList.java
+0
-122
Cursor.java
h2/src/main/org/h2/mvstore/Cursor.java
+95
-75
CursorPos.java
h2/src/main/org/h2/mvstore/CursorPos.java
+1
-1
DataUtils.java
h2/src/main/org/h2/mvstore/DataUtils.java
+11
-11
MVMap.java
h2/src/main/org/h2/mvstore/MVMap.java
+872
-474
MVMapConcurrent.java
h2/src/main/org/h2/mvstore/MVMapConcurrent.java
+0
-77
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+820
-622
Page.java
h2/src/main/org/h2/mvstore/Page.java
+807
-556
MVPrimaryIndex.java
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
+9
-11
TransactionStore.java
h2/src/main/org/h2/mvstore/db/TransactionStore.java
+17
-12
MVRTreeMap.java
h2/src/main/org/h2/mvstore/rtree/MVRTreeMap.java
+207
-208
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+0
-2
TestQueryCache.java
h2/src/test/org/h2/test/db/TestQueryCache.java
+0
-2
TestMvcc2.java
h2/src/test/org/h2/test/mvcc/TestMvcc2.java
+9
-16
SequenceMap.java
h2/src/test/org/h2/test/store/SequenceMap.java
+6
-14
TestConcurrent.java
h2/src/test/org/h2/test/store/TestConcurrent.java
+40
-35
TestConcurrentLinkedList.java
h2/src/test/org/h2/test/store/TestConcurrentLinkedList.java
+0
-207
TestMVRTree.java
h2/src/test/org/h2/test/store/TestMVRTree.java
+1
-1
TestMVStore.java
h2/src/test/org/h2/test/store/TestMVStore.java
+36
-15
TestMVStoreTool.java
h2/src/test/org/h2/test/store/TestMVStoreTool.java
+40
-16
TestMVTableEngine.java
h2/src/test/org/h2/test/store/TestMVTableEngine.java
+4
-2
TestStreamStore.java
h2/src/test/org/h2/test/store/TestStreamStore.java
+1
-1
dictionary.txt
h2/src/tools/org/h2/build/doc/dictionary.txt
+25
-25
没有找到文件。
h2/src/main/org/h2/engine/Constants.java
浏览文件 @
80050699
...
@@ -331,6 +331,11 @@ public class Constants {
...
@@ -331,6 +331,11 @@ public class Constants {
// Java 6, 32 bit: 12
// Java 6, 32 bit: 12
public
static
final
int
MEMORY_OBJECT
=
24
;
public
static
final
int
MEMORY_OBJECT
=
24
;
/**
* The memory needed by an array.
*/
public
static
final
int
MEMORY_ARRAY
=
24
;
/**
/**
* The memory needed by an object of class PageBtree.
* The memory needed by an object of class PageBtree.
*/
*/
...
...
h2/src/main/org/h2/engine/Session.java
浏览文件 @
80050699
...
@@ -31,6 +31,7 @@ import org.h2.message.DbException;
...
@@ -31,6 +31,7 @@ import org.h2.message.DbException;
import
org.h2.message.Trace
;
import
org.h2.message.Trace
;
import
org.h2.message.TraceSystem
;
import
org.h2.message.TraceSystem
;
import
org.h2.mvstore.db.MVTable
;
import
org.h2.mvstore.db.MVTable
;
import
org.h2.mvstore.db.MVTableEngine
;
import
org.h2.mvstore.db.TransactionStore.Change
;
import
org.h2.mvstore.db.TransactionStore.Change
;
import
org.h2.mvstore.db.TransactionStore.Transaction
;
import
org.h2.mvstore.db.TransactionStore.Transaction
;
import
org.h2.result.ResultInterface
;
import
org.h2.result.ResultInterface
;
...
@@ -1681,11 +1682,14 @@ public class Session extends SessionWithState {
...
@@ -1681,11 +1682,14 @@ public class Session extends SessionWithState {
*/
*/
public
Transaction
getTransaction
()
{
public
Transaction
getTransaction
()
{
if
(
transaction
==
null
)
{
if
(
transaction
==
null
)
{
if
(
database
.
getMvStore
().
getStore
().
isClosed
())
{
MVTableEngine
.
Store
store
=
database
.
getMvStore
();
if
(
store
!=
null
)
{
if
(
store
.
getStore
().
isClosed
())
{
database
.
shutdownImmediately
();
database
.
shutdownImmediately
();
throw
DbException
.
get
(
ErrorCode
.
DATABASE_IS_CLOSED
);
throw
DbException
.
get
(
ErrorCode
.
DATABASE_IS_CLOSED
);
}
}
transaction
=
database
.
getMvStore
().
getTransactionStore
().
begin
();
transaction
=
store
.
getTransactionStore
().
begin
();
}
startStatement
=
-
1
;
startStatement
=
-
1
;
}
}
return
transaction
;
return
transaction
;
...
@@ -1702,6 +1706,10 @@ public class Session extends SessionWithState {
...
@@ -1702,6 +1706,10 @@ public class Session extends SessionWithState {
* Start a new statement within a transaction.
* Start a new statement within a transaction.
*/
*/
public
void
startStatementWithinTransaction
()
{
public
void
startStatementWithinTransaction
()
{
Transaction
transaction
=
getTransaction
();
if
(
transaction
!=
null
)
{
transaction
.
markStatementStart
();
}
startStatement
=
-
1
;
startStatement
=
-
1
;
}
}
...
@@ -1710,6 +1718,9 @@ public class Session extends SessionWithState {
...
@@ -1710,6 +1718,9 @@ public class Session extends SessionWithState {
* set, and deletes all temporary files held by the result sets.
* set, and deletes all temporary files held by the result sets.
*/
*/
public
void
endStatement
()
{
public
void
endStatement
()
{
if
(
transaction
!=
null
)
{
transaction
.
markStatementEnd
();
}
startStatement
=
-
1
;
startStatement
=
-
1
;
closeTemporaryResults
();
closeTemporaryResults
();
}
}
...
...
h2/src/main/org/h2/mvstore/ConcurrentArrayList.java
deleted
100644 → 0
浏览文件 @
ca14d3bc
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
mvstore
;
import
java.util.Arrays
;
import
java.util.Iterator
;
/**
* A very simple array list that supports concurrent access.
* Internally, it uses immutable objects.
*
* @param <K> the key type
*/
public
class
ConcurrentArrayList
<
K
>
{
/**
* The array.
*/
@SuppressWarnings
(
"unchecked"
)
K
[]
array
=
(
K
[])
new
Object
[
0
];
/**
* Get the first element, or null if none.
*
* @return the first element
*/
public
K
peekFirst
()
{
K
[]
a
=
array
;
return
a
.
length
==
0
?
null
:
a
[
0
];
}
/**
* Get the last element, or null if none.
*
* @return the last element
*/
public
K
peekLast
()
{
K
[]
a
=
array
;
int
len
=
a
.
length
;
return
len
==
0
?
null
:
a
[
len
-
1
];
}
/**
* Add an element at the end.
*
* @param obj the element
*/
public
synchronized
void
add
(
K
obj
)
{
if
(
obj
==
null
)
{
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_INTERNAL
,
"adding null value to list"
);
}
int
len
=
array
.
length
;
array
=
Arrays
.
copyOf
(
array
,
len
+
1
);
array
[
len
]
=
obj
;
}
/**
* Remove the first element, if it matches.
*
* @param obj the element to remove
* @return true if the element matched and was removed
*/
public
synchronized
boolean
removeFirst
(
K
obj
)
{
if
(
peekFirst
()
!=
obj
)
{
return
false
;
}
int
len
=
array
.
length
;
@SuppressWarnings
(
"unchecked"
)
K
[]
a
=
(
K
[])
new
Object
[
len
-
1
];
System
.
arraycopy
(
array
,
1
,
a
,
0
,
len
-
1
);
array
=
a
;
return
true
;
}
/**
* Remove the last element, if it matches.
*
* @param obj the element to remove
* @return true if the element matched and was removed
*/
public
synchronized
boolean
removeLast
(
K
obj
)
{
if
(
peekLast
()
!=
obj
)
{
return
false
;
}
array
=
Arrays
.
copyOf
(
array
,
array
.
length
-
1
);
return
true
;
}
/**
* Get an iterator over all entries.
*
* @return the iterator
*/
public
Iterator
<
K
>
iterator
()
{
return
new
Iterator
<
K
>()
{
K
[]
a
=
array
;
int
index
;
@Override
public
boolean
hasNext
()
{
return
index
<
a
.
length
;
}
@Override
public
K
next
()
{
return
a
[
index
++];
}
@Override
public
void
remove
()
{
throw
DataUtils
.
newUnsupportedOperationException
(
"remove"
);
}
};
}
}
h2/src/main/org/h2/mvstore/Cursor.java
浏览文件 @
80050699
...
@@ -14,41 +14,75 @@ import java.util.Iterator;
...
@@ -14,41 +14,75 @@ import java.util.Iterator;
* @param <V> the value type
* @param <V> the value type
*/
*/
public
class
Cursor
<
K
,
V
>
implements
Iterator
<
K
>
{
public
class
Cursor
<
K
,
V
>
implements
Iterator
<
K
>
{
private
final
K
to
;
private
final
MVMap
<
K
,
?>
map
;
private
CursorPos
cursorPos
;
private
final
K
from
;
private
CursorPos
keeper
;
private
CursorPos
pos
;
private
K
current
;
private
K
current
,
last
;
private
K
last
;
private
V
currentValue
,
lastValue
;
private
V
lastValue
;
private
Page
lastPage
;
private
Page
lastPage
;
private
final
Page
root
;
private
boolean
initialized
;
Cursor
(
MVMap
<
K
,
?>
map
,
Page
root
,
K
from
)
{
public
Cursor
(
Page
root
,
K
from
)
{
this
.
map
=
map
;
this
(
root
,
from
,
null
);
this
.
root
=
root
;
}
this
.
from
=
from
;
public
Cursor
(
Page
root
,
K
from
,
K
to
)
{
this
.
cursorPos
=
traverseDown
(
root
,
from
);
this
.
to
=
to
;
}
}
@Override
@Override
@SuppressWarnings
(
"unchecked"
)
public
boolean
hasNext
()
{
public
boolean
hasNext
()
{
if
(!
initialized
)
{
if
(
cursorPos
!=
null
)
{
min
(
root
,
from
);
while
(
current
==
null
)
{
initialized
=
true
;
Page
page
=
cursorPos
.
page
;
fetchNext
();
int
index
=
cursorPos
.
index
;
if
(
index
>=
(
page
.
isLeaf
()
?
page
.
getKeyCount
()
:
page
.
map
.
getChildPageCount
(
page
)))
{
CursorPos
tmp
=
cursorPos
;
cursorPos
=
cursorPos
.
parent
;
tmp
.
parent
=
keeper
;
keeper
=
tmp
;
if
(
cursorPos
==
null
)
{
return
false
;
}
}
else
{
while
(!
page
.
isLeaf
())
{
page
=
page
.
getChildPage
(
index
);
if
(
keeper
==
null
)
{
cursorPos
=
new
CursorPos
(
page
,
0
,
cursorPos
);
}
else
{
CursorPos
tmp
=
keeper
;
keeper
=
keeper
.
parent
;
tmp
.
parent
=
cursorPos
;
tmp
.
page
=
page
;
tmp
.
index
=
0
;
cursorPos
=
tmp
;
}
index
=
0
;
}
K
key
=
(
K
)
page
.
getKey
(
index
);
if
(
to
!=
null
&&
page
.
map
.
getKeyType
().
compare
(
key
,
to
)
>
0
)
{
return
false
;
}
current
=
last
=
key
;
lastValue
=
(
V
)
page
.
getValue
(
index
);
lastPage
=
page
;
}
++
cursorPos
.
index
;
}
}
}
return
current
!=
null
;
return
current
!=
null
;
}
}
@Override
@Override
public
K
next
()
{
public
K
next
()
{
hasNext
();
if
(!
hasNext
())
{
K
c
=
current
;
return
null
;
last
=
current
;
}
lastValue
=
currentValue
;
current
=
null
;
lastPage
=
pos
==
null
?
null
:
pos
.
page
;
return
last
;
fetchNext
();
return
c
;
}
}
/**
/**
...
@@ -69,6 +103,11 @@ public class Cursor<K, V> implements Iterator<K> {
...
@@ -69,6 +103,11 @@ public class Cursor<K, V> implements Iterator<K> {
return
lastValue
;
return
lastValue
;
}
}
/**
* Get the page where last retrieved key is located.
*
* @return the page
*/
Page
getPage
()
{
Page
getPage
()
{
return
lastPage
;
return
lastPage
;
}
}
...
@@ -80,77 +119,58 @@ public class Cursor<K, V> implements Iterator<K> {
...
@@ -80,77 +119,58 @@ public class Cursor<K, V> implements Iterator<K> {
* @param n the number of entries to skip
* @param n the number of entries to skip
*/
*/
public
void
skip
(
long
n
)
{
public
void
skip
(
long
n
)
{
if
(!
hasNext
())
{
return
;
}
if
(
n
<
10
)
{
if
(
n
<
10
)
{
while
(
n
--
>
0
)
{
while
(
n
--
>
0
&&
hasNext
())
{
fetchNext
();
next
();
}
}
return
;
}
else
if
(
hasNext
())
{
assert
cursorPos
!=
null
;
CursorPos
cp
=
cursorPos
;
CursorPos
parent
;
while
((
parent
=
cp
.
parent
)
!=
null
)
cp
=
parent
;
Page
root
=
cp
.
page
;
@SuppressWarnings
(
"unchecked"
)
MVMap
<
K
,
?>
map
=
(
MVMap
<
K
,
?>)
root
.
map
;
long
index
=
map
.
getKeyIndex
(
next
());
last
=
map
.
getKey
(
index
+
n
);
this
.
cursorPos
=
traverseDown
(
root
,
last
);
}
}
long
index
=
map
.
getKeyIndex
(
current
);
K
k
=
map
.
getKey
(
index
+
n
);
pos
=
null
;
min
(
root
,
k
);
fetchNext
();
}
}
@Override
@Override
public
void
remove
()
{
public
void
remove
()
{
throw
DataUtils
.
newUnsupportedOperationException
(
throw
DataUtils
.
newUnsupportedOperationException
(
"Remov
ing
is not supported"
);
"Remov
al
is not supported"
);
}
}
/**
/**
* Fetch the next entry that is equal or larger than the given key, starting
* Fetch the next entry that is equal or larger than the given key, starting
* from the given page. This method retains the stack.
* from the given page. This method retains the stack.
*
*
* @param p the page to start
* @param p the page to start
from
* @param
from the key to search
* @param
key the key to search, null means search for the first key
*/
*/
private
void
min
(
Page
p
,
K
from
)
{
public
static
CursorPos
traverseDown
(
Page
p
,
Object
key
)
{
while
(
true
)
{
CursorPos
cursorPos
=
null
;
if
(
p
.
isLeaf
())
{
while
(!
p
.
isLeaf
())
{
int
x
=
from
==
null
?
0
:
p
.
binarySearch
(
from
);
assert
p
.
getKeyCount
()
>
0
;
if
(
x
<
0
)
{
int
index
=
0
;
x
=
-
x
-
1
;
if
(
key
!=
null
)
{
}
index
=
p
.
binarySearch
(
key
)
+
1
;
pos
=
new
CursorPos
(
p
,
x
,
pos
);
if
(
index
<
0
)
{
break
;
index
=
-
index
;
}
int
x
=
from
==
null
?
-
1
:
p
.
binarySearch
(
from
);
if
(
x
<
0
)
{
x
=
-
x
-
1
;
}
else
{
x
++;
}
}
pos
=
new
CursorPos
(
p
,
x
+
1
,
pos
);
p
=
p
.
getChildPage
(
x
);
}
}
cursorPos
=
new
CursorPos
(
p
,
index
,
cursorPos
);
p
=
p
.
getChildPage
(
index
);
}
}
int
index
=
0
;
/**
if
(
key
!=
null
)
{
* Fetch the next entry if there is one.
index
=
p
.
binarySearch
(
key
);
*/
if
(
index
<
0
)
{
@SuppressWarnings
(
"unchecked"
)
index
=
-
index
-
1
;
private
void
fetchNext
()
{
while
(
pos
!=
null
)
{
if
(
pos
.
index
<
pos
.
page
.
getKeyCount
())
{
int
index
=
pos
.
index
++;
current
=
(
K
)
pos
.
page
.
getKey
(
index
);
currentValue
=
(
V
)
pos
.
page
.
getValue
(
index
);
return
;
}
pos
=
pos
.
parent
;
if
(
pos
==
null
)
{
break
;
}
}
if
(
pos
.
index
<
map
.
getChildPageCount
(
pos
.
page
))
{
min
(
pos
.
page
.
getChildPage
(
pos
.
index
++),
null
);
}
}
return
new
CursorPos
(
p
,
index
,
cursorPos
);
}
}
current
=
null
;
}
}
}
h2/src/main/org/h2/mvstore/CursorPos.java
浏览文件 @
80050699
...
@@ -23,7 +23,7 @@ public class CursorPos {
...
@@ -23,7 +23,7 @@ public class CursorPos {
/**
/**
* The position in the parent page, if any.
* The position in the parent page, if any.
*/
*/
public
final
CursorPos
parent
;
public
CursorPos
parent
;
public
CursorPos
(
Page
page
,
int
index
,
CursorPos
parent
)
{
public
CursorPos
(
Page
page
,
int
index
,
CursorPos
parent
)
{
this
.
page
=
page
;
this
.
page
=
page
;
...
...
h2/src/main/org/h2/mvstore/DataUtils.java
浏览文件 @
80050699
...
@@ -138,16 +138,6 @@ public final class DataUtils {
...
@@ -138,16 +138,6 @@ public final class DataUtils {
*/
*/
public
static
final
long
COMPRESSED_VAR_LONG_MAX
=
0x1ffffffffffff
L
;
public
static
final
long
COMPRESSED_VAR_LONG_MAX
=
0x1ffffffffffff
L
;
/**
* The estimated number of bytes used per page object.
*/
public
static
final
int
PAGE_MEMORY
=
128
;
/**
* The estimated number of bytes used per child entry.
*/
public
static
final
int
PAGE_MEMORY_CHILD
=
16
;
/**
/**
* The marker size of a very large page.
* The marker size of a very large page.
*/
*/
...
@@ -522,6 +512,16 @@ public final class DataUtils {
...
@@ -522,6 +512,16 @@ public final class DataUtils {
return
((
int
)
pos
)
&
1
;
return
((
int
)
pos
)
&
1
;
}
}
/**
* Find out if page was saved.
*
* @param pos the position
* @return true if page has been saved
*/
public
static
boolean
isPageSaved
(
long
pos
)
{
return
pos
!=
0
;
}
/**
/**
* Get the position of this page. The following information is encoded in
* Get the position of this page. The following information is encoded in
* the position: the chunk id, the offset, the maximum length, and the type
* the position: the chunk id, the offset, the maximum length, and the type
...
@@ -1005,7 +1005,7 @@ public final class DataUtils {
...
@@ -1005,7 +1005,7 @@ public final class DataUtils {
* @return the parsed value
* @return the parsed value
* @throws IllegalStateException if parsing fails
* @throws IllegalStateException if parsing fails
*/
*/
public
static
int
readHexInt
(
Hash
Map
<
String
,
?>
map
,
String
key
,
int
defaultValue
)
{
public
static
int
readHexInt
(
Map
<
String
,
?>
map
,
String
key
,
int
defaultValue
)
{
Object
v
=
map
.
get
(
key
);
Object
v
=
map
.
get
(
key
);
if
(
v
==
null
)
{
if
(
v
==
null
)
{
return
defaultValue
;
return
defaultValue
;
...
...
h2/src/main/org/h2/mvstore/MVMap.java
浏览文件 @
80050699
差异被折叠。
点击展开。
h2/src/main/org/h2/mvstore/MVMapConcurrent.java
deleted
100644 → 0
浏览文件 @
ca14d3bc
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
mvstore
;
import
org.h2.mvstore.type.DataType
;
import
org.h2.mvstore.type.ObjectDataType
;
/**
* A class used for backward compatibility.
*
* @param <K> the key type
* @param <V> the value type
*/
public
class
MVMapConcurrent
<
K
,
V
>
extends
MVMap
<
K
,
V
>
{
public
MVMapConcurrent
(
DataType
keyType
,
DataType
valueType
)
{
super
(
keyType
,
valueType
);
}
/**
* 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
<>(
keyType
,
valueType
);
}
}
}
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
80050699
差异被折叠。
点击展开。
h2/src/main/org/h2/mvstore/Page.java
浏览文件 @
80050699
差异被折叠。
点击展开。
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
浏览文件 @
80050699
...
@@ -114,8 +114,8 @@ public class MVPrimaryIndex extends BaseIndex {
...
@@ -114,8 +114,8 @@ public class MVPrimaryIndex extends BaseIndex {
TransactionMap
<
Value
,
Value
>
map
=
getMap
(
session
);
TransactionMap
<
Value
,
Value
>
map
=
getMap
(
session
);
Value
key
=
ValueLong
.
get
(
row
.
getKey
());
Value
key
=
ValueLong
.
get
(
row
.
getKey
());
Value
old
=
map
.
getLatest
(
key
);
try
{
if
(
old
!=
null
)
{
if
(
map
.
put
(
key
,
ValueArray
.
get
(
row
.
getValueList
()))
!=
null
)
{
String
sql
=
"PRIMARY KEY ON "
+
table
.
getSQL
();
String
sql
=
"PRIMARY KEY ON "
+
table
.
getSQL
();
if
(
mainIndexColumn
>=
0
&&
mainIndexColumn
<
indexColumns
.
length
)
{
if
(
mainIndexColumn
>=
0
&&
mainIndexColumn
<
indexColumns
.
length
)
{
sql
+=
"("
+
indexColumns
[
mainIndexColumn
].
getSQL
()
+
")"
;
sql
+=
"("
+
indexColumns
[
mainIndexColumn
].
getSQL
()
+
")"
;
...
@@ -124,8 +124,6 @@ public class MVPrimaryIndex extends BaseIndex {
...
@@ -124,8 +124,6 @@ public class MVPrimaryIndex extends BaseIndex {
e
.
setSource
(
this
);
e
.
setSource
(
this
);
throw
e
;
throw
e
;
}
}
try
{
map
.
put
(
key
,
ValueArray
.
get
(
row
.
getValueList
()));
}
catch
(
IllegalStateException
e
)
{
}
catch
(
IllegalStateException
e
)
{
throw
mvTable
.
convertException
(
e
);
throw
mvTable
.
convertException
(
e
);
}
}
...
...
h2/src/main/org/h2/mvstore/db/TransactionStore.java
浏览文件 @
80050699
...
@@ -475,7 +475,7 @@ public class TransactionStore {
...
@@ -475,7 +475,7 @@ public class TransactionStore {
t
.
setStatus
(
Transaction
.
STATUS_CLOSED
);
t
.
setStatus
(
Transaction
.
STATUS_CLOSED
);
openTransactions
.
clear
(
t
.
transactionId
);
openTransactions
.
clear
(
t
.
transactionId
);
if
(
oldStatus
==
Transaction
.
STATUS_PREPARED
||
store
.
getAutoCommitDelay
()
==
0
)
{
if
(
oldStatus
==
Transaction
.
STATUS_PREPARED
||
store
.
getAutoCommitDelay
()
==
0
)
{
store
.
c
ommit
();
store
.
tryC
ommit
();
return
;
return
;
}
}
// to avoid having to store the transaction log,
// to avoid having to store the transaction log,
...
@@ -486,7 +486,7 @@ public class TransactionStore {
...
@@ -486,7 +486,7 @@ public class TransactionStore {
int
max
=
store
.
getAutoCommitMemory
();
int
max
=
store
.
getAutoCommitMemory
();
// save at 3/4 capacity
// save at 3/4 capacity
if
(
unsaved
*
4
>
max
*
3
)
{
if
(
unsaved
*
4
>
max
*
3
)
{
store
.
c
ommit
();
store
.
tryC
ommit
();
}
}
}
}
}
}
...
@@ -681,6 +681,8 @@ public class TransactionStore {
...
@@ -681,6 +681,8 @@ public class TransactionStore {
private
int
status
;
private
int
status
;
private
MVStore
.
TxCounter
txCounter
;
private
String
name
;
private
String
name
;
Transaction
(
TransactionStore
store
,
int
transactionId
,
int
status
,
Transaction
(
TransactionStore
store
,
int
transactionId
,
int
status
,
...
@@ -723,6 +725,19 @@ public class TransactionStore {
...
@@ -723,6 +725,19 @@ public class TransactionStore {
return
logId
;
return
logId
;
}
}
public
void
markStatementStart
()
{
markStatementEnd
();
txCounter
=
store
.
store
.
registerVersionUsage
();
}
public
void
markStatementEnd
()
{
MVStore
.
TxCounter
counter
=
txCounter
;
txCounter
=
null
;
if
(
counter
!=
null
)
{
store
.
store
.
deregisterVersionUsage
(
counter
);
}
}
/**
/**
* Add a log entry.
* Add a log entry.
*
*
...
@@ -1183,16 +1198,6 @@ public class TransactionStore {
...
@@ -1183,16 +1198,6 @@ public class TransactionStore {
return
get
(
key
,
readLogId
);
return
get
(
key
,
readLogId
);
}
}
/**
* Get the most recent value for the given key.
*
* @param key the key
* @return the value or null
*/
public
V
getLatest
(
K
key
)
{
return
get
(
key
,
Long
.
MAX_VALUE
);
}
/**
/**
* Whether the map contains the key.
* Whether the map contains the key.
*
*
...
...
h2/src/main/org/h2/mvstore/rtree/MVRTreeMap.java
浏览文件 @
80050699
差异被折叠。
点击展开。
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
80050699
...
@@ -135,7 +135,6 @@ import org.h2.test.store.TestCacheConcurrentLIRS;
...
@@ -135,7 +135,6 @@ import org.h2.test.store.TestCacheConcurrentLIRS;
import
org.h2.test.store.TestCacheLIRS
;
import
org.h2.test.store.TestCacheLIRS
;
import
org.h2.test.store.TestCacheLongKeyLIRS
;
import
org.h2.test.store.TestCacheLongKeyLIRS
;
import
org.h2.test.store.TestConcurrent
;
import
org.h2.test.store.TestConcurrent
;
import
org.h2.test.store.TestConcurrentLinkedList
;
import
org.h2.test.store.TestDataUtils
;
import
org.h2.test.store.TestDataUtils
;
import
org.h2.test.store.TestFreeSpace
;
import
org.h2.test.store.TestFreeSpace
;
import
org.h2.test.store.TestKillProcessWhileWriting
;
import
org.h2.test.store.TestKillProcessWhileWriting
;
...
@@ -882,7 +881,6 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
...
@@ -882,7 +881,6 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
addTest
(
new
TestCacheConcurrentLIRS
());
addTest
(
new
TestCacheConcurrentLIRS
());
addTest
(
new
TestCacheLIRS
());
addTest
(
new
TestCacheLIRS
());
addTest
(
new
TestCacheLongKeyLIRS
());
addTest
(
new
TestCacheLongKeyLIRS
());
addTest
(
new
TestConcurrentLinkedList
());
addTest
(
new
TestDataUtils
());
addTest
(
new
TestDataUtils
());
addTest
(
new
TestFreeSpace
());
addTest
(
new
TestFreeSpace
());
addTest
(
new
TestKillProcessWhileWriting
());
addTest
(
new
TestKillProcessWhileWriting
());
...
...
h2/src/test/org/h2/test/db/TestQueryCache.java
浏览文件 @
80050699
...
@@ -77,8 +77,6 @@ public class TestQueryCache extends TestBase {
...
@@ -77,8 +77,6 @@ public class TestQueryCache extends TestBase {
prep
=
conn
.
prepareStatement
(
query
);
prep
=
conn
.
prepareStatement
(
query
);
}
else
if
(
i
==
1001
)
{
}
else
if
(
i
==
1001
)
{
first
=
time
;
first
=
time
;
// try to avoid pauses in subsequent iterations
System
.
gc
();
}
else
if
(
i
>
1001
)
{
}
else
if
(
i
>
1001
)
{
if
(
first
>
time
)
{
if
(
first
>
time
)
{
firstGreater
++;
firstGreater
++;
...
...
h2/src/test/org/h2/test/mvcc/TestMvcc2.java
浏览文件 @
80050699
...
@@ -9,7 +9,6 @@ import java.sql.Connection;
...
@@ -9,7 +9,6 @@ import java.sql.Connection;
import
java.sql.ResultSet
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.sql.Statement
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.util.Task
;
import
org.h2.util.Task
;
...
@@ -65,33 +64,26 @@ public class TestMvcc2 extends TestBase {
...
@@ -65,33 +64,26 @@ public class TestMvcc2 extends TestBase {
stat2
.
execute
(
"set lock_timeout 1000"
);
stat2
.
execute
(
"set lock_timeout 1000"
);
stat
.
execute
(
"create table test(id int primary key, name varchar)"
);
stat
.
execute
(
"create table test(id int primary key, name varchar)"
);
conn
.
setAutoCommit
(
false
);
conn
.
setAutoCommit
(
false
);
final
AtomicBoolean
committed
=
new
AtomicBoolean
(
false
);
Task
t
=
new
Task
()
{
Task
t
=
new
Task
()
{
@Override
@Override
public
void
call
()
throws
SQLException
{
public
void
call
()
{
try
{
try
{
//System.out.println("insert2 hallo");
stat2
.
execute
(
"insert into test values(0, 'Hallo')"
);
stat2
.
execute
(
"insert into test values(0, 'Hallo')"
);
//System.out.println("insert2 hallo done"
);
fail
(
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
//System.out.println("insert2 hallo e " + e);
assertTrue
(
e
.
toString
(),
if
(!
committed
.
get
())
{
e
.
getErrorCode
()
==
ErrorCode
.
DUPLICATE_KEY_1
||
throw
e
;
e
.
getErrorCode
()
==
ErrorCode
.
CONCURRENT_UPDATE_1
);
}
}
}
}
}
};
};
//System.out.println("insert hello");
stat
.
execute
(
"insert into test values(0, 'Hello')"
);
stat
.
execute
(
"insert into test values(0, 'Hello')"
);
t
.
execute
();
t
.
execute
();
Thread
.
sleep
(
500
);
//System.out.println("insert hello commit");
committed
.
set
(
true
);
conn
.
commit
();
conn
.
commit
();
t
.
get
();
t
.
get
();
ResultSet
rs
;
ResultSet
rs
;
rs
=
stat
.
executeQuery
(
"select name from test"
);
rs
=
stat
.
executeQuery
(
"select name from test"
);
rs
.
next
(
);
assertTrue
(
rs
.
next
()
);
assertEquals
(
"Hello"
,
rs
.
getString
(
1
));
assertEquals
(
"Hello"
,
rs
.
getString
(
1
));
stat
.
execute
(
"drop table test"
);
stat
.
execute
(
"drop table test"
);
conn2
.
close
();
conn2
.
close
();
...
@@ -111,16 +103,17 @@ public class TestMvcc2 extends TestBase {
...
@@ -111,16 +103,17 @@ public class TestMvcc2 extends TestBase {
@Override
@Override
public
void
call
()
throws
SQLException
{
public
void
call
()
throws
SQLException
{
stat2
.
execute
(
"update test set name = 'Hallo'"
);
stat2
.
execute
(
"update test set name = 'Hallo'"
);
assertEquals
(
1
,
stat2
.
getUpdateCount
());
}
}
};
};
stat
.
execute
(
"update test set name = 'Hi'"
);
stat
.
execute
(
"update test set name = 'Hi'"
);
assertEquals
(
1
,
stat
.
getUpdateCount
());
t
.
execute
();
t
.
execute
();
Thread
.
sleep
(
500
);
conn
.
commit
();
conn
.
commit
();
t
.
get
();
t
.
get
();
ResultSet
rs
;
ResultSet
rs
;
rs
=
stat
.
executeQuery
(
"select name from test"
);
rs
=
stat
.
executeQuery
(
"select name from test"
);
rs
.
next
(
);
assertTrue
(
rs
.
next
()
);
assertEquals
(
"Hallo"
,
rs
.
getString
(
1
));
assertEquals
(
"Hallo"
,
rs
.
getString
(
1
));
stat
.
execute
(
"drop table test"
);
stat
.
execute
(
"drop table test"
);
conn2
.
close
();
conn2
.
close
();
...
...
h2/src/test/org/h2/test/store/SequenceMap.java
浏览文件 @
80050699
...
@@ -7,6 +7,7 @@ package org.h2.test.store;
...
@@ -7,6 +7,7 @@ package org.h2.test.store;
import
java.util.AbstractSet
;
import
java.util.AbstractSet
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Set
;
import
org.h2.mvstore.MVMap
;
import
org.h2.mvstore.MVMap
;
...
@@ -25,8 +26,8 @@ public class SequenceMap extends MVMap<Long, Long> {
...
@@ -25,8 +26,8 @@ public class SequenceMap extends MVMap<Long, Long> {
*/
*/
int
max
=
10
;
int
max
=
10
;
public
SequenceMap
()
{
public
SequenceMap
(
Map
<
String
,
Object
>
config
)
{
super
(
null
,
null
);
super
(
config
);
}
}
@Override
@Override
...
@@ -67,20 +68,11 @@ public class SequenceMap extends MVMap<Long, Long> {
...
@@ -67,20 +68,11 @@ public class SequenceMap extends MVMap<Long, Long> {
/**
/**
* A builder for this class.
* A builder for this class.
*/
*/
public
static
class
Builder
implements
MapBuilder
<
SequenceMap
,
Long
,
Long
>
{
public
static
class
Builder
extends
MVMap
.
Builder
<
Long
,
Long
>
{
/**
* Create a new builder.
*/
public
Builder
()
{
// ignore
}
@Override
@Override
public
SequenceMap
create
()
{
public
SequenceMap
create
(
Map
<
String
,
Object
>
config
)
{
return
new
SequenceMap
();
return
new
SequenceMap
(
config
);
}
}
}
}
}
}
h2/src/test/org/h2/test/store/TestConcurrent.java
浏览文件 @
80050699
差异被折叠。
点击展开。
h2/src/test/org/h2/test/store/TestConcurrentLinkedList.java
deleted
100644 → 0
浏览文件 @
ca14d3bc
差异被折叠。
点击展开。
h2/src/test/org/h2/test/store/TestMVRTree.java
浏览文件 @
80050699
...
@@ -296,7 +296,7 @@ public class TestMVRTree extends TestMVStore {
...
@@ -296,7 +296,7 @@ public class TestMVRTree extends TestMVStore {
}
}
g2d
.
setColor
(
Color
.
red
);
g2d
.
setColor
(
Color
.
red
);
ArrayList
<
SpatialKey
>
list
=
New
.
arrayList
();
ArrayList
<
SpatialKey
>
list
=
New
.
arrayList
();
r
.
addNodeKeys
(
list
,
r
.
getRoot
());
r
.
addNodeKeys
(
list
,
r
.
getRoot
Page
());
for
(
SpatialKey
x
:
list
)
{
for
(
SpatialKey
x
:
list
)
{
int
[]
rect
=
scale
(
b
,
x
,
width
,
height
);
int
[]
rect
=
scale
(
b
,
x
,
width
,
height
);
g2d
.
drawRect
(
rect
[
0
],
rect
[
1
],
rect
[
2
]
-
rect
[
0
],
rect
[
3
]
-
rect
[
1
]);
g2d
.
drawRect
(
rect
[
0
],
rect
[
1
],
rect
[
2
]
-
rect
[
0
],
rect
[
3
]
-
rect
[
1
]);
...
...
h2/src/test/org/h2/test/store/TestMVStore.java
浏览文件 @
80050699
...
@@ -122,8 +122,7 @@ public class TestMVStore extends TestBase {
...
@@ -122,8 +122,7 @@ public class TestMVStore extends TestBase {
store
.
rollback
();
store
.
rollback
();
assertTrue
(
store
.
hasMap
(
"test"
));
assertTrue
(
store
.
hasMap
(
"test"
));
map
=
store
.
openMap
(
"test"
);
map
=
store
.
openMap
(
"test"
);
// TODO the data should get back alive
assertEquals
(
"Hello"
,
map
.
get
(
"1"
));
assertNull
(
map
.
get
(
"1"
));
store
.
close
();
store
.
close
();
String
fileName
=
getBaseDir
()
+
"/"
+
getTestName
();
String
fileName
=
getBaseDir
()
+
"/"
+
getTestName
();
...
@@ -315,12 +314,13 @@ public class TestMVStore extends TestBase {
...
@@ -315,12 +314,13 @@ public class TestMVStore extends TestBase {
private
void
testVersionsToKeep
()
throws
Exception
{
private
void
testVersionsToKeep
()
throws
Exception
{
MVStore
s
=
new
MVStore
.
Builder
().
open
();
MVStore
s
=
new
MVStore
.
Builder
().
open
();
assertEquals
(
5
,
s
.
getVersionsToKeep
());
MVMap
<
Integer
,
Integer
>
map
;
MVMap
<
Integer
,
Integer
>
map
;
map
=
s
.
openMap
(
"data"
);
map
=
s
.
openMap
(
"data"
);
for
(
int
i
=
0
;
i
<
20
;
i
++)
{
for
(
int
i
=
0
;
i
<
20
;
i
++)
{
long
version
=
s
.
getCurrentVersion
();
map
.
put
(
i
,
i
);
map
.
put
(
i
,
i
);
s
.
commit
();
s
.
commit
();
long
version
=
s
.
getCurrentVersion
();
if
(
version
>=
6
)
{
if
(
version
>=
6
)
{
map
.
openVersion
(
version
-
5
);
map
.
openVersion
(
version
-
5
);
try
{
try
{
...
@@ -493,9 +493,9 @@ public class TestMVStore extends TestBase {
...
@@ -493,9 +493,9 @@ public class TestMVStore extends TestBase {
}
}
long
sizeOld
=
s
.
getFileStore
().
size
();
long
sizeOld
=
s
.
getFileStore
().
size
();
s
.
compactMoveChunks
();
s
.
compactMoveChunks
();
s
.
close
();
long
sizeNew
=
s
.
getFileStore
().
size
();
long
sizeNew
=
s
.
getFileStore
().
size
();
assertTrue
(
"old: "
+
sizeOld
+
" new: "
+
sizeNew
,
sizeNew
<
sizeOld
);
assertTrue
(
"old: "
+
sizeOld
+
" new: "
+
sizeNew
,
sizeNew
<
sizeOld
);
s
.
close
();
}
}
private
void
testBackgroundExceptionListener
()
throws
Exception
{
private
void
testBackgroundExceptionListener
()
throws
Exception
{
...
@@ -805,7 +805,7 @@ public class TestMVStore extends TestBase {
...
@@ -805,7 +805,7 @@ public class TestMVStore extends TestBase {
String
fileName
=
getBaseDir
()
+
"/"
+
getTestName
();
String
fileName
=
getBaseDir
()
+
"/"
+
getTestName
();
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
MVStore
s
=
openStore
(
fileName
);
MVStore
s
=
openStore
(
fileName
);
SequenceMap
seq
=
s
.
openMap
(
"data"
,
new
SequenceMap
.
Builder
());
Map
<
Long
,
Long
>
seq
=
s
.
openMap
(
"data"
,
new
SequenceMap
.
Builder
());
StringBuilder
buff
=
new
StringBuilder
();
StringBuilder
buff
=
new
StringBuilder
();
for
(
long
x
:
seq
.
keySet
())
{
for
(
long
x
:
seq
.
keySet
())
{
buff
.
append
(
x
).
append
(
';'
);
buff
.
append
(
x
).
append
(
';'
);
...
@@ -815,6 +815,9 @@ public class TestMVStore extends TestBase {
...
@@ -815,6 +815,9 @@ public class TestMVStore extends TestBase {
}
}
private
void
testCacheSize
()
{
private
void
testCacheSize
()
{
if
(
config
.
memory
)
{
return
;
}
String
fileName
=
getBaseDir
()
+
"/"
+
getTestName
();
String
fileName
=
getBaseDir
()
+
"/"
+
getTestName
();
FileUtils
.
delete
(
fileName
);
FileUtils
.
delete
(
fileName
);
MVStore
s
;
MVStore
s
;
...
@@ -830,12 +833,14 @@ public class TestMVStore extends TestBase {
...
@@ -830,12 +833,14 @@ public class TestMVStore extends TestBase {
}
}
s
.
close
();
s
.
close
();
int
[]
expectedReadsForCacheSize
=
{
int
[]
expectedReadsForCacheSize
=
{
3407
,
2590
,
1924
,
1440
,
1330
,
956
,
918
1880
,
1789
,
1616
,
1374
,
970
,
711
,
541
// compressed
// 1887, 1775, 1599, 1355, 1035, 732, 507 // uncompressed
};
};
for
(
int
cacheSize
=
0
;
cacheSize
<=
6
;
cacheSize
+=
4
)
{
for
(
int
cacheSize
=
0
;
cacheSize
<=
6
;
cacheSize
+=
1
)
{
int
cacheMB
=
1
+
3
*
cacheSize
;
int
cacheMB
=
1
+
3
*
cacheSize
;
s
=
new
MVStore
.
Builder
().
s
=
new
MVStore
.
Builder
().
fileName
(
fileName
).
fileName
(
fileName
).
autoCommitDisabled
().
cacheSize
(
cacheMB
).
open
();
cacheSize
(
cacheMB
).
open
();
assertEquals
(
cacheMB
,
s
.
getCacheSize
());
assertEquals
(
cacheMB
,
s
.
getCacheSize
());
map
=
s
.
openMap
(
"test"
);
map
=
s
.
openMap
(
"test"
);
...
@@ -847,8 +852,14 @@ public class TestMVStore extends TestBase {
...
@@ -847,8 +852,14 @@ public class TestMVStore extends TestBase {
}
}
long
readCount
=
s
.
getFileStore
().
getReadCount
();
long
readCount
=
s
.
getFileStore
().
getReadCount
();
int
expected
=
expectedReadsForCacheSize
[
cacheSize
];
int
expected
=
expectedReadsForCacheSize
[
cacheSize
];
assertTrue
(
"reads: "
+
readCount
+
" expected: "
+
expected
,
assertTrue
(
"Cache "
+
cacheMB
+
"Mb, reads: "
+
readCount
+
" expected: "
+
expected
+
Math
.
abs
(
100
-
(
100
*
expected
/
readCount
))
<
5
);
" size: "
+
s
.
getFileStore
().
getReadBytes
()
+
" cache used: "
+
s
.
getCacheSizeUsed
()
+
" cache hits: "
+
s
.
getCache
().
getHits
()
+
" cache misses: "
+
s
.
getCache
().
getMisses
()
+
" cache requests: "
+
(
s
.
getCache
().
getHits
()
+
s
.
getCache
().
getMisses
())
+
""
,
Math
.
abs
(
100
-
(
100
*
expected
/
readCount
))
<
15
);
s
.
close
();
s
.
close
();
}
}
...
@@ -1341,8 +1352,9 @@ public class TestMVStore extends TestBase {
...
@@ -1341,8 +1352,9 @@ public class TestMVStore extends TestBase {
assertEquals
(
"Hello"
,
mOld
.
get
(
"1"
));
assertEquals
(
"Hello"
,
mOld
.
get
(
"1"
));
assertEquals
(
"World"
,
mOld
.
get
(
"2"
));
assertEquals
(
"World"
,
mOld
.
get
(
"2"
));
assertTrue
(
mOld
.
isReadOnly
());
assertTrue
(
mOld
.
isReadOnly
());
s
.
getCurrentVersion
();
long
old3
=
s
.
getCurrentVersion
();
long
old3
=
s
.
commit
();
assertEquals
(
3
,
old3
);
s
.
commit
();
// the old version is still available
// the old version is still available
assertEquals
(
"Hello"
,
mOld
.
get
(
"1"
));
assertEquals
(
"Hello"
,
mOld
.
get
(
"1"
));
...
@@ -1361,9 +1373,16 @@ public class TestMVStore extends TestBase {
...
@@ -1361,9 +1373,16 @@ public class TestMVStore extends TestBase {
assertEquals
(
"Hi"
,
m
.
get
(
"1"
));
assertEquals
(
"Hi"
,
m
.
get
(
"1"
));
assertEquals
(
null
,
m
.
get
(
"2"
));
assertEquals
(
null
,
m
.
get
(
"2"
));
// This test tries to cast in bronze some peculiar behaviour,
// which is rather implementation artifact then intentional.
// Once store is closed, only one single version of the data
// will exists upon re-opening - the latest.
// I hope nobody relies on this "multi-versioning".
/*
mOld = m.openVersion(old3);
mOld = m.openVersion(old3);
assertEquals("Hallo", mOld.get("1"));
assertEquals("Hallo", mOld.get("1"));
assertEquals("Welt", mOld.get("2"));
assertEquals("Welt", mOld.get("2"));
*/
try
{
try
{
m
.
openVersion
(-
3
);
m
.
openVersion
(-
3
);
...
@@ -1400,6 +1419,8 @@ public class TestMVStore extends TestBase {
...
@@ -1400,6 +1419,8 @@ public class TestMVStore extends TestBase {
}
}
}
}
assertTrue
(
s
.
compact
(
100
,
50
*
1024
));
assertTrue
(
s
.
compact
(
100
,
50
*
1024
));
// compaction alone will not guarantee file size reduction
s
.
compactMoveChunks
();
s
.
close
();
s
.
close
();
long
len2
=
FileUtils
.
size
(
fileName
);
long
len2
=
FileUtils
.
size
(
fileName
);
assertTrue
(
"len2: "
+
len2
+
" len: "
+
len
,
len2
<
len
);
assertTrue
(
"len2: "
+
len2
+
" len: "
+
len
,
len2
<
len
);
...
@@ -1417,9 +1438,8 @@ public class TestMVStore extends TestBase {
...
@@ -1417,9 +1438,8 @@ public class TestMVStore extends TestBase {
assertEquals
(
i
+
1
,
m
.
size
());
assertEquals
(
i
+
1
,
m
.
size
());
}
}
assertEquals
(
1000
,
m
.
size
());
assertEquals
(
1000
,
m
.
size
());
// previously (131896) we fail to account for initial root page for every map
// memory calculations were adjusted, so as this out-of-the-thin-air number
// there are two of them here (meta and "data"), hence lack of 256 bytes
assertEquals
(
84730
,
s
.
getUnsavedMemory
());
assertEquals
(
132152
,
s
.
getUnsavedMemory
());
s
.
commit
();
s
.
commit
();
assertEquals
(
2
,
s
.
getFileStore
().
getWriteCount
());
assertEquals
(
2
,
s
.
getFileStore
().
getWriteCount
());
s
.
close
();
s
.
close
();
...
@@ -1430,7 +1450,7 @@ public class TestMVStore extends TestBase {
...
@@ -1430,7 +1450,7 @@ public class TestMVStore extends TestBase {
assertEquals
(
0
,
m
.
size
());
assertEquals
(
0
,
m
.
size
());
s
.
commit
();
s
.
commit
();
// ensure only nodes are read, but not leaves
// ensure only nodes are read, but not leaves
assertEquals
(
45
,
s
.
getFileStore
().
getReadCount
());
assertEquals
(
10
,
s
.
getFileStore
().
getReadCount
());
assertTrue
(
s
.
getFileStore
().
getWriteCount
()
<
5
);
assertTrue
(
s
.
getFileStore
().
getWriteCount
()
<
5
);
s
.
close
();
s
.
close
();
}
}
...
@@ -1499,6 +1519,7 @@ public class TestMVStore extends TestBase {
...
@@ -1499,6 +1519,7 @@ public class TestMVStore extends TestBase {
assertNull
(
meta
.
get
(
"name.data1"
));
assertNull
(
meta
.
get
(
"name.data1"
));
assertNull
(
m0
.
get
(
"1"
));
assertNull
(
m0
.
get
(
"1"
));
assertEquals
(
"Hello"
,
m
.
get
(
"1"
));
assertEquals
(
"Hello"
,
m
.
get
(
"1"
));
// no changes - no real commit here
assertEquals
(
2
,
s
.
commit
());
assertEquals
(
2
,
s
.
commit
());
s
.
close
();
s
.
close
();
...
...
h2/src/test/org/h2/test/store/TestMVStoreTool.java
浏览文件 @
80050699
差异被折叠。
点击展开。
h2/src/test/org/h2/test/store/TestMVTableEngine.java
浏览文件 @
80050699
差异被折叠。
点击展开。
h2/src/test/org/h2/test/store/TestStreamStore.java
浏览文件 @
80050699
...
@@ -151,7 +151,7 @@ public class TestStreamStore extends TestBase {
...
@@ -151,7 +151,7 @@ public class TestStreamStore extends TestBase {
long
readCount
=
s
.
getFileStore
().
getReadCount
();
long
readCount
=
s
.
getFileStore
().
getReadCount
();
// the read count should be low because new blocks
// the read count should be low because new blocks
// are appended at the end (not between existing blocks)
// are appended at the end (not between existing blocks)
assertTrue
(
"rc: "
+
readCount
,
readCount
<
15
);
assertTrue
(
"rc: "
+
readCount
,
readCount
<
=
17
);
map
=
s
.
openMap
(
"data"
);
map
=
s
.
openMap
(
"data"
);
assertTrue
(
"size: "
+
map
.
size
(),
map
.
sizeAsLong
()
>=
200
);
assertTrue
(
"size: "
+
map
.
size
(),
map
.
sizeAsLong
()
>=
200
);
s
.
close
();
s
.
close
();
...
...
h2/src/tools/org/h2/build/doc/dictionary.txt
浏览文件 @
80050699
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论