提交 530549d2 authored 作者: Thomas Mueller's avatar Thomas Mueller

Page store bugfixes

上级 06214924
......@@ -222,11 +222,6 @@ public class PageDataLeaf extends PageData {
all.checkCapacity(data.length());
all.write(data.getBytes(), 0, data.length());
data.truncate(index.getPageStore().getPageSize());
// write the page now to disk, to avoid problems
// when the page needs to be written before the overflow
// is written to disk (the cache first removes elements,
// moves them in a write queue, and then writes them)
write(null);
do {
int type, size, next;
if (remaining <= pageSize - PageDataOverflow.START_LAST) {
......@@ -508,18 +503,4 @@ public class PageDataLeaf extends PageData {
return index.getMemorySizePerPage();
}
void setParentPageId(int id) {
// never reset the written flag not only for speed, but also
// because if would cause the page to be written again if
// it contains overflow, which would cause the data to be read,
// and that's not possible because the overflow page may be
// not in the cache but in the write queue already
if (written) {
data.setInt(START_PARENT, id);
this.parentPageId = id;
} else {
super.setParentPageId(id);
}
}
}
......@@ -110,6 +110,7 @@ public class PageDataOverflow extends Page {
Data data = store.createData();
PageDataOverflow p = new PageDataOverflow(store, page, data);
data.writeByte((byte) type);
data.writeShortInt(0);
data.writeInt(parentPageId);
if (type == Page.TYPE_DATA_OVERFLOW) {
data.writeInt(next);
......
......@@ -126,8 +126,11 @@ public class CacheLRU implements Cache {
private void removeOld() throws SQLException {
int i = 0;
int todoImplementInOtherCachesAsWell;
ObjectArray<CacheObject> changed = ObjectArray.newInstance();
while (sizeMemory * 4 > maxSize * 3 && recordCount > Constants.CACHE_MIN_RECORDS) {
int mem = sizeMemory;
int rc = recordCount;
while (mem * 4 > maxSize * 3 && rc > Constants.CACHE_MIN_RECORDS) {
i++;
if (i == recordCount) {
writer.flushLog();
......@@ -151,10 +154,13 @@ public class CacheLRU implements Cache {
addToFront(last);
continue;
}
remove(last.getPos());
if (last.isChanged()) {
changed.add(last);
} else {
remove(last.getPos());
}
rc--;
mem -= last.getMemorySize();
}
if (changed.size() > 0) {
CacheObject.sort(changed);
......@@ -162,6 +168,10 @@ public class CacheLRU implements Cache {
CacheObject rec = changed.get(i);
writer.writeBack(rec);
}
for (i = 0; i < changed.size(); i++) {
CacheObject rec = changed.get(i);
remove(rec.getPos());
}
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论