Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
86777f9f
提交
86777f9f
authored
1月 05, 2019
作者:
Noel Grandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
javadoc for Page
上级
41b5225a
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
76 行增加
和
1 行删除
+76
-1
Page.java
h2/src/main/org/h2/mvstore/Page.java
+76
-1
没有找到文件。
h2/src/main/org/h2/mvstore/Page.java
浏览文件 @
86777f9f
...
@@ -137,7 +137,7 @@ public abstract class Page implements Cloneable
...
@@ -137,7 +137,7 @@ public abstract class Page implements Cloneable
}
}
/**
/**
* Create a new, empty page.
* Create a new, empty
leaf
page.
*
*
* @param map the map
* @param map the map
* @return the new page
* @return the new page
...
@@ -146,6 +146,12 @@ public abstract class Page implements Cloneable
...
@@ -146,6 +146,12 @@ public abstract class Page implements Cloneable
return
createLeaf
(
map
,
EMPTY_OBJECT_ARRAY
,
EMPTY_OBJECT_ARRAY
,
PAGE_LEAF_MEMORY
);
return
createLeaf
(
map
,
EMPTY_OBJECT_ARRAY
,
EMPTY_OBJECT_ARRAY
,
PAGE_LEAF_MEMORY
);
}
}
/**
* Create a new, empty internal node page.
*
* @param map the map
* @return the new page
*/
static
Page
createEmptyNode
(
MVMap
<?,
?>
map
)
{
static
Page
createEmptyNode
(
MVMap
<?,
?>
map
)
{
return
createNode
(
map
,
EMPTY_OBJECT_ARRAY
,
SINGLE_EMPTY
,
0
,
return
createNode
(
map
,
EMPTY_OBJECT_ARRAY
,
SINGLE_EMPTY
,
0
,
PAGE_NODE_MEMORY
+
MEMORY_POINTER
+
PAGE_MEMORY_CHILD
);
// there is always one child
PAGE_NODE_MEMORY
+
MEMORY_POINTER
+
PAGE_MEMORY_CHILD
);
// there is always one child
...
@@ -396,6 +402,11 @@ public abstract class Page implements Cloneable
...
@@ -396,6 +402,11 @@ public abstract class Page implements Cloneable
return
buff
.
toString
();
return
buff
.
toString
();
}
}
/**
* Dump debug data for this page.
*
* @param buff append buffer
*/
protected
void
dump
(
StringBuilder
buff
)
{
protected
void
dump
(
StringBuilder
buff
)
{
buff
.
append
(
"id: "
).
append
(
System
.
identityHashCode
(
this
)).
append
(
'\n'
);
buff
.
append
(
"id: "
).
append
(
System
.
identityHashCode
(
this
)).
append
(
'\n'
);
buff
.
append
(
"pos: "
).
append
(
Long
.
toHexString
(
pos
)).
append
(
'\n'
);
buff
.
append
(
"pos: "
).
append
(
Long
.
toHexString
(
pos
)).
append
(
'\n'
);
...
@@ -490,6 +501,13 @@ public abstract class Page implements Cloneable
...
@@ -490,6 +501,13 @@ public abstract class Page implements Cloneable
*/
*/
abstract
Page
split
(
int
at
);
abstract
Page
split
(
int
at
);
/**
* Split the current keys array into two arrays.
*
* @param aCount size of the first array.
* @param bCount size of the second array/
* @return the second array.
*/
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
);
...
@@ -502,6 +520,12 @@ public abstract class Page implements Cloneable
...
@@ -502,6 +520,12 @@ public abstract class Page implements Cloneable
abstract
void
expand
(
int
extraKeyCount
,
Object
[]
extraKeys
,
Object
[]
extraValues
);
abstract
void
expand
(
int
extraKeyCount
,
Object
[]
extraKeys
,
Object
[]
extraValues
);
/**
* Expand the keys array.
*
* @param extraKeyCount number of extra key entries to create
* @param extraKeys extra key values
*/
final
void
expandKeys
(
int
extraKeyCount
,
Object
[]
extraKeys
)
{
final
void
expandKeys
(
int
extraKeyCount
,
Object
[]
extraKeys
)
{
int
keyCount
=
getKeyCount
();
int
keyCount
=
getKeyCount
();
Object
[]
newKeys
=
createKeyStorage
(
keyCount
+
extraKeyCount
);
Object
[]
newKeys
=
createKeyStorage
(
keyCount
+
extraKeyCount
);
...
@@ -580,6 +604,12 @@ public abstract class Page implements Cloneable
...
@@ -580,6 +604,12 @@ 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
);
/**
* Insert a key into the key array
*
* @param index index to insert at
* @param key the key value
*/
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
;
...
@@ -660,6 +690,11 @@ public abstract class Page implements Cloneable
...
@@ -660,6 +690,11 @@ public abstract class Page implements Cloneable
recalculateMemory
();
recalculateMemory
();
}
}
/**
* Read the page payload from the buffer.
*
* @param buff the buffer
*/
protected
abstract
void
readPayLoad
(
ByteBuffer
buff
);
protected
abstract
void
readPayLoad
(
ByteBuffer
buff
);
public
final
boolean
isSaved
()
{
public
final
boolean
isSaved
()
{
...
@@ -748,8 +783,19 @@ public abstract class Page implements Cloneable
...
@@ -748,8 +783,19 @@ public abstract class Page implements Cloneable
return
typePos
+
1
;
return
typePos
+
1
;
}
}
/**
* Write values that the buffer contains to the buff.
*
* @param buff the target buffer
*/
protected
abstract
void
writeValues
(
WriteBuffer
buff
);
protected
abstract
void
writeValues
(
WriteBuffer
buff
);
/**
* Write page children to the buff.
*
* @param buff the target buffer
* @param withCounts true if the descendant counts should be written
*/
protected
abstract
void
writeChildren
(
WriteBuffer
buff
,
boolean
withCounts
);
protected
abstract
void
writeChildren
(
WriteBuffer
buff
,
boolean
withCounts
);
/**
/**
...
@@ -829,6 +875,11 @@ public abstract class Page implements Cloneable
...
@@ -829,6 +875,11 @@ public abstract class Page implements Cloneable
memory
=
calculateMemory
();
memory
=
calculateMemory
();
}
}
/**
* Calculate estimated memory used in persistent case.
*
* @return memory in bytes
*/
protected
int
calculateMemory
()
{
protected
int
calculateMemory
()
{
int
mem
=
keys
.
length
*
MEMORY_POINTER
;
int
mem
=
keys
.
length
*
MEMORY_POINTER
;
DataType
keyType
=
map
.
getKeyType
();
DataType
keyType
=
map
.
getKeyType
();
...
@@ -842,6 +893,9 @@ public abstract class Page implements Cloneable
...
@@ -842,6 +893,9 @@ public abstract class Page implements Cloneable
return
true
;
return
true
;
}
}
/**
* Called when done with copying page.
*/
public
void
setComplete
()
{}
public
void
setComplete
()
{}
/**
/**
...
@@ -859,13 +913,28 @@ public abstract class Page implements Cloneable
...
@@ -859,13 +913,28 @@ public abstract class Page implements Cloneable
public
abstract
CursorPos
getAppendCursorPos
(
CursorPos
cursorPos
);
public
abstract
CursorPos
getAppendCursorPos
(
CursorPos
cursorPos
);
/**
* Remove all page data recursively.
*/
public
abstract
void
removeAllRecursive
();
public
abstract
void
removeAllRecursive
();
/**
* Create array for keys storage.
*
* @param size number of entries
* @return values array
*/
private
Object
[]
createKeyStorage
(
int
size
)
private
Object
[]
createKeyStorage
(
int
size
)
{
{
return
new
Object
[
size
];
return
new
Object
[
size
];
}
}
/**
* Create array for values storage.
*
* @param size number of entries
* @return values array
*/
final
Object
[]
createValueStorage
(
int
size
)
final
Object
[]
createValueStorage
(
int
size
)
{
{
return
new
Object
[
size
];
return
new
Object
[
size
];
...
@@ -876,6 +945,9 @@ public abstract class Page implements Cloneable
...
@@ -876,6 +945,9 @@ public abstract class Page implements Cloneable
*/
*/
public
static
final
class
PageReference
{
public
static
final
class
PageReference
{
/**
* Singleton object used when arrays of PageReference have not yet been filled.
*/
public
static
final
PageReference
EMPTY
=
new
PageReference
(
null
,
0
,
0
);
public
static
final
PageReference
EMPTY
=
new
PageReference
(
null
,
0
,
0
);
/**
/**
...
@@ -928,6 +1000,9 @@ public abstract class Page implements Cloneable
...
@@ -928,6 +1000,9 @@ public abstract class Page implements Cloneable
return
pos
;
return
pos
;
}
}
/**
* Re-acquire position from in-memory page.
*/
void
resetPos
()
{
void
resetPos
()
{
Page
p
=
page
;
Page
p
=
page
;
if
(
p
!=
null
&&
p
.
isSaved
())
{
if
(
p
!=
null
&&
p
.
isSaved
())
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论