Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
72e65d6f
提交
72e65d6f
authored
1月 21, 2019
作者:
Andrei Tokar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
consistency in using getKeyCount()
上级
f0fb7e00
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
19 行增加
和
19 行删除
+19
-19
MVStoreTool.java
h2/src/main/org/h2/mvstore/MVStoreTool.java
+3
-6
Page.java
h2/src/main/org/h2/mvstore/Page.java
+16
-13
没有找到文件。
h2/src/main/org/h2/mvstore/MVStoreTool.java
浏览文件 @
72e65d6f
...
...
@@ -699,8 +699,8 @@ public class MVStoreTool {
@Override
public
void
write
(
WriteBuffer
buff
,
Object
[]
obj
,
int
len
,
boolean
key
)
{
for
(
Object
o
:
obj
)
{
write
(
buff
,
o
);
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
write
(
buff
,
o
bj
[
i
]
);
}
}
...
...
@@ -717,12 +717,9 @@ public class MVStoreTool {
@Override
public
void
read
(
ByteBuffer
buff
,
Object
[]
obj
,
int
len
,
boolean
key
)
{
for
(
int
i
=
0
;
i
<
obj
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
obj
[
i
]
=
read
(
buff
);
}
}
}
}
h2/src/main/org/h2/mvstore/Page.java
浏览文件 @
72e65d6f
...
...
@@ -468,7 +468,7 @@ public abstract class Page implements Cloneable
* @return the value or null
*/
int
binarySearch
(
Object
key
)
{
int
low
=
0
,
high
=
keys
.
length
-
1
;
int
low
=
0
,
high
=
getKeyCount
()
-
1
;
// the cached index minus one, so that
// for the first time (when cachedCompare is 0),
// the default value is used
...
...
@@ -550,7 +550,7 @@ public abstract class Page implements Cloneable
public
abstract
long
getTotalCount
();
/**
* Get the
descendant counts for the
given child.
* Get the
number of key-value pairs for a
given child.
*
* @param index the child index
* @return the descendant count
...
...
@@ -621,7 +621,7 @@ public abstract class Page implements Cloneable
final
void
insertKey
(
int
index
,
Object
key
)
{
int
keyCount
=
getKeyCount
();
assert
index
<=
keyCount
:
index
+
" > "
+
keyCount
;
Object
[]
newKeys
=
new
Object
[
keyCount
+
1
]
;
Object
[]
newKeys
=
createKeyStorage
(
keyCount
+
1
)
;
DataUtils
.
copyWithGap
(
keys
,
newKeys
,
keyCount
,
index
);
keys
=
newKeys
;
...
...
@@ -647,7 +647,7 @@ public abstract class Page implements Cloneable
Object
old
=
getKey
(
index
);
addMemory
(-
MEMORY_POINTER
-
keyType
.
getMemory
(
old
));
}
Object
[]
newKeys
=
new
Object
[
keyCount
-
1
]
;
Object
[]
newKeys
=
createKeyStorage
(
keyCount
-
1
)
;
DataUtils
.
copyExcept
(
keys
,
newKeys
,
keyCount
,
index
);
keys
=
newKeys
;
}
...
...
@@ -661,7 +661,7 @@ public abstract class Page implements Cloneable
private
void
read
(
ByteBuffer
buff
,
int
chunkId
)
{
int
pageLength
=
buff
.
remaining
()
+
4
;
// size of int, since we've read page length already
int
len
=
DataUtils
.
readVarInt
(
buff
);
keys
=
new
Object
[
len
]
;
keys
=
createKeyStorage
(
len
)
;
int
type
=
buff
.
get
();
if
(
isLeaf
()
!=
((
type
&
1
)
==
PAGE_TYPE_LEAF
))
{
throw
DataUtils
.
newIllegalStateException
(
...
...
@@ -728,7 +728,7 @@ public abstract class Page implements Cloneable
buff
.
put
((
byte
)
type
);
writeChildren
(
buff
,
true
);
int
compressStart
=
buff
.
position
();
map
.
getKeyType
().
write
(
buff
,
keys
,
getKeyCount
()
,
true
);
map
.
getKeyType
().
write
(
buff
,
keys
,
len
,
true
);
writeValues
(
buff
);
MVStore
store
=
map
.
getStore
();
int
expLen
=
buff
.
position
()
-
compressStart
;
...
...
@@ -889,10 +889,11 @@ public abstract class Page implements Cloneable
* @return memory in bytes
*/
protected
int
calculateMemory
()
{
int
mem
=
keys
.
length
*
MEMORY_POINTER
;
int
keyCount
=
getKeyCount
();
int
mem
=
keyCount
*
MEMORY_POINTER
;
DataType
keyType
=
map
.
getKeyType
();
for
(
Object
key
:
keys
)
{
mem
+=
keyType
.
getMemory
(
key
);
for
(
int
i
=
0
;
i
<
keyCount
;
i
++
)
{
mem
+=
keyType
.
getMemory
(
key
s
[
i
]
);
}
return
mem
;
}
...
...
@@ -1472,6 +1473,7 @@ public abstract class Page implements Cloneable
long
getCounts
(
int
index
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
void
setChild
(
int
index
,
Page
c
)
{
throw
new
UnsupportedOperationException
();
...
...
@@ -1510,6 +1512,7 @@ public abstract class Page implements Cloneable
}
}
}
@Override
public
void
insertNode
(
int
index
,
Object
key
,
Page
childPage
)
{
throw
new
UnsupportedOperationException
();
...
...
@@ -1573,11 +1576,11 @@ public abstract class Page implements Cloneable
@Override
protected
int
calculateMemory
()
{
int
mem
=
super
.
calculateMemory
()
+
PAGE_LEAF_MEMORY
+
values
.
length
*
MEMORY_POINTER
;
int
keyCount
=
getKeyCount
();
int
mem
=
super
.
calculateMemory
()
+
PAGE_LEAF_MEMORY
+
keyCount
*
MEMORY_POINTER
;
DataType
valueType
=
map
.
getValueType
();
for
(
Object
value
:
values
)
{
mem
+=
valueType
.
getMemory
(
value
);
for
(
int
i
=
0
;
i
<
keyCount
;
i
++
)
{
mem
+=
valueType
.
getMemory
(
value
s
[
i
]
);
}
return
mem
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论