提交 99fd7b9b authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 fcac9575
...@@ -35,6 +35,11 @@ public class PageFreeList extends Record { ...@@ -35,6 +35,11 @@ public class PageFreeList extends Record {
this.nextPage = nextPage; this.nextPage = nextPage;
} }
/**
* Allocate a page from the free list.
*
* @return the page
*/
int allocate() throws SQLException { int allocate() throws SQLException {
int size = array.size(); int size = array.size();
if (size > 0) { if (size > 0) {
...@@ -54,6 +59,9 @@ public class PageFreeList extends Record { ...@@ -54,6 +59,9 @@ public class PageFreeList extends Record {
return (store.getPageSize() - 9) / DataPage.LENGTH_INT; return (store.getPageSize() - 9) / DataPage.LENGTH_INT;
} }
/**
* Read the page from the disk.
*/
void read() throws SQLException { void read() throws SQLException {
store.readPage(getPos(), page); store.readPage(getPos(), page);
int p = page.readInt(); int p = page.readInt();
...@@ -79,6 +87,11 @@ public class PageFreeList extends Record { ...@@ -79,6 +87,11 @@ public class PageFreeList extends Record {
} }
} }
/**
* Add a page to the free list.
*
* @param pageId the page id to add
*/
void free(int pageId) throws SQLException { void free(int pageId) throws SQLException {
store.updateRecord(this); store.updateRecord(this);
if (array.size() < getMaxSize()) { if (array.size() < getMaxSize()) {
......
...@@ -371,6 +371,13 @@ public class PageStore implements CacheWriter { ...@@ -371,6 +371,13 @@ public class PageStore implements CacheWriter {
cache.remove(pageId); cache.remove(pageId);
} }
/**
* Set the root page of the free list.
*
* @param pageId the first free list page
* @param existing if the page already exists
* @param next the next page
*/
void setFreeListRootPage(int pageId, boolean existing, int next) throws SQLException { void setFreeListRootPage(int pageId, boolean existing, int next) throws SQLException {
this.freeListRootPageId = pageId; this.freeListRootPageId = pageId;
if (!existing) { if (!existing) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论