提交 825ebf50 authored 作者: Thomas Mueller's avatar Thomas Mueller

Compaction bugfix

上级 4b982f97
...@@ -1224,7 +1224,7 @@ public class MVMap<K, V> extends AbstractMap<K, V> ...@@ -1224,7 +1224,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
private Page copy(Page source, CursorPos parent) { private Page copy(Page source, CursorPos parent) {
Page target = Page.create(this, writeVersion, source); Page target = Page.create(this, writeVersion, source);
if (target.isLeaf()) { if (source.isLeaf()) {
Page child = target; Page child = target;
for (CursorPos p = parent; p != null; p = p.parent) { for (CursorPos p = parent; p != null; p = p.parent) {
p.page.setChild(p.index, child); p.page.setChild(p.index, child);
...@@ -1236,6 +1236,11 @@ public class MVMap<K, V> extends AbstractMap<K, V> ...@@ -1236,6 +1236,11 @@ public class MVMap<K, V> extends AbstractMap<K, V>
} }
} }
} else { } else {
// temporarily, replace child pages with empty pages,
// to ensure there are no links to the old store
for (int i = 0; i < getChildPageCount(target); i++) {
target.setChild(i, null);
}
CursorPos pos = new CursorPos(target, 0, parent); CursorPos pos = new CursorPos(target, 0, parent);
for (int i = 0; i < getChildPageCount(target); i++) { for (int i = 0; i < getChildPageCount(target); i++) {
pos.index = i; pos.index = i;
......
...@@ -467,7 +467,14 @@ public class Page { ...@@ -467,7 +467,14 @@ public class Page {
* @param c the new child page * @param c the new child page
*/ */
public void setChild(int index, Page c) { public void setChild(int index, Page c) {
if (c != children[index].page || c.getPos() != children[index].pos) { if (c == null) {
long oldCount = children[index].count;
children = Arrays.copyOf(children, children.length);
PageReference ref = new PageReference(null, 0, 0);
children[index] = ref;
totalCount -= oldCount;
} else if (c != children[index].page ||
c.getPos() != children[index].pos) {
long oldCount = children[index].count; long oldCount = children[index].count;
children = Arrays.copyOf(children, children.length); children = Arrays.copyOf(children, children.length);
PageReference ref = new PageReference(c, c.pos, c.totalCount); PageReference ref = new PageReference(c, c.pos, c.totalCount);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论