Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
117b640f
提交
117b640f
authored
4月 01, 2018
作者:
andrei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Address synthetic access issues
上级
4ecab392
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
165 行增加
和
165 行删除
+165
-165
Cursor.java
h2/src/main/org/h2/mvstore/Cursor.java
+4
-4
MVMap.java
h2/src/main/org/h2/mvstore/MVMap.java
+48
-66
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+30
-30
Page.java
h2/src/main/org/h2/mvstore/Page.java
+47
-30
MVRTreeMap.java
h2/src/main/org/h2/mvstore/rtree/MVRTreeMap.java
+10
-9
TestMVStore.java
h2/src/test/org/h2/test/store/TestMVStore.java
+1
-1
dictionary.txt
h2/src/tools/org/h2/build/doc/dictionary.txt
+25
-25
没有找到文件。
h2/src/main/org/h2/mvstore/Cursor.java
浏览文件 @
117b640f
...
@@ -118,7 +118,6 @@ public final class Cursor<K, V> implements Iterator<K> {
...
@@ -118,7 +118,6 @@ public final class Cursor<K, V> implements Iterator<K> {
*
*
* @param n the number of entries to skip
* @param n the number of entries to skip
*/
*/
@SuppressWarnings
(
"unchecked"
)
public
void
skip
(
long
n
)
{
public
void
skip
(
long
n
)
{
if
(
n
<
10
)
{
if
(
n
<
10
)
{
while
(
n
--
>
0
&&
hasNext
())
{
while
(
n
--
>
0
&&
hasNext
())
{
...
@@ -126,10 +125,11 @@ public final class Cursor<K, V> implements Iterator<K> {
...
@@ -126,10 +125,11 @@ public final class Cursor<K, V> implements Iterator<K> {
}
}
}
else
if
(
hasNext
())
{
}
else
if
(
hasNext
())
{
assert
cursorPos
!=
null
;
assert
cursorPos
!=
null
;
CursorPos
c
urPos
=
cursorPos
;
CursorPos
c
p
=
cursorPos
;
CursorPos
parent
;
CursorPos
parent
;
while
((
parent
=
curPos
.
parent
)
!=
null
)
curPos
=
parent
;
while
((
parent
=
cp
.
parent
)
!=
null
)
cp
=
parent
;
Page
root
=
curPos
.
page
;
Page
root
=
cp
.
page
;
@SuppressWarnings
(
"unchecked"
)
MVMap
<
K
,
?>
map
=
(
MVMap
<
K
,
?>)
root
.
map
;
MVMap
<
K
,
?>
map
=
(
MVMap
<
K
,
?>)
root
.
map
;
long
index
=
map
.
getKeyIndex
(
next
());
long
index
=
map
.
getKeyIndex
(
next
());
last
=
map
.
getKey
(
index
+
n
);
last
=
map
.
getKey
(
index
+
n
);
...
...
h2/src/main/org/h2/mvstore/MVMap.java
浏览文件 @
117b640f
差异被折叠。
点击展开。
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
117b640f
...
@@ -158,7 +158,7 @@ public final class MVStore {
...
@@ -158,7 +158,7 @@ public final class MVStore {
private
volatile
boolean
closed
;
private
volatile
boolean
closed
;
private
final
FileStore
fileStore
;
final
FileStore
fileStore
;
private
final
boolean
fileStoreIsProvided
;
private
final
boolean
fileStoreIsProvided
;
private
final
int
pageSplitSize
;
private
final
int
pageSplitSize
;
...
@@ -170,14 +170,14 @@ public final class MVStore {
...
@@ -170,14 +170,14 @@ public final class MVStore {
* It is split in 16 segments. The stack move distance is 2% of the expected
* It is split in 16 segments. The stack move distance is 2% of the expected
* number of entries.
* number of entries.
*/
*/
private
final
CacheLongKeyLIRS
<
Page
>
cache
;
final
CacheLongKeyLIRS
<
Page
>
cache
;
/**
/**
* The page chunk references cache. The default size is 4 MB, and the
* The page chunk references cache. The default size is 4 MB, and the
* average size is 2 KB. It is split in 16 segments. The stack move distance
* average size is 2 KB. It is split in 16 segments. The stack move distance
* is 2% of the expected number of entries.
* is 2% of the expected number of entries.
*/
*/
private
final
CacheLongKeyLIRS
<
int
[]>
cacheChunkRef
;
final
CacheLongKeyLIRS
<
int
[]>
cacheChunkRef
;
/**
/**
* The newest chunk. If nothing was stored yet, this field is not set.
* The newest chunk. If nothing was stored yet, this field is not set.
...
@@ -505,15 +505,14 @@ public final class MVStore {
...
@@ -505,15 +505,14 @@ public final class MVStore {
}
}
public
synchronized
<
M
extends
MVMap
<
K
,
V
>,
K
,
V
>
M
openMap
(
int
id
,
public
synchronized
<
M
extends
MVMap
<
K
,
V
>,
K
,
V
>
M
openMap
(
int
id
,
MVMap
.
MapBuilder
<
M
,
K
,
V
>
builder
)
{
MVMap
.
MapBuilder
<
M
,
K
,
V
>
builder
)
{
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
M
map
=
(
M
)
getMap
(
id
);
M
map
=
(
M
)
getMap
(
id
);
if
(
map
==
null
)
{
if
(
map
==
null
)
{
String
configAsString
=
meta
.
get
(
MVMap
.
getMapKey
(
id
));
String
configAsString
=
meta
.
get
(
MVMap
.
getMapKey
(
id
));
if
(
configAsString
!=
null
)
{
if
(
configAsString
!=
null
)
{
HashMap
<
String
,
Object
>
config
=
new
HashMap
<>();
HashMap
<
String
,
Object
>
config
=
HashMap
<
String
,
String
>
cfg
=
DataUtils
.
parseMap
(
configAsString
);
new
HashMap
<
String
,
Object
>(
DataUtils
.
parseMap
(
configAsString
));
config
.
putAll
(
cfg
);
config
.
put
(
"id"
,
id
);
config
.
put
(
"id"
,
id
);
map
=
builder
.
create
(
this
,
config
);
map
=
builder
.
create
(
this
,
config
);
map
.
init
();
map
.
init
();
...
@@ -729,7 +728,8 @@ public final class MVStore {
...
@@ -729,7 +728,8 @@ public final class MVStore {
int
length
=
c
.
len
*
BLOCK_SIZE
;
int
length
=
c
.
len
*
BLOCK_SIZE
;
fileStore
.
markUsed
(
start
,
length
);
fileStore
.
markUsed
(
start
,
length
);
}
}
assert
fileStore
.
getFileLengthInUse
()
==
measureFileLengthInUse
()
:
fileStore
.
getFileLengthInUse
()
+
" != "
+
measureFileLengthInUse
();
assert
fileStore
.
getFileLengthInUse
()
==
measureFileLengthInUse
()
:
fileStore
.
getFileLengthInUse
()
+
" != "
+
measureFileLengthInUse
();
// read all chunk headers and footers within the retention time,
// read all chunk headers and footers within the retention time,
// to detect unwritten data after a power failure
// to detect unwritten data after a power failure
}
while
((
newest
=
verifyLastChunks
())
!=
null
);
}
while
((
newest
=
verifyLastChunks
())
!=
null
);
...
@@ -989,7 +989,7 @@ public final class MVStore {
...
@@ -989,7 +989,7 @@ public final class MVStore {
* @param pos the position
* @param pos the position
* @return the chunk
* @return the chunk
*/
*/
private
Chunk
getChunk
(
long
pos
)
{
Chunk
getChunk
(
long
pos
)
{
Chunk
c
=
getChunkIfFound
(
pos
);
Chunk
c
=
getChunkIfFound
(
pos
);
if
(
c
==
null
)
{
if
(
c
==
null
)
{
int
chunkId
=
DataUtils
.
getPageChunkId
(
pos
);
int
chunkId
=
DataUtils
.
getPageChunkId
(
pos
);
...
@@ -1203,7 +1203,8 @@ public final class MVStore {
...
@@ -1203,7 +1203,8 @@ public final class MVStore {
long
filePos
=
allocateFileSpace
(
length
,
!
reuseSpace
);
long
filePos
=
allocateFileSpace
(
length
,
!
reuseSpace
);
c
.
block
=
filePos
/
BLOCK_SIZE
;
c
.
block
=
filePos
/
BLOCK_SIZE
;
c
.
len
=
length
/
BLOCK_SIZE
;
c
.
len
=
length
/
BLOCK_SIZE
;
assert
fileStore
.
getFileLengthInUse
()
==
measureFileLengthInUse
()
:
fileStore
.
getFileLengthInUse
()
+
" != "
+
measureFileLengthInUse
()
+
" "
+
c
;
assert
fileStore
.
getFileLengthInUse
()
==
measureFileLengthInUse
()
:
fileStore
.
getFileLengthInUse
()
+
" != "
+
measureFileLengthInUse
()
+
" "
+
c
;
c
.
metaRootPos
=
metaRoot
.
getPos
();
c
.
metaRootPos
=
metaRoot
.
getPos
();
// calculate and set the likely next position
// calculate and set the likely next position
if
(
reuseSpace
)
{
if
(
reuseSpace
)
{
...
@@ -1311,7 +1312,8 @@ public final class MVStore {
...
@@ -1311,7 +1312,8 @@ public final class MVStore {
long
start
=
c
.
block
*
BLOCK_SIZE
;
long
start
=
c
.
block
*
BLOCK_SIZE
;
int
length
=
c
.
len
*
BLOCK_SIZE
;
int
length
=
c
.
len
*
BLOCK_SIZE
;
fileStore
.
free
(
start
,
length
);
fileStore
.
free
(
start
,
length
);
assert
fileStore
.
getFileLengthInUse
()
==
measureFileLengthInUse
()
:
fileStore
.
getFileLengthInUse
()
+
" != "
+
measureFileLengthInUse
();
assert
fileStore
.
getFileLengthInUse
()
==
measureFileLengthInUse
()
:
fileStore
.
getFileLengthInUse
()
+
" != "
+
measureFileLengthInUse
();
}
else
{
}
else
{
if
(
c
.
unused
==
0
)
{
if
(
c
.
unused
==
0
)
{
c
.
unused
=
time
;
c
.
unused
=
time
;
...
@@ -1370,7 +1372,7 @@ public final class MVStore {
...
@@ -1370,7 +1372,7 @@ public final class MVStore {
private
ChunkIdsCollector
child
;
private
ChunkIdsCollector
child
;
private
int
mapId
;
private
int
mapId
;
private
ChunkIdsCollector
(
int
mapId
)
{
ChunkIdsCollector
(
int
mapId
)
{
this
.
parent
=
null
;
this
.
parent
=
null
;
this
.
mapId
=
mapId
;
this
.
mapId
=
mapId
;
}
}
...
@@ -1448,7 +1450,7 @@ public final class MVStore {
...
@@ -1448,7 +1450,7 @@ public final class MVStore {
"Negative position {0}; p={1}, c={2}"
,
filePos
,
pos
,
chunk
.
toString
());
"Negative position {0}; p={1}, c={2}"
,
filePos
,
pos
,
chunk
.
toString
());
}
}
long
maxPos
=
(
chunk
.
block
+
chunk
.
len
)
*
BLOCK_SIZE
;
long
maxPos
=
(
chunk
.
block
+
chunk
.
len
)
*
BLOCK_SIZE
;
Page
.
readChildren
s
Positions
(
fileStore
,
pos
,
filePos
,
maxPos
,
childCollector
);
Page
.
readChildrenPositions
(
fileStore
,
pos
,
filePos
,
maxPos
,
childCollector
);
}
}
// and cache resulting set of chunk ids
// and cache resulting set of chunk ids
if
(
cacheChunkRef
!=
null
)
{
if
(
cacheChunkRef
!=
null
)
{
...
@@ -1476,9 +1478,9 @@ public final class MVStore {
...
@@ -1476,9 +1478,9 @@ public final class MVStore {
private
int
[]
getChunkIds
()
{
private
int
[]
getChunkIds
()
{
int
chunkIds
[]
=
new
int
[
referenced
.
size
()];
int
chunkIds
[]
=
new
int
[
referenced
.
size
()];
int
indx
=
0
;
int
ind
e
x
=
0
;
for
(
int
chunkId
:
referenced
)
{
for
(
int
chunkId
:
referenced
)
{
chunkIds
[
indx
++]
=
chunkId
;
chunkIds
[
ind
e
x
++]
=
chunkId
;
}
}
return
chunkIds
;
return
chunkIds
;
}
}
...
@@ -1948,7 +1950,7 @@ public final class MVStore {
...
@@ -1948,7 +1950,7 @@ public final class MVStore {
@Override
@Override
public
int
compare
(
Chunk
o1
,
Chunk
o2
)
{
public
int
compare
(
Chunk
o1
,
Chunk
o2
)
{
int
comp
=
Integer
.
compare
(
o1
.
collectPriority
,
int
comp
=
Integer
.
compare
(
o1
.
collectPriority
,
o2
.
collectPriority
);
o2
.
collectPriority
);
if
(
comp
==
0
)
{
if
(
comp
==
0
)
{
comp
=
Long
.
compare
(
o1
.
maxLenLive
,
comp
=
Long
.
compare
(
o1
.
maxLenLive
,
o2
.
maxLenLive
);
o2
.
maxLenLive
);
...
@@ -2202,7 +2204,7 @@ public final class MVStore {
...
@@ -2202,7 +2204,7 @@ public final class MVStore {
long
current
=
this
.
oldestVersionToKeep
.
get
();
long
current
=
this
.
oldestVersionToKeep
.
get
();
// Oldest version may only advance, never goes back
// Oldest version may only advance, never goes back
success
=
oldestVersionToKeep
<=
current
||
success
=
oldestVersionToKeep
<=
current
||
this
.
oldestVersionToKeep
.
compareAndSet
(
current
,
oldestVersionToKeep
);
this
.
oldestVersionToKeep
.
compareAndSet
(
current
,
oldestVersionToKeep
);
}
while
(!
success
);
}
while
(!
success
);
}
}
...
@@ -2391,7 +2393,8 @@ public final class MVStore {
...
@@ -2391,7 +2393,8 @@ public final class MVStore {
long
start
=
c
.
block
*
BLOCK_SIZE
;
long
start
=
c
.
block
*
BLOCK_SIZE
;
int
length
=
c
.
len
*
BLOCK_SIZE
;
int
length
=
c
.
len
*
BLOCK_SIZE
;
fileStore
.
free
(
start
,
length
);
fileStore
.
free
(
start
,
length
);
assert
fileStore
.
getFileLengthInUse
()
==
measureFileLengthInUse
()
:
fileStore
.
getFileLengthInUse
()
+
" != "
+
measureFileLengthInUse
();
assert
fileStore
.
getFileLengthInUse
()
==
measureFileLengthInUse
()
:
fileStore
.
getFileLengthInUse
()
+
" != "
+
measureFileLengthInUse
();
// overwrite the chunk,
// overwrite the chunk,
// so it is not be used later on
// so it is not be used later on
WriteBuffer
buff
=
getWriteBuffer
();
WriteBuffer
buff
=
getWriteBuffer
();
...
@@ -2486,16 +2489,15 @@ public final class MVStore {
...
@@ -2486,16 +2489,15 @@ public final class MVStore {
"Renaming the meta map is not allowed"
);
"Renaming the meta map is not allowed"
);
int
id
=
map
.
getId
();
int
id
=
map
.
getId
();
String
oldName
=
getMapName
(
id
);
String
oldName
=
getMapName
(
id
);
if
(
oldName
.
equals
(
newName
))
{
if
(
oldName
!=
null
&&
!
oldName
.
equals
(
newName
))
{
return
;
DataUtils
.
checkArgument
(
!
meta
.
containsKey
(
"name."
+
newName
),
"A map named {0} already exists"
,
newName
);
meta
.
remove
(
"name."
+
oldName
);
meta
.
put
(
MVMap
.
getMapKey
(
id
),
map
.
asString
(
newName
));
meta
.
put
(
"name."
+
newName
,
Integer
.
toHexString
(
id
));
markMetaChanged
();
}
}
DataUtils
.
checkArgument
(
!
meta
.
containsKey
(
"name."
+
newName
),
"A map named {0} already exists"
,
newName
);
meta
.
remove
(
"name."
+
oldName
);
meta
.
put
(
MVMap
.
getMapKey
(
id
),
map
.
asString
(
newName
));
meta
.
put
(
"name."
+
newName
,
Integer
.
toHexString
(
id
));
markMetaChanged
();
}
}
/**
/**
...
@@ -2857,7 +2859,7 @@ public final class MVStore {
...
@@ -2857,7 +2859,7 @@ public final class MVStore {
public
final
long
version
;
public
final
long
version
;
public
final
AtomicInteger
counter
=
new
AtomicInteger
();
public
final
AtomicInteger
counter
=
new
AtomicInteger
();
private
TxCounter
(
long
version
)
{
TxCounter
(
long
version
)
{
this
.
version
=
version
;
this
.
version
=
version
;
}
}
...
@@ -3136,7 +3138,5 @@ public final class MVStore {
...
@@ -3136,7 +3138,5 @@ public final class MVStore {
// Cast from HashMap<String, String> to HashMap<String, Object> is safe
// Cast from HashMap<String, String> to HashMap<String, Object> is safe
return
new
Builder
((
HashMap
)
DataUtils
.
parseMap
(
s
));
return
new
Builder
((
HashMap
)
DataUtils
.
parseMap
(
s
));
}
}
}
}
}
}
h2/src/main/org/h2/mvstore/Page.java
浏览文件 @
117b640f
...
@@ -66,16 +66,33 @@ public abstract class Page implements Cloneable
...
@@ -66,16 +66,33 @@ public abstract class Page implements Cloneable
private
volatile
boolean
removedInMemory
;
private
volatile
boolean
removedInMemory
;
/**
/**
* The estimated number of bytes used per
page object
.
* The estimated number of bytes used per
base page
.
*/
*/
private
static
final
int
PAGE_MEMORY
=
Constants
.
MEMORY_OBJECT
+
2
*
Constants
.
MEMORY_POINTER
+
Constants
.
MEMORY_ARRAY
+
17
;
private
static
final
int
PAGE_MEMORY
=
protected
static
final
int
PAGE_NODE_MEMORY
=
PAGE_MEMORY
+
Constants
.
MEMORY_POINTER
+
8
+
Constants
.
MEMORY_ARRAY
;
Constants
.
MEMORY_OBJECT
+
// this
protected
static
final
int
PAGE_LEAF_MEMORY
=
PAGE_MEMORY
+
Constants
.
MEMORY_POINTER
+
Constants
.
MEMORY_ARRAY
;
2
*
Constants
.
MEMORY_POINTER
+
// map, keys
Constants
.
MEMORY_ARRAY
+
// Object[] keys
17
;
// pos, cachedCompare, memory, removedInMemory
/**
* The estimated number of bytes used per empty internal page object.
*/
static
final
int
PAGE_NODE_MEMORY
=
PAGE_MEMORY
+
// super
Constants
.
MEMORY_POINTER
+
// children
Constants
.
MEMORY_ARRAY
+
// totalCount
8
;
/**
* The estimated number of bytes used per empty leaf page.
*/
static
final
int
PAGE_LEAF_MEMORY
=
PAGE_MEMORY
+
// super
Constants
.
MEMORY_POINTER
+
// values
Constants
.
MEMORY_ARRAY
;
// Object[] values
/**
/**
* The estimated number of bytes used per child entry.
* The estimated number of bytes used per child entry.
*/
*/
protected
static
final
int
PAGE_MEMORY_CHILD
=
Constants
.
MEMORY_POINTER
+
16
;
// 16 = two longs
static
final
int
PAGE_MEMORY_CHILD
=
Constants
.
MEMORY_POINTER
+
16
;
// 16 = two longs
/**
/**
* An empty object array.
* An empty object array.
...
@@ -90,16 +107,16 @@ public abstract class Page implements Cloneable
...
@@ -90,16 +107,16 @@ public abstract class Page implements Cloneable
private
static
final
PageReference
[]
SINGLE_EMPTY
=
{
PageReference
.
EMPTY
};
private
static
final
PageReference
[]
SINGLE_EMPTY
=
{
PageReference
.
EMPTY
};
private
Page
(
MVMap
<?,
?>
map
)
{
Page
(
MVMap
<?,
?>
map
)
{
this
.
map
=
map
;
this
.
map
=
map
;
}
}
private
Page
(
MVMap
<?,
?>
map
,
Page
source
)
{
Page
(
MVMap
<?,
?>
map
,
Page
source
)
{
this
(
map
,
source
.
keys
);
this
(
map
,
source
.
keys
);
memory
=
source
.
memory
;
memory
=
source
.
memory
;
}
}
private
Page
(
MVMap
<?,
?>
map
,
Object
keys
[])
{
Page
(
MVMap
<?,
?>
map
,
Object
keys
[])
{
this
.
map
=
map
;
this
.
map
=
map
;
this
.
keys
=
keys
;
this
.
keys
=
keys
;
}
}
...
@@ -221,9 +238,9 @@ public abstract class Page implements Cloneable
...
@@ -221,9 +238,9 @@ public abstract class Page implements Cloneable
* @param maxPos the maximum position (the end of the chunk)
* @param maxPos the maximum position (the end of the chunk)
* @param collector to report child pages positions to
* @param collector to report child pages positions to
*/
*/
static
void
readChildren
s
Positions
(
FileStore
fileStore
,
long
pos
,
static
void
readChildrenPositions
(
FileStore
fileStore
,
long
pos
,
long
filePos
,
long
maxPos
,
long
filePos
,
long
maxPos
,
MVStore
.
ChunkIdsCollector
collector
)
{
MVStore
.
ChunkIdsCollector
collector
)
{
ByteBuffer
buff
;
ByteBuffer
buff
;
int
maxLength
=
DataUtils
.
getPageMaxLength
(
pos
);
int
maxLength
=
DataUtils
.
getPageMaxLength
(
pos
);
if
(
maxLength
==
DataUtils
.
PAGE_LARGE
)
{
if
(
maxLength
==
DataUtils
.
PAGE_LARGE
)
{
...
@@ -291,9 +308,9 @@ public abstract class Page implements Cloneable
...
@@ -291,9 +308,9 @@ public abstract class Page implements Cloneable
/**
/**
* Create a copy of this page with potentially different owning map.
* Create a copy of this page with potentially different owning map.
* This is used exclusively during bulk map cop
i
ing.
* This is used exclusively during bulk map cop
y
ing.
* Child page references for nodes are cleared (repointed to an empty page)
* Child page references for nodes are cleared (re
-
pointed to an empty page)
* to be filled-in later to cop
i
ing procedure. This way it can be saved
* to be filled-in later to cop
y
ing procedure. This way it can be saved
* mid-process without tree integrity violation
* mid-process without tree integrity violation
*
*
* @param map new map to own resulting page
* @param map new map to own resulting page
...
@@ -468,7 +485,7 @@ public abstract class Page implements Cloneable
...
@@ -468,7 +485,7 @@ public abstract class Page implements Cloneable
*/
*/
abstract
Page
split
(
int
at
);
abstract
Page
split
(
int
at
);
protected
final
Object
[]
splitKeys
(
int
aCount
,
int
bCount
)
{
final
Object
[]
splitKeys
(
int
aCount
,
int
bCount
)
{
assert
aCount
+
bCount
<=
getKeyCount
();
assert
aCount
+
bCount
<=
getKeyCount
();
Object
aKeys
[]
=
createKeyStorage
(
aCount
);
Object
aKeys
[]
=
createKeyStorage
(
aCount
);
Object
bKeys
[]
=
createKeyStorage
(
bCount
);
Object
bKeys
[]
=
createKeyStorage
(
bCount
);
...
@@ -549,7 +566,7 @@ public abstract class Page implements Cloneable
...
@@ -549,7 +566,7 @@ public abstract class Page implements Cloneable
public
abstract
void
insertNode
(
int
index
,
Object
key
,
Page
childPage
);
public
abstract
void
insertNode
(
int
index
,
Object
key
,
Page
childPage
);
@SuppressWarnings
(
"SuspiciousSystemArraycopy"
)
@SuppressWarnings
(
"SuspiciousSystemArraycopy"
)
protected
final
void
insertKey
(
int
index
,
Object
key
)
{
final
void
insertKey
(
int
index
,
Object
key
)
{
int
keyCount
=
getKeyCount
();
int
keyCount
=
getKeyCount
();
assert
index
<=
keyCount
:
index
+
" > "
+
keyCount
;
assert
index
<=
keyCount
:
index
+
" > "
+
keyCount
;
Object
[]
newKeys
=
new
Object
[
keyCount
+
1
];
Object
[]
newKeys
=
new
Object
[
keyCount
+
1
];
...
@@ -571,16 +588,15 @@ public abstract class Page implements Cloneable
...
@@ -571,16 +588,15 @@ public abstract class Page implements Cloneable
public
void
remove
(
int
index
)
{
public
void
remove
(
int
index
)
{
int
keyCount
=
getKeyCount
();
int
keyCount
=
getKeyCount
();
DataType
keyType
=
map
.
getKeyType
();
DataType
keyType
=
map
.
getKeyType
();
int
indx
=
index
;
if
(
index
==
keyCount
)
{
if
(
indx
==
keyCount
)
{
--
index
;
--
indx
;
}
}
if
(
isPersistent
())
{
if
(
isPersistent
())
{
Object
old
=
getKey
(
indx
);
Object
old
=
getKey
(
ind
e
x
);
addMemory
(-
keyType
.
getMemory
(
old
));
addMemory
(-
keyType
.
getMemory
(
old
));
}
}
Object
newKeys
[]
=
new
Object
[
keyCount
-
1
];
Object
newKeys
[]
=
new
Object
[
keyCount
-
1
];
DataUtils
.
copyExcept
(
keys
,
newKeys
,
keyCount
,
indx
);
DataUtils
.
copyExcept
(
keys
,
newKeys
,
keyCount
,
ind
e
x
);
keys
=
newKeys
;
keys
=
newKeys
;
}
}
...
@@ -792,7 +808,7 @@ public abstract class Page implements Cloneable
...
@@ -792,7 +808,7 @@ public abstract class Page implements Cloneable
return
0
;
//getKeyCount();
return
0
;
//getKeyCount();
}
}
protected
final
void
addMemory
(
int
mem
)
{
final
void
addMemory
(
int
mem
)
{
memory
+=
mem
;
memory
+=
mem
;
}
}
...
@@ -826,7 +842,7 @@ public abstract class Page implements Cloneable
...
@@ -826,7 +842,7 @@ public abstract class Page implements Cloneable
return
new
Object
[
size
];
return
new
Object
[
size
];
}
}
protected
final
Object
[]
createValueStorage
(
int
size
)
final
Object
[]
createValueStorage
(
int
size
)
{
{
return
new
Object
[
size
];
return
new
Object
[
size
];
}
}
...
@@ -857,7 +873,7 @@ public abstract class Page implements Cloneable
...
@@ -857,7 +873,7 @@ public abstract class Page implements Cloneable
this
(
page
,
page
.
getPos
(),
page
.
getTotalCount
());
this
(
page
,
page
.
getPos
(),
page
.
getTotalCount
());
}
}
private
PageReference
(
long
pos
,
long
count
)
{
PageReference
(
long
pos
,
long
count
)
{
this
(
null
,
pos
,
count
);
this
(
null
,
pos
,
count
);
assert
pos
!=
0
;
assert
pos
!=
0
;
}
}
...
@@ -887,9 +903,9 @@ public abstract class Page implements Cloneable
...
@@ -887,9 +903,9 @@ public abstract class Page implements Cloneable
/**
/**
* The total entry count of this page and all children.
* The total entry count of this page and all children.
*/
*/
private
long
totalCount
;
private
long
totalCount
;
private
NonLeaf
(
MVMap
<?,
?>
map
)
{
NonLeaf
(
MVMap
<?,
?>
map
)
{
super
(
map
);
super
(
map
);
}
}
...
@@ -899,7 +915,7 @@ public abstract class Page implements Cloneable
...
@@ -899,7 +915,7 @@ public abstract class Page implements Cloneable
this
.
totalCount
=
totalCount
;
this
.
totalCount
=
totalCount
;
}
}
private
NonLeaf
(
MVMap
<?,
?>
map
,
Object
keys
[],
PageReference
children
[],
long
totalCount
)
{
NonLeaf
(
MVMap
<?,
?>
map
,
Object
keys
[],
PageReference
children
[],
long
totalCount
)
{
super
(
map
,
keys
);
super
(
map
,
keys
);
this
.
children
=
children
;
this
.
children
=
children
;
this
.
totalCount
=
totalCount
;
this
.
totalCount
=
totalCount
;
...
@@ -945,6 +961,7 @@ public abstract class Page implements Cloneable
...
@@ -945,6 +961,7 @@ public abstract class Page implements Cloneable
throw
new
UnsupportedOperationException
();
throw
new
UnsupportedOperationException
();
}
}
@Override
@SuppressWarnings
(
"SuspiciousSystemArraycopy"
)
@SuppressWarnings
(
"SuspiciousSystemArraycopy"
)
public
Page
split
(
int
at
)
{
public
Page
split
(
int
at
)
{
assert
!
isSaved
();
assert
!
isSaved
();
...
@@ -1173,7 +1190,7 @@ public abstract class Page implements Cloneable
...
@@ -1173,7 +1190,7 @@ public abstract class Page implements Cloneable
*/
*/
private
Object
values
[];
private
Object
values
[];
private
Leaf
(
MVMap
<?,
?>
map
)
{
Leaf
(
MVMap
<?,
?>
map
)
{
super
(
map
);
super
(
map
);
}
}
...
@@ -1182,7 +1199,7 @@ public abstract class Page implements Cloneable
...
@@ -1182,7 +1199,7 @@ public abstract class Page implements Cloneable
this
.
values
=
source
.
values
;
this
.
values
=
source
.
values
;
}
}
private
Leaf
(
MVMap
<?,
?>
map
,
Object
keys
[],
Object
values
[])
{
Leaf
(
MVMap
<?,
?>
map
,
Object
keys
[],
Object
values
[])
{
super
(
map
,
keys
);
super
(
map
,
keys
);
this
.
values
=
values
;
this
.
values
=
values
;
}
}
...
@@ -1256,7 +1273,7 @@ public abstract class Page implements Cloneable
...
@@ -1256,7 +1273,7 @@ public abstract class Page implements Cloneable
Object
old
=
setValueInternal
(
index
,
value
);
Object
old
=
setValueInternal
(
index
,
value
);
if
(
isPersistent
())
{
if
(
isPersistent
())
{
addMemory
(
valueType
.
getMemory
(
value
)
-
addMemory
(
valueType
.
getMemory
(
value
)
-
valueType
.
getMemory
(
old
));
valueType
.
getMemory
(
old
));
}
}
return
old
;
return
old
;
}
}
...
...
h2/src/main/org/h2/mvstore/rtree/MVRTreeMap.java
浏览文件 @
117b640f
...
@@ -26,7 +26,7 @@ public final class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
...
@@ -26,7 +26,7 @@ public final class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
/**
/**
* The spatial key type.
* The spatial key type.
*/
*/
private
final
SpatialDataType
keyType
;
final
SpatialDataType
keyType
;
private
boolean
quadraticSplit
;
private
boolean
quadraticSplit
;
...
@@ -177,29 +177,29 @@ public final class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
...
@@ -177,29 +177,29 @@ public final class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
private
V
operate
(
Page
p
,
Object
key
,
V
value
,
DecisionMaker
<?
super
V
>
decisionMaker
)
{
private
V
operate
(
Page
p
,
Object
key
,
V
value
,
DecisionMaker
<?
super
V
>
decisionMaker
)
{
V
result
=
null
;
V
result
=
null
;
if
(
p
.
isLeaf
())
{
if
(
p
.
isLeaf
())
{
int
indx
=
-
1
;
int
ind
e
x
=
-
1
;
int
keyCount
=
p
.
getKeyCount
();
int
keyCount
=
p
.
getKeyCount
();
for
(
int
i
=
0
;
i
<
keyCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
keyCount
;
i
++)
{
if
(
keyType
.
equals
(
p
.
getKey
(
i
),
key
))
{
if
(
keyType
.
equals
(
p
.
getKey
(
i
),
key
))
{
indx
=
i
;
ind
e
x
=
i
;
}
}
}
}
result
=
ind
x
<
0
?
null
:
(
V
)
p
.
getValue
(
ind
x
);
result
=
ind
ex
<
0
?
null
:
(
V
)
p
.
getValue
(
inde
x
);
Decision
decision
=
decisionMaker
.
decide
(
result
,
value
);
Decision
decision
=
decisionMaker
.
decide
(
result
,
value
);
switch
(
decision
)
{
switch
(
decision
)
{
case
ABORT:
break
;
case
ABORT:
break
;
case
REMOVE:
case
REMOVE:
if
(
indx
>=
0
)
{
if
(
ind
e
x
>=
0
)
{
p
.
remove
(
indx
);
p
.
remove
(
ind
e
x
);
}
}
break
;
break
;
case
PUT:
case
PUT:
value
=
decisionMaker
.
selectValue
(
result
,
value
);
value
=
decisionMaker
.
selectValue
(
result
,
value
);
if
(
indx
<
0
)
{
if
(
ind
e
x
<
0
)
{
p
.
insertLeaf
(
p
.
getKeyCount
(),
key
,
value
);
p
.
insertLeaf
(
p
.
getKeyCount
(),
key
,
value
);
}
else
{
}
else
{
p
.
setKey
(
indx
,
key
);
p
.
setKey
(
ind
e
x
,
key
);
p
.
setValue
(
indx
,
value
);
p
.
setValue
(
ind
e
x
,
value
);
}
}
break
;
break
;
}
}
...
@@ -608,6 +608,7 @@ public final class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
...
@@ -608,6 +608,7 @@ public final class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
* @param valueType the key type
* @param valueType the key type
* @return this
* @return this
*/
*/
@Override
public
Builder
<
V
>
valueType
(
DataType
valueType
)
{
public
Builder
<
V
>
valueType
(
DataType
valueType
)
{
setValueType
(
valueType
);
setValueType
(
valueType
);
return
this
;
return
this
;
...
...
h2/src/test/org/h2/test/store/TestMVStore.java
浏览文件 @
117b640f
...
@@ -1375,7 +1375,7 @@ public class TestMVStore extends TestBase {
...
@@ -1375,7 +1375,7 @@ public class TestMVStore extends TestBase {
// This test tries to cast in bronze some peculiar behaviour,
// This test tries to cast in bronze some peculiar behaviour,
// which is rather implementation artifact then intentional.
// which is rather implementation artifact then intentional.
// Once store is closed, only one sinle version of the data
// Once store is closed, only one sin
g
le version of the data
// will exists upon re-opening - the latest.
// will exists upon re-opening - the latest.
// I hope nobody relies on this "multi-versioning".
// I hope nobody relies on this "multi-versioning".
/*
/*
...
...
h2/src/tools/org/h2/build/doc/dictionary.txt
浏览文件 @
117b640f
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论