提交 8dfa08e6 authored 作者: Thomas Mueller's avatar Thomas Mueller

Adding data to databases with a small page size is now faster.

上级 e3efaef3
......@@ -142,6 +142,11 @@ public class PageStore implements CacheWriter {
private int freeListPagesPerList;
private boolean recoveryRunning;
/**
* The index to the first freelist page that potentially has free space.
*/
private int firstFreeListIndex;
/**
* The file size in bytes.
*/
......@@ -1065,7 +1070,9 @@ public class PageStore implements CacheWriter {
}
private void freePage(int pageId) {
PageFreeList list = getFreeListForPage(pageId);
int index = getFreeListId(pageId);
PageFreeList list = getFreeList(index);
firstFreeListIndex = Math.min(index, firstFreeListIndex);
list.free(pageId);
}
......@@ -1117,11 +1124,11 @@ public class PageStore implements CacheWriter {
private int allocatePage(BitField exclude, int first) {
int page;
// TODO could remember the first possible free list page
for (int i = 0;; i++) {
for (int i = firstFreeListIndex;; i++) {
PageFreeList list = getFreeList(i);
page = list.allocate(exclude, first);
if (page >= 0) {
firstFreeListIndex = i;
break;
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论