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

New experimental page store.

上级 0c909fff
...@@ -221,4 +221,13 @@ abstract class PageBtree extends Record { ...@@ -221,4 +221,13 @@ abstract class PageBtree extends Record {
} }
} }
/**
* Get the estimated memory size.
*
* @return number of double words (4 bytes)
*/
public int getMemorySize() {
return index.getPageStore().getPageSize() >> 2;
}
} }
...@@ -188,4 +188,13 @@ abstract class PageData extends Record { ...@@ -188,4 +188,13 @@ abstract class PageData extends Record {
*/ */
abstract Row getRow(int key) throws SQLException; abstract Row getRow(int key) throws SQLException;
/**
* Get the estimated memory size.
*
* @return number of double words (4 bytes)
*/
public int getMemorySize() {
return index.getPageStore().getPageSize() >> 2;
}
} }
...@@ -132,4 +132,13 @@ public class PageDataLeafOverflow extends Record { ...@@ -132,4 +132,13 @@ public class PageDataLeafOverflow extends Record {
return "page[" + getPos() + "] data leaf overflow prev:" + previous + " next:" + next; return "page[" + getPos() + "] data leaf overflow prev:" + previous + " next:" + next;
} }
/**
* Get the estimated memory size.
*
* @return number of double words (4 bytes)
*/
public int getMemorySize() {
return leaf.getMemorySize();
}
} }
...@@ -8,7 +8,6 @@ package org.h2.index; ...@@ -8,7 +8,6 @@ package org.h2.index;
import java.sql.SQLException; import java.sql.SQLException;
import org.h2.engine.Session;
import org.h2.message.Message; import org.h2.message.Message;
import org.h2.result.Row; import org.h2.result.Row;
import org.h2.store.DataPage; import org.h2.store.DataPage;
......
...@@ -34,7 +34,7 @@ public class PageFreeList extends Record { ...@@ -34,7 +34,7 @@ public class PageFreeList extends Record {
setPos(pageId); setPos(pageId);
this.store = store; this.store = store;
pageCount = (store.getPageSize() - DATA_START) * 8; pageCount = (store.getPageSize() - DATA_START) * 8;
used.set(pageId); used.set(0);
} }
/** /**
...@@ -46,8 +46,9 @@ public class PageFreeList extends Record { ...@@ -46,8 +46,9 @@ public class PageFreeList extends Record {
if (full) { if (full) {
return -1; return -1;
} }
// TODO cache last result
int free = used.nextClearBit(0); int free = used.nextClearBit(0);
if (free > pageCount) { if (free >= pageCount) {
full = true; full = true;
return -1; return -1;
} }
...@@ -132,4 +133,13 @@ public class PageFreeList extends Record { ...@@ -132,4 +133,13 @@ public class PageFreeList extends Record {
return (pageSize - DATA_START) * 8; return (pageSize - DATA_START) * 8;
} }
/**
* Get the estimated memory size.
*
* @return number of double words (4 bytes)
*/
public int getMemorySize() {
return store.getPageSize() >> 2;
}
} }
...@@ -35,21 +35,6 @@ import org.h2.value.Value; ...@@ -35,21 +35,6 @@ import org.h2.value.Value;
*/ */
public class PageLog { public class PageLog {
/**
* The recovery stage to undo changes (re-apply the backup).
*/
static final int RECOVERY_STAGE_UNDO = 0;
/**
* The recovery stage to allocate pages used by the transaction log.
*/
static final int RECOVERY_STAGE_ALLOCATE = 1;
/**
* The recovery stage to redo operations.
*/
static final int RECOVERY_STAGE_REDO = 2;
/** /**
* No operation. * No operation.
*/ */
...@@ -85,6 +70,21 @@ public class PageLog { ...@@ -85,6 +70,21 @@ public class PageLog {
*/ */
public static final int CHECKPOINT = 5; public static final int CHECKPOINT = 5;
/**
* The recovery stage to undo changes (re-apply the backup).
*/
static final int RECOVERY_STAGE_UNDO = 0;
/**
* The recovery stage to allocate pages used by the transaction log.
*/
static final int RECOVERY_STAGE_ALLOCATE = 1;
/**
* The recovery stage to redo operations.
*/
static final int RECOVERY_STAGE_REDO = 2;
private final PageStore store; private final PageStore store;
private int pos; private int pos;
private Trace trace; private Trace trace;
......
...@@ -66,6 +66,8 @@ import org.h2.value.ValueString; ...@@ -66,6 +66,8 @@ import org.h2.value.ValueString;
*/ */
public class PageStore implements CacheWriter { public class PageStore implements CacheWriter {
// TODO auto checkpoint
// TODO check memory usage
// TODO TestPowerOff // TODO TestPowerOff
// TODO PageStore.openMetaIndex (desc and nulls first / last) // TODO PageStore.openMetaIndex (desc and nulls first / last)
// TODO PageBtreeIndex.canGetFirstOrLast // TODO PageBtreeIndex.canGetFirstOrLast
...@@ -106,6 +108,10 @@ public class PageStore implements CacheWriter { ...@@ -106,6 +108,10 @@ public class PageStore implements CacheWriter {
// TODO SessionState.logId is no longer needed // TODO SessionState.logId is no longer needed
// TODO PageData and PageBtree addRowTry: try to simplify // TODO PageData and PageBtree addRowTry: try to simplify
// TODO when removing DiskFile:
// remove CacheObject.blockCount
// remove Record.getMemorySize
/** /**
* The smallest possible page size. * The smallest possible page size.
*/ */
......
...@@ -122,4 +122,13 @@ public class PageStreamData extends Record { ...@@ -122,4 +122,13 @@ public class PageStreamData extends Record {
return remaining; return remaining;
} }
/**
* Get the estimated memory size.
*
* @return number of double words (4 bytes)
*/
public int getMemorySize() {
return store.getPageSize() >> 2;
}
} }
\ No newline at end of file
...@@ -138,4 +138,13 @@ public class PageStreamTrunk extends Record { ...@@ -138,4 +138,13 @@ public class PageStreamTrunk extends Record {
store.writePage(getPos(), empty); store.writePage(getPos(), empty);
} }
/**
* Get the estimated memory size.
*
* @return number of double words (4 bytes)
*/
public int getMemorySize() {
return store.getPageSize() >> 2;
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论