Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
c9404560
提交
c9404560
authored
10月 17, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MVStore: maintain separate child count field (might be removed later on)
上级
5818aa0b
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
58 行增加
和
35 行删除
+58
-35
MVMap.java
h2/src/main/org/h2/mvstore/MVMap.java
+4
-2
Page.java
h2/src/main/org/h2/mvstore/Page.java
+48
-29
MVRTreeMap.java
h2/src/main/org/h2/mvstore/rtree/MVRTreeMap.java
+6
-4
没有找到文件。
h2/src/main/org/h2/mvstore/MVMap.java
浏览文件 @
c9404560
...
...
@@ -136,8 +136,10 @@ public class MVMap<K, V> extends AbstractMap<K, V>
long
[]
children
=
{
p
.
getPos
(),
split
.
getPos
()
};
Page
[]
childrenPages
=
{
p
,
split
};
long
[]
counts
=
{
p
.
getTotalCount
(),
split
.
getTotalCount
()
};
p
=
Page
.
create
(
this
,
writeVersion
,
1
,
keys
,
null
,
children
,
childrenPages
,
counts
,
totalCount
,
0
,
0
);
p
=
Page
.
create
(
this
,
writeVersion
,
1
,
keys
,
null
,
2
,
children
,
childrenPages
,
counts
,
totalCount
,
0
,
0
);
return
p
;
}
...
...
h2/src/main/org/h2/mvstore/Page.java
浏览文件 @
c9404560
...
...
@@ -48,6 +48,11 @@ public class Page {
*/
private
int
keyCount
;
/**
* The number of children.
*/
private
int
childCount
;
/**
* The last result of a find operation is cached.
*/
...
...
@@ -109,9 +114,10 @@ public class Page {
* @return the new page
*/
public
static
Page
createEmpty
(
MVMap
<?,
?>
map
,
long
version
)
{
return
create
(
map
,
version
,
0
,
EMPTY_OBJECT_ARRAY
,
EMPTY_OBJECT_ARRAY
,
null
,
null
,
null
,
0
,
0
,
DataUtils
.
PAGE_MEMORY
);
return
create
(
map
,
version
,
0
,
EMPTY_OBJECT_ARRAY
,
EMPTY_OBJECT_ARRAY
,
0
,
null
,
null
,
null
,
0
,
0
,
DataUtils
.
PAGE_MEMORY
);
}
/**
...
...
@@ -131,14 +137,15 @@ public class Page {
* @return the page
*/
public
static
Page
create
(
MVMap
<?,
?>
map
,
long
version
,
int
keyCount
,
Object
[]
keys
,
Object
[]
values
,
long
[]
children
,
Page
[]
childrenPages
,
long
[]
counts
,
int
keyCount
,
Object
[]
keys
,
Object
[]
values
,
int
childCount
,
long
[]
children
,
Page
[]
childrenPages
,
long
[]
counts
,
long
totalCount
,
int
sharedFlags
,
int
memory
)
{
Page
p
=
new
Page
(
map
,
version
);
// the position is 0
p
.
keys
=
keys
;
p
.
keyCount
=
keyCount
;
p
.
keys
=
keys
;
p
.
values
=
values
;
p
.
childCount
=
childCount
;
p
.
children
=
children
;
p
.
childrenPages
=
childrenPages
;
p
.
counts
=
counts
;
...
...
@@ -275,8 +282,8 @@ public class Page {
*/
public
Page
copy
(
long
version
)
{
Page
newPage
=
create
(
map
,
version
,
keyCount
,
keys
,
values
,
children
,
childrenPages
,
counts
,
totalCount
,
keyCount
,
keys
,
values
,
c
hildCount
,
children
,
childrenPages
,
c
ounts
,
totalCount
,
SHARED_KEYS
|
SHARED_VALUES
|
SHARED_CHILDREN
|
SHARED_COUNTS
,
memory
);
// mark the old as deleted
...
...
@@ -298,6 +305,9 @@ public class Page {
*/
public
int
binarySearch
(
Object
key
)
{
int
low
=
0
,
high
=
keyCount
-
1
;
// the cached index minus one, so that
// for the first time (when cachedCompare is 0),
// the default value is used
int
x
=
cachedCompare
-
1
;
if
(
x
<
0
||
x
>
high
)
{
x
=
(
low
+
high
)
>>>
1
;
...
...
@@ -360,8 +370,9 @@ public class Page {
values
=
aValues
;
sharedFlags
&=
~(
SHARED_KEYS
|
SHARED_VALUES
);
totalCount
=
a
;
Page
newPage
=
create
(
map
,
version
,
b
,
bKeys
,
bValues
,
null
,
null
,
null
,
Page
newPage
=
create
(
map
,
version
,
b
,
bKeys
,
bValues
,
0
,
null
,
null
,
null
,
bKeys
.
length
,
0
,
0
);
memory
=
calculateMemory
();
newPage
.
memory
=
newPage
.
calculateMemory
();
...
...
@@ -395,6 +406,7 @@ public class Page {
System
.
arraycopy
(
counts
,
0
,
aCounts
,
0
,
a
+
1
);
System
.
arraycopy
(
counts
,
a
+
1
,
bCounts
,
0
,
b
);
counts
=
aCounts
;
childCount
=
a
+
1
;
sharedFlags
&=
~(
SHARED_KEYS
|
SHARED_CHILDREN
|
SHARED_COUNTS
);
long
t
=
0
;
...
...
@@ -406,9 +418,10 @@ public class Page {
for
(
long
x
:
bCounts
)
{
t
+=
x
;
}
Page
newPage
=
create
(
map
,
version
,
b
-
1
,
bKeys
,
null
,
bChildren
,
bChildrenPages
,
bCounts
,
t
,
0
,
0
);
Page
newPage
=
create
(
map
,
version
,
b
-
1
,
bKeys
,
null
,
b
,
bChildren
,
bChildrenPages
,
bCounts
,
t
,
0
,
0
);
memory
=
calculateMemory
();
newPage
.
memory
=
newPage
.
calculateMemory
();
return
newPage
;
...
...
@@ -539,7 +552,7 @@ public class Page {
*/
void
removeAllRecursive
()
{
if
(
children
!=
null
)
{
for
(
int
i
=
0
,
size
=
child
ren
.
length
;
i
<
size
;
i
++)
{
for
(
int
i
=
0
,
size
=
child
Count
;
i
<
size
;
i
++)
{
Page
p
=
childrenPages
[
i
];
if
(
p
!=
null
)
{
p
.
removeAllRecursive
();
...
...
@@ -601,23 +614,26 @@ public class Page {
DataUtils
.
copyWithGap
(
keys
,
newKeys
,
keyCount
,
index
);
newKeys
[
index
]
=
key
;
keys
=
newKeys
;
keyCount
++;
long
[]
newChildren
=
new
long
[
child
ren
.
length
+
1
];
DataUtils
.
copyWithGap
(
children
,
newChildren
,
child
ren
.
length
,
index
);
long
[]
newChildren
=
new
long
[
child
Count
+
1
];
DataUtils
.
copyWithGap
(
children
,
newChildren
,
child
Count
,
index
);
newChildren
[
index
]
=
childPage
.
getPos
();
children
=
newChildren
;
Page
[]
newChildrenPages
=
new
Page
[
child
renPages
.
length
+
1
];
DataUtils
.
copyWithGap
(
childrenPages
,
newChildrenPages
,
child
renPages
.
length
,
index
);
Page
[]
newChildrenPages
=
new
Page
[
child
Count
+
1
];
DataUtils
.
copyWithGap
(
childrenPages
,
newChildrenPages
,
child
Count
,
index
);
newChildrenPages
[
index
]
=
childPage
;
childrenPages
=
newChildrenPages
;
long
[]
newCounts
=
new
long
[
c
ounts
.
length
+
1
];
DataUtils
.
copyWithGap
(
counts
,
newCounts
,
c
ounts
.
length
,
index
);
long
[]
newCounts
=
new
long
[
c
hildCount
+
1
];
DataUtils
.
copyWithGap
(
counts
,
newCounts
,
c
hildCount
,
index
);
newCounts
[
index
]
=
childPage
.
totalCount
;
counts
=
newCounts
;
childCount
++;
sharedFlags
&=
~(
SHARED_KEYS
|
SHARED_CHILDREN
|
SHARED_COUNTS
);
totalCount
+=
childPage
.
totalCount
;
memory
+=
map
.
getKeyType
().
getMemory
(
key
);
...
...
@@ -666,21 +682,23 @@ public class Page {
memory
-=
DataUtils
.
PAGE_MEMORY_CHILD
;
long
countOffset
=
counts
[
index
];
long
[]
newChildren
=
new
long
[
child
ren
.
length
-
1
];
DataUtils
.
copyExcept
(
children
,
newChildren
,
child
ren
.
length
,
index
);
long
[]
newChildren
=
new
long
[
child
Count
-
1
];
DataUtils
.
copyExcept
(
children
,
newChildren
,
child
Count
,
index
);
children
=
newChildren
;
Page
[]
newChildrenPages
=
new
Page
[
child
renPages
.
length
-
1
];
Page
[]
newChildrenPages
=
new
Page
[
child
Count
-
1
];
DataUtils
.
copyExcept
(
childrenPages
,
newChildrenPages
,
child
renPages
.
length
,
index
);
child
Count
,
index
);
childrenPages
=
newChildrenPages
;
long
[]
newCounts
=
new
long
[
c
ounts
.
length
-
1
];
DataUtils
.
copyExcept
(
counts
,
newCounts
,
c
ounts
.
length
,
index
);
long
[]
newCounts
=
new
long
[
c
hildCount
-
1
];
DataUtils
.
copyExcept
(
counts
,
newCounts
,
c
hildCount
,
index
);
counts
=
newCounts
;
sharedFlags
&=
~(
SHARED_CHILDREN
|
SHARED_COUNTS
);
totalCount
-=
countOffset
;
childCount
--;
}
}
...
...
@@ -740,6 +758,7 @@ public class Page {
keys
[
i
]
=
k
;
}
if
(
node
)
{
childCount
=
len
+
1
;
children
=
new
long
[
len
+
1
];
for
(
int
i
=
0
;
i
<=
len
;
i
++)
{
children
[
i
]
=
buff
.
getLong
();
...
...
@@ -846,7 +865,7 @@ public class Page {
return
;
}
if
(!
isLeaf
())
{
int
len
=
child
ren
.
length
;
int
len
=
child
Count
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
Page
p
=
childrenPages
[
i
];
if
(
p
!=
null
)
{
...
...
@@ -863,7 +882,7 @@ public class Page {
*/
void
writeEnd
()
{
if
(!
isLeaf
())
{
int
len
=
child
ren
.
length
;
int
len
=
child
Count
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
Page
p
=
childrenPages
[
i
];
if
(
p
!=
null
)
{
...
...
@@ -883,7 +902,7 @@ public class Page {
}
public
int
getChildPageCount
()
{
return
child
ren
.
length
;
return
child
Count
;
}
@Override
...
...
h2/src/main/org/h2/mvstore/rtree/MVRTreeMap.java
浏览文件 @
c9404560
...
...
@@ -235,8 +235,9 @@ public class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
long
[]
children
=
{
p
.
getPos
(),
split
.
getPos
(),
0
};
Page
[]
childrenPages
=
{
p
,
split
,
null
};
long
[]
counts
=
{
p
.
getTotalCount
(),
split
.
getTotalCount
(),
0
};
p
=
Page
.
create
(
this
,
v
,
2
,
keys
,
null
,
children
,
childrenPages
,
counts
,
p
=
Page
.
create
(
this
,
v
,
2
,
keys
,
null
,
3
,
children
,
childrenPages
,
counts
,
totalCount
,
0
,
0
);
// now p is a node; continues
}
...
...
@@ -432,8 +433,9 @@ public class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
Object
[]
values
=
leaf
?
new
Object
[
4
]
:
null
;
long
[]
c
=
leaf
?
null
:
new
long
[
1
];
Page
[]
cp
=
leaf
?
null
:
new
Page
[
1
];
return
Page
.
create
(
this
,
writeVersion
,
0
,
new
Object
[
4
],
values
,
c
,
cp
,
c
,
0
,
0
,
0
);
return
Page
.
create
(
this
,
writeVersion
,
0
,
new
Object
[
4
],
values
,
leaf
?
0
:
1
,
c
,
cp
,
c
,
0
,
0
,
0
);
}
private
static
void
move
(
Page
source
,
Page
target
,
int
sourceIndex
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论