Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
b10f04ec
提交
b10f04ec
authored
16 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
When using LOG=2 and repeatedly updating the last row rows of a table, the index file grew quickly.
上级
83a21918
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
37 行增加
和
17 行删除
+37
-17
BtreeIndex.java
h2/src/main/org/h2/index/BtreeIndex.java
+6
-9
BtreeNode.java
h2/src/main/org/h2/index/BtreeNode.java
+30
-7
BtreePage.java
h2/src/main/org/h2/index/BtreePage.java
+1
-1
没有找到文件。
h2/src/main/org/h2/index/BtreeIndex.java
浏览文件 @
b10f04ec
...
...
@@ -252,15 +252,10 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
public
void
remove
(
Session
session
,
Row
row
)
throws
SQLException
{
setChanged
(
session
);
if
(
rowCount
==
1
)
{
// TODO performance: maybe improve truncate performance in this case
truncate
(
session
);
}
else
{
BtreePage
root
=
getRoot
(
session
);
root
.
remove
(
session
,
row
);
rowCount
--;
}
}
public
boolean
canFindNext
()
{
return
true
;
...
...
@@ -351,8 +346,10 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
if
(!
database
.
getLogIndexChanges
()
&&
!
database
.
getReadOnly
())
{
storage
.
flushRecord
(
head
);
}
if
(
trace
.
isDebugEnabled
())
{
trace
.
debug
(
"Index "
+
getSQL
()
+
" head consistent="
+
head
.
getConsistent
());
}
}
public
void
truncate
(
Session
session
)
throws
SQLException
{
setChanged
(
session
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/BtreeNode.java
浏览文件 @
b10f04ec
...
...
@@ -74,7 +74,7 @@ public class BtreeNode extends BtreePage {
int
add
(
Row
newRow
,
Session
session
)
throws
SQLException
{
int
l
=
0
,
r
=
pageData
.
size
();
if
(!
Constants
.
ALLOW_EMPTY_BTREE_PAGES
&&
pageChildren
.
size
()
==
0
)
{
if
(!
Constants
.
ALLOW_EMPTY_BTREE_PAGES
&&
!
root
&&
pageChildren
.
size
()
==
0
)
{
Message
.
throwInternalError
(
"Empty btree page"
);
}
while
(
l
<
r
)
{
...
...
@@ -96,6 +96,11 @@ public class BtreeNode extends BtreePage {
}
}
int
at
=
l
;
if
(
pageChildren
.
size
()
==
0
)
{
BtreeLeaf
newLeaf
=
new
BtreeLeaf
(
index
,
new
ObjectArray
());
index
.
addPage
(
session
,
newLeaf
);
pageChildren
.
add
(
newLeaf
.
getPos
());
}
BtreePage
page
=
index
.
getPage
(
session
,
pageChildren
.
get
(
at
));
int
splitPoint
=
page
.
add
(
newRow
,
session
);
if
(
splitPoint
==
0
)
{
...
...
@@ -116,7 +121,7 @@ public class BtreeNode extends BtreePage {
SearchRow
remove
(
Session
session
,
Row
oldRow
)
throws
SQLException
{
int
l
=
0
,
r
=
pageData
.
size
();
if
(!
Constants
.
ALLOW_EMPTY_BTREE_PAGES
&&
pageChildren
.
size
()
==
0
)
{
if
(!
Constants
.
ALLOW_EMPTY_BTREE_PAGES
&&
!
root
&&
pageChildren
.
size
()
==
0
)
{
Message
.
throwInternalError
(
"Empty btree page"
);
}
int
comp
=
0
;
...
...
@@ -146,11 +151,15 @@ public class BtreeNode extends BtreePage {
index
.
deletePage
(
session
,
this
);
pageChildren
.
remove
(
at
);
if
(
pageChildren
.
size
()
==
0
)
{
if
(
root
)
{
// root page: save as it (empty)
index
.
updatePage
(
session
,
this
);
return
first
;
}
else
{
// no more children - this page is empty as well
// it can't be the root otherwise the index would have been
// truncated
return
oldRow
;
}
}
if
(
at
==
0
)
{
// the first child is empty - then the first row of this subtree
// has changed
...
...
@@ -209,7 +218,7 @@ public class BtreeNode extends BtreePage {
boolean
findFirst
(
BtreeCursor
cursor
,
SearchRow
compare
,
boolean
bigger
)
throws
SQLException
{
int
l
=
0
,
r
=
pageData
.
size
();
if
(!
Constants
.
ALLOW_EMPTY_BTREE_PAGES
&&
pageChildren
.
size
()
==
0
)
{
if
(!
Constants
.
ALLOW_EMPTY_BTREE_PAGES
&&
!
root
&&
pageChildren
.
size
()
==
0
)
{
Message
.
throwInternalError
(
"Empty btree page"
);
}
while
(
l
<
r
)
{
...
...
@@ -306,6 +315,13 @@ public class BtreeNode extends BtreePage {
}
void
first
(
BtreeCursor
cursor
)
throws
SQLException
{
if
(
pageData
.
size
()
==
0
)
{
if
(!
Constants
.
ALLOW_EMPTY_BTREE_PAGES
&&
!
root
)
{
Message
.
throwInternalError
(
"Empty btree page"
);
}
nextUpper
(
cursor
);
return
;
}
cursor
.
push
(
this
,
0
);
BtreePage
page
=
index
.
getPage
(
cursor
.
getSession
(),
pageChildren
.
get
(
0
));
page
.
first
(
cursor
);
...
...
@@ -313,6 +329,13 @@ public class BtreeNode extends BtreePage {
void
last
(
BtreeCursor
cursor
)
throws
SQLException
{
int
last
=
pageChildren
.
size
()
-
1
;
if
(
last
<
0
)
{
if
(!
Constants
.
ALLOW_EMPTY_BTREE_PAGES
&&
!
root
)
{
Message
.
throwInternalError
(
"Empty btree page"
);
}
previousUpper
(
cursor
);
return
;
}
cursor
.
push
(
this
,
last
);
BtreePage
page
=
index
.
getPage
(
cursor
.
getSession
(),
pageChildren
.
get
(
last
));
page
.
last
(
cursor
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/BtreePage.java
浏览文件 @
b10f04ec
...
...
@@ -65,7 +65,7 @@ public abstract class BtreePage extends Record {
* @param session the session
* @param row the row
* @return the new first row in the list; null if no change; the deleted row
* if no
t
empty
* if no
w
empty
*/
abstract
SearchRow
remove
(
Session
session
,
Row
row
)
throws
SQLException
;
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论