Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
227fbad7
提交
227fbad7
authored
11月 24, 2008
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
cf7264a1
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
109 行增加
和
9 行删除
+109
-9
PageData.java
h2/src/main/org/h2/index/PageData.java
+8
-0
PageDataLeaf.java
h2/src/main/org/h2/index/PageDataLeaf.java
+45
-7
PageDataNode.java
h2/src/main/org/h2/index/PageDataNode.java
+47
-0
PageScanIndex.java
h2/src/main/org/h2/index/PageScanIndex.java
+8
-2
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+1
-0
没有找到文件。
h2/src/main/org/h2/index/PageData.java
浏览文件 @
227fbad7
...
@@ -155,5 +155,13 @@ abstract class PageData {
...
@@ -155,5 +155,13 @@ abstract class PageData {
void
setParentPageId
(
int
id
)
{
void
setParentPageId
(
int
id
)
{
this
.
parentPageId
=
id
;
this
.
parentPageId
=
id
;
}
}
/**
* Remove a row.
*
* @param key the key of the row to remove
* @return true if this page is now empty
*/
abstract
boolean
remove
(
int
key
)
throws
SQLException
;
}
}
h2/src/main/org/h2/index/PageDataLeaf.java
浏览文件 @
227fbad7
...
@@ -8,8 +8,13 @@ package org.h2.index;
...
@@ -8,8 +8,13 @@ package org.h2.index;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Constants
;
import
org.h2.jdbc.JdbcSQLException
;
import
org.h2.message.Message
;
import
org.h2.message.Message
;
import
org.h2.result.Row
;
import
org.h2.result.Row
;
import
org.h2.result.SearchRow
;
import
org.h2.store.DataPageBinary
;
import
org.h2.store.DataPageBinary
;
/**
/**
...
@@ -159,7 +164,7 @@ class PageDataLeaf extends PageData {
...
@@ -159,7 +164,7 @@ class PageDataLeaf extends PageData {
return
0
;
return
0
;
}
}
private
void
removeRow
(
int
i
ndex
)
throws
SQLException
{
private
void
removeRow
(
int
i
)
throws
SQLException
{
entryCount
--;
entryCount
--;
if
(
entryCount
<=
0
)
{
if
(
entryCount
<=
0
)
{
Message
.
getInternalError
();
Message
.
getInternalError
();
...
@@ -167,12 +172,12 @@ class PageDataLeaf extends PageData {
...
@@ -167,12 +172,12 @@ class PageDataLeaf extends PageData {
int
[]
newOffsets
=
new
int
[
entryCount
];
int
[]
newOffsets
=
new
int
[
entryCount
];
int
[]
newKeys
=
new
int
[
entryCount
];
int
[]
newKeys
=
new
int
[
entryCount
];
Row
[]
newRows
=
new
Row
[
entryCount
];
Row
[]
newRows
=
new
Row
[
entryCount
];
System
.
arraycopy
(
offsets
,
0
,
newOffsets
,
0
,
i
ndex
);
System
.
arraycopy
(
offsets
,
0
,
newOffsets
,
0
,
i
);
System
.
arraycopy
(
keys
,
0
,
newKeys
,
0
,
i
ndex
);
System
.
arraycopy
(
keys
,
0
,
newKeys
,
0
,
i
);
System
.
arraycopy
(
rows
,
0
,
newRows
,
0
,
i
ndex
);
System
.
arraycopy
(
rows
,
0
,
newRows
,
0
,
i
);
System
.
arraycopy
(
offsets
,
i
ndex
+
1
,
newOffsets
,
index
,
entryCount
-
index
);
System
.
arraycopy
(
offsets
,
i
+
1
,
newOffsets
,
i
,
entryCount
-
i
);
System
.
arraycopy
(
keys
,
i
ndex
+
1
,
newKeys
,
index
,
entryCount
-
index
);
System
.
arraycopy
(
keys
,
i
+
1
,
newKeys
,
i
,
entryCount
-
i
);
System
.
arraycopy
(
rows
,
i
ndex
+
1
,
newRows
,
index
,
entryCount
-
index
);
System
.
arraycopy
(
rows
,
i
+
1
,
newRows
,
i
,
entryCount
-
i
);
start
-=
6
;
start
-=
6
;
offsets
=
newOffsets
;
offsets
=
newOffsets
;
keys
=
newKeys
;
keys
=
newKeys
;
...
@@ -231,4 +236,37 @@ class PageDataLeaf extends PageData {
...
@@ -231,4 +236,37 @@ class PageDataLeaf extends PageData {
return
this
;
return
this
;
}
}
boolean
remove
(
int
key
)
throws
SQLException
{
int
i
=
find
(
key
);
if
(
keys
[
i
]
!=
key
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
ROW_NOT_FOUND_WHEN_DELETING_1
,
index
.
getSQL
());
}
if
(
entryCount
==
1
)
{
return
true
;
}
// if (pageData.size() == 1 && !root) {
// // the last row has been deleted
// return oldRow;
// }
// pageData.remove(i);
// updateRealByteCount(false, row);
// index.updatePage(session, this);
// if (i > 0) {
// // the first row didn't change
// return null;
// }
// if (pageData.size() == 0) {
// return null;
// }
// return getData(0);
// }
// if (comp > 0) {
// r = i;
// } else {
// l = i + 1;
// }
// }
throw
Message
.
getSQLException
(
ErrorCode
.
ROW_NOT_FOUND_WHEN_DELETING_1
,
index
.
getSQL
());
}
}
}
h2/src/main/org/h2/index/PageDataNode.java
浏览文件 @
227fbad7
...
@@ -8,6 +8,9 @@ package org.h2.index;
...
@@ -8,6 +8,9 @@ package org.h2.index;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
org.h2.constant.ErrorCode
;
import
org.h2.engine.Constants
;
import
org.h2.message.Message
;
import
org.h2.result.Row
;
import
org.h2.result.Row
;
import
org.h2.result.SearchRow
;
import
org.h2.result.SearchRow
;
import
org.h2.store.DataPageBinary
;
import
org.h2.store.DataPageBinary
;
...
@@ -141,5 +144,49 @@ class PageDataNode extends PageData {
...
@@ -141,5 +144,49 @@ class PageDataNode extends PageData {
int
child
=
childPageIds
[
0
];
int
child
=
childPageIds
[
0
];
return
index
.
getPage
(
child
).
getFirstLeaf
();
return
index
.
getPage
(
child
).
getFirstLeaf
();
}
}
private
void
removeRow
(
int
i
)
throws
SQLException
{
entryCount
--;
if
(
entryCount
<=
0
)
{
Message
.
getInternalError
();
}
int
[]
newKeys
=
new
int
[
entryCount
];
int
[]
newChildPageIds
=
new
int
[
entryCount
+
1
];
System
.
arraycopy
(
keys
,
0
,
newKeys
,
0
,
i
);
System
.
arraycopy
(
childPageIds
,
0
,
newChildPageIds
,
0
,
i
);
System
.
arraycopy
(
keys
,
i
+
1
,
newKeys
,
i
,
entryCount
-
i
);
System
.
arraycopy
(
childPageIds
,
i
+
1
,
newChildPageIds
,
i
,
entryCount
-
i
+
1
);
keys
=
newKeys
;
childPageIds
=
newChildPageIds
;
}
boolean
remove
(
int
key
)
throws
SQLException
{
int
todo
;
int
at
=
find
(
key
);
// merge is not implemented to allow concurrent usage of btrees
// TODO maybe implement merge
PageData
page
=
index
.
getPage
(
childPageIds
[
at
]);
boolean
empty
=
page
.
remove
(
key
);
if
(!
empty
)
{
// the first row didn't change - nothing to do
return
false
;
}
// this child is now empty
if
(
entryCount
==
1
)
{
// no more children - this page is empty as well
// it can't be the root otherwise the index would have been
// truncated
return
true
;
}
if
(
at
==
0
)
{
// the first child is empty - then the first row of this subtree
// has changed
removeRow
(
at
);
}
else
{
// otherwise the first row didn't change
removeRow
(
at
-
1
);
}
return
false
;
}
}
}
h2/src/main/org/h2/index/PageScanIndex.java
浏览文件 @
227fbad7
...
@@ -143,8 +143,14 @@ public class PageScanIndex extends BaseIndex implements RowIndex {
...
@@ -143,8 +143,14 @@ public class PageScanIndex extends BaseIndex implements RowIndex {
public
void
remove
(
Session
session
,
Row
row
)
throws
SQLException
{
public
void
remove
(
Session
session
,
Row
row
)
throws
SQLException
{
int
invalidateRowCount
;
int
invalidateRowCount
;
int
todo
;
// setChanged(session);
rowCount
++;
if
(
rowCount
==
1
)
{
truncate
(
session
);
}
else
{
PageData
root
=
getPage
(
headPos
);
root
.
remove
(
row
.
getPos
());
rowCount
--;
}
}
}
public
void
remove
(
Session
session
)
throws
SQLException
{
public
void
remove
(
Session
session
)
throws
SQLException
{
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
227fbad7
...
@@ -284,6 +284,7 @@ java org.h2.test.TestAll timer
...
@@ -284,6 +284,7 @@ java org.h2.test.TestAll timer
/*
/*
is in-memory scan index re-using ids?
don't store default values (store a special value)
don't store default values (store a special value)
build.sh from mac (test in Ubuntu)
build.sh from mac (test in Ubuntu)
btree: maybe split at the insertion point
btree: maybe split at the insertion point
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论