提交 efc5d747 authored 作者: Thomas Mueller's avatar Thomas Mueller

Various bugfixes and improvements in the page store mechanism (still experimental).

上级 16bdacb2
......@@ -172,6 +172,7 @@ class PageBtreeNode extends PageBtree {
p2.onlyPosition = true;
}
int firstChild = childPageIds[splitPoint];
readAllRows();
for (int i = splitPoint; i < entryCount;) {
p2.addChild(p2.entryCount, childPageIds[splitPoint + 1], rows[splitPoint]);
removeChild(splitPoint);
......@@ -258,7 +259,6 @@ class PageBtreeNode extends PageBtree {
// no more children - this page is empty as well
return true;
}
written = false;
removeChild(at);
index.getPageStore().updateRecord(this, true, data);
return false;
......
......@@ -60,6 +60,7 @@ class PageDataNode extends PageData {
}
private void addChild(int x, int childPageId, int key) {
written = false;
int[] newKeys = new int[entryCount + 1];
int[] newChildPageIds = new int[entryCount + 2];
if (childPageIds != null) {
......@@ -256,6 +257,14 @@ class PageDataNode extends PageData {
}
public void write(DataPage buff) throws SQLException {
write();
index.getPageStore().writePage(getPos(), data);
}
private void write() {
if (written) {
return;
}
check();
data.reset();
data.writeInt(parentPageId);
......@@ -267,10 +276,11 @@ class PageDataNode extends PageData {
data.writeInt(childPageIds[i]);
data.writeInt(keys[i]);
}
index.getPageStore().writePage(getPos(), data);
written = true;
}
private void removeChild(int i) {
written = false;
entryCount--;
if (entryCount < 0) {
Message.throwInternalError();
......
......@@ -211,7 +211,7 @@ public class PageScanIndex extends BaseIndex implements RowIndex {
result.read();
if (parent != -1) {
if (result.getParentPageId() != parent) {
throw Message.throwInternalError(result.getParentPageId() + " " + parent + " " + result);
throw Message.throwInternalError(result + " parent " + result.getParentPageId() + " expected " + parent);
}
}
return result;
......
......@@ -86,16 +86,18 @@ public class PageInputStream extends InputStream {
if (trunk == null) {
trunk = new PageStreamTrunk(store, trunkNext);
trunk.read();
trunkNext = trunk.getNextTrunk();
}
int next;
while (true) {
next = trunk.getNextPageData();
if (dataPage == -1 || dataPage == next) {
if (next != 0) {
if (next != -1) {
break;
}
trunk = new PageStreamTrunk(store, trunkNext);
trunk.read();
trunkNext = trunk.getNextTrunk();
}
}
if (trace.isDebugEnabled()) {
......
......@@ -669,6 +669,8 @@ public class PageStore implements CacheWriter {
synchronized (database) {
if (pos >= pageCount) {
throw Message.getSQLException(ErrorCode.FILE_CORRUPTED_1, pos + " of " + pageCount);
} else if (pos < 0) {
throw Message.throwInternalError("negative offset: " + pos);
}
file.seek((long) pos << pageSizeShift);
file.readFully(page.getBytes(), 0, pageSize);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论