Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
2505065e
提交
2505065e
authored
1月 22, 2014
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Prepare for improved memory housekeeping
上级
d089b55f
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
32 行增加
和
21 行删除
+32
-21
Page.java
h2/src/main/org/h2/mvstore/Page.java
+32
-21
没有找到文件。
h2/src/main/org/h2/mvstore/Page.java
浏览文件 @
2505065e
...
...
@@ -152,7 +152,11 @@ public class Page {
p
.
counts
=
counts
;
p
.
totalCount
=
totalCount
;
p
.
sharedFlags
=
sharedFlags
;
p
.
memory
=
memory
==
0
?
p
.
calculateMemory
()
:
memory
;
if
(
memory
==
0
)
{
p
.
recalculateMemory
();
}
else
{
p
.
addMemory
(
memory
);
}
MVStore
store
=
map
.
store
;
if
(
store
!=
null
)
{
store
.
registerUnsavedPage
();
...
...
@@ -286,7 +290,7 @@ public class Page {
keyCount
,
keys
,
values
,
childCount
,
children
,
childrenPages
,
counts
,
totalCount
,
SHARED_KEYS
|
SHARED_VALUES
|
SHARED_CHILDREN
|
SHARED_COUNTS
,
memory
);
getMemory
()
);
// mark the old as deleted
removePage
();
newPage
.
cachedCompare
=
cachedCompare
;
...
...
@@ -375,8 +379,8 @@ public class Page {
b
,
bKeys
,
bValues
,
0
,
null
,
null
,
null
,
bKeys
.
length
,
0
,
0
);
memory
=
calculateMemory
();
newPage
.
memory
=
newPage
.
calculateMemory
();
re
calculateMemory
();
newPage
.
re
calculateMemory
();
return
newPage
;
}
...
...
@@ -423,8 +427,8 @@ public class Page {
b
-
1
,
bKeys
,
null
,
b
,
bChildren
,
bChildrenPages
,
bCounts
,
t
,
0
,
0
);
memory
=
calculateMemory
();
newPage
.
memory
=
newPage
.
calculateMemory
();
re
calculateMemory
();
newPage
.
re
calculateMemory
();
return
newPage
;
}
...
...
@@ -521,10 +525,11 @@ public class Page {
}
Object
old
=
keys
[
index
];
DataType
keyType
=
map
.
getKeyType
();
int
mem
=
keyType
.
getMemory
(
key
);
if
(
old
!=
null
)
{
mem
ory
-=
keyType
.
getMemory
(
old
);
mem
-=
keyType
.
getMemory
(
old
);
}
memory
+=
keyType
.
getMemory
(
key
);
addMemory
(
mem
);
keys
[
index
]
=
key
;
}
...
...
@@ -542,8 +547,8 @@ public class Page {
sharedFlags
&=
~
SHARED_VALUES
;
}
DataType
valueType
=
map
.
getValueType
();
memory
-=
valueType
.
getMemory
(
old
);
memory
+=
valueType
.
getMemory
(
value
);
addMemory
(
valueType
.
getMemory
(
value
)
-
valueType
.
getMemory
(
old
)
);
values
[
index
]
=
value
;
return
old
;
}
...
...
@@ -598,8 +603,8 @@ public class Page {
keyCount
++;
sharedFlags
&=
~(
SHARED_KEYS
|
SHARED_VALUES
);
totalCount
++;
memory
+=
map
.
getKeyType
().
getMemory
(
key
);
memory
+=
map
.
getValueType
().
getMemory
(
value
);
addMemory
(
map
.
getKeyType
().
getMemory
(
key
)
+
map
.
getValueType
().
getMemory
(
value
)
);
}
/**
...
...
@@ -637,8 +642,8 @@ public class Page {
sharedFlags
&=
~(
SHARED_KEYS
|
SHARED_CHILDREN
|
SHARED_COUNTS
);
totalCount
+=
childPage
.
totalCount
;
memory
+=
map
.
getKeyType
().
getMemory
(
key
);
memory
+=
DataUtils
.
PAGE_MEMORY_CHILD
;
addMemory
(
map
.
getKeyType
().
getMemory
(
key
)
+
DataUtils
.
PAGE_MEMORY_CHILD
)
;
}
/**
...
...
@@ -649,7 +654,7 @@ public class Page {
public
void
remove
(
int
index
)
{
int
keyIndex
=
index
>=
keyCount
?
index
-
1
:
index
;
Object
old
=
keys
[
keyIndex
];
memory
-=
map
.
getKeyType
().
getMemory
(
old
);
addMemory
(-
map
.
getKeyType
().
getMemory
(
old
)
);
if
((
sharedFlags
&
SHARED_KEYS
)
==
0
&&
keys
.
length
>
keyCount
-
4
)
{
if
(
keyIndex
<
keyCount
-
1
)
{
System
.
arraycopy
(
keys
,
keyIndex
+
1
,
keys
,
keyIndex
,
keyCount
-
keyIndex
-
1
);
...
...
@@ -664,7 +669,7 @@ public class Page {
if
(
values
!=
null
)
{
old
=
values
[
index
];
memory
-=
map
.
getValueType
().
getMemory
(
old
);
addMemory
(-
map
.
getValueType
().
getMemory
(
old
)
);
if
((
sharedFlags
&
SHARED_VALUES
)
==
0
&&
values
.
length
>
keyCount
-
4
)
{
if
(
index
<
keyCount
-
1
)
{
System
.
arraycopy
(
values
,
index
+
1
,
values
,
index
,
keyCount
-
index
-
1
);
...
...
@@ -680,7 +685,7 @@ public class Page {
}
keyCount
--;
if
(
children
!=
null
)
{
memory
-=
DataUtils
.
PAGE_MEMORY_CHILD
;
addMemory
(-
DataUtils
.
PAGE_MEMORY_CHILD
)
;
long
countOffset
=
counts
[
index
];
long
[]
newChildren
=
new
long
[
childCount
-
1
];
...
...
@@ -782,7 +787,7 @@ public class Page {
}
totalCount
=
len
;
}
memory
=
calculateMemory
();
re
calculateMemory
();
}
/**
...
...
@@ -929,7 +934,9 @@ public class Page {
public
int
getMemory
()
{
if
(
MVStore
.
ASSERT
)
{
if
(
memory
!=
calculateMemory
())
{
int
mem
=
memory
;
recalculateMemory
();
if
(
mem
!=
memory
)
{
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_INTERNAL
,
"Memory calculation error"
);
}
...
...
@@ -937,7 +944,11 @@ public class Page {
return
memory
;
}
private
int
calculateMemory
()
{
private
void
addMemory
(
int
mem
)
{
memory
+=
mem
;
}
private
void
recalculateMemory
()
{
int
mem
=
DataUtils
.
PAGE_MEMORY
;
DataType
keyType
=
map
.
getKeyType
();
for
(
int
i
=
0
;
i
<
keyCount
;
i
++)
{
...
...
@@ -951,7 +962,7 @@ public class Page {
}
else
{
mem
+=
this
.
getChildPageCount
()
*
DataUtils
.
PAGE_MEMORY_CHILD
;
}
return
mem
;
addMemory
(
mem
-
memory
)
;
}
void
setVersion
(
long
version
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论