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

New experimental page store.

上级 aa3c5565
...@@ -18,7 +18,7 @@ Change Log ...@@ -18,7 +18,7 @@ Change Log
<h1>Change Log</h1> <h1>Change Log</h1>
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul><li>H2 Console: column of tables of non-default schemas are now also listed, <ul><li>H2 Console: column of tables of non-default schemas are now also listed,
except for schemas starting with 'INFO'. except for schemas starting with 'INFO'.
</li><li>ALTER TABLE: removing an auto-increment or identity column didn't remove the sequence. </li><li>ALTER TABLE: removing an auto-increment or identity column didn't remove the sequence.
</li><li>Creating indexes is now a bit faster. </li><li>Creating indexes is now a bit faster.
......
...@@ -159,16 +159,16 @@ class PageDataLeaf extends PageData { ...@@ -159,16 +159,16 @@ class PageDataLeaf extends PageData {
rows[0] = null; rows[0] = null;
do { do {
int type, size, next; int type, size, next;
if (remaining <= pageSize - PageDataLeafOverflow.START_LAST) { if (remaining <= pageSize - PageDataOverflow.START_LAST) {
type = Page.TYPE_DATA_OVERFLOW | Page.FLAG_LAST; type = Page.TYPE_DATA_OVERFLOW | Page.FLAG_LAST;
size = remaining; size = remaining;
next = 0; next = 0;
} else { } else {
type = Page.TYPE_DATA_OVERFLOW; type = Page.TYPE_DATA_OVERFLOW;
size = pageSize - PageDataLeafOverflow.START_MORE; size = pageSize - PageDataOverflow.START_MORE;
next = index.getPageStore().allocatePage(); next = index.getPageStore().allocatePage();
} }
PageDataLeafOverflow overflow = new PageDataLeafOverflow(this, page, type, previous, next, data, dataOffset, size); PageDataOverflow overflow = new PageDataOverflow(this, page, type, previous, next, data, dataOffset, size);
index.getPageStore().updateRecord(overflow, true, null); index.getPageStore().updateRecord(overflow, true, null);
dataOffset += size; dataOffset += size;
remaining -= size; remaining -= size;
...@@ -232,7 +232,7 @@ class PageDataLeaf extends PageData { ...@@ -232,7 +232,7 @@ class PageDataLeaf extends PageData {
int next = firstOverflowPageId; int next = firstOverflowPageId;
int offset = pageSize; int offset = pageSize;
do { do {
PageDataLeafOverflow page = index.getPageOverflow(next, this, offset); PageDataOverflow page = index.getPageOverflow(next, this, offset);
next = page.readInto(data); next = page.readInto(data);
} while (next != 0); } while (next != 0);
overflowRowSize = data.length(); overflowRowSize = data.length();
...@@ -287,7 +287,7 @@ class PageDataLeaf extends PageData { ...@@ -287,7 +287,7 @@ class PageDataLeaf extends PageData {
if (firstOverflowPageId == 0) { if (firstOverflowPageId == 0) {
return; return;
} }
PageDataLeafOverflow overflow = index.getPageOverflow(firstOverflowPageId, this, 0); PageDataOverflow overflow = index.getPageOverflow(firstOverflowPageId, this, 0);
overflow.setParent(getPos()); overflow.setParent(getPos());
index.getPageStore().updateRecord(overflow, true, null); index.getPageStore().updateRecord(overflow, true, null);
} }
...@@ -310,7 +310,7 @@ class PageDataLeaf extends PageData { ...@@ -310,7 +310,7 @@ class PageDataLeaf extends PageData {
PageStore store = index.getPageStore(); PageStore store = index.getPageStore();
int next = firstOverflowPageId; int next = firstOverflowPageId;
do { do {
PageDataLeafOverflow page = index.getPageOverflow(next, this, 0); PageDataOverflow page = index.getPageOverflow(next, this, 0);
store.freePage(next, false, null); store.freePage(next, false, null);
next = page.getNextOverflow(); next = page.getNextOverflow();
} while (next != 0); } while (next != 0);
......
...@@ -23,7 +23,7 @@ import org.h2.store.Record; ...@@ -23,7 +23,7 @@ import org.h2.store.Record;
* </li><li>data * </li><li>data
* </li></ul> * </li></ul>
*/ */
public class PageDataLeafOverflow extends Record { public class PageDataOverflow extends Record {
/** /**
* The start of the data in the last overflow page. * The start of the data in the last overflow page.
...@@ -62,7 +62,7 @@ public class PageDataLeafOverflow extends Record { ...@@ -62,7 +62,7 @@ public class PageDataLeafOverflow extends Record {
private Data data; private Data data;
PageDataLeafOverflow(PageDataLeaf leaf, int pageId, int type, int previous, int next, Data allData, int offset, int size) { PageDataOverflow(PageDataLeaf leaf, int pageId, int type, int previous, int next, Data allData, int offset, int size) {
this.index = leaf.index; this.index = leaf.index;
setPos(pageId); setPos(pageId);
this.type = type; this.type = type;
...@@ -85,10 +85,10 @@ public class PageDataLeafOverflow extends Record { ...@@ -85,10 +85,10 @@ public class PageDataLeafOverflow extends Record {
* *
* @param leaf the leaf page * @param leaf the leaf page
* @param pageId the page id * @param pageId the page id
* @param dataAll the data page with the complete value * @param data the data page
* @param offset the offset * @param offset the offset
*/ */
public PageDataLeafOverflow(PageDataLeaf leaf, int pageId, Data data, int offset) { PageDataOverflow(PageDataLeaf leaf, int pageId, Data data, int offset) {
this.index = leaf.index; this.index = leaf.index;
setPos(pageId); setPos(pageId);
this.data = data; this.data = data;
......
...@@ -158,14 +158,14 @@ public class PageScanIndex extends BaseIndex implements RowIndex { ...@@ -158,14 +158,14 @@ public class PageScanIndex extends BaseIndex implements RowIndex {
* @param offset the offset in bytes * @param offset the offset in bytes
* @return the page * @return the page
*/ */
PageDataLeafOverflow getPageOverflow(int id, PageDataLeaf leaf, int offset) throws SQLException { PageDataOverflow getPageOverflow(int id, PageDataLeaf leaf, int offset) throws SQLException {
Record rec = store.getRecord(id); Record rec = store.getRecord(id);
if (rec != null) { if (rec != null) {
return (PageDataLeafOverflow) rec; return (PageDataOverflow) rec;
} }
Data data = store.readPage(id); Data data = store.readPage(id);
data.reset(); data.reset();
PageDataLeafOverflow result = new PageDataLeafOverflow(leaf, id, data, offset); PageDataOverflow result = new PageDataOverflow(leaf, id, data, offset);
result.read(); result.read();
return result; return result;
} }
......
...@@ -1439,7 +1439,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -1439,7 +1439,7 @@ public class JdbcConnection extends TraceObject implements Connection {
int id = getNextId(TraceObject.CLOB); int id = getNextId(TraceObject.CLOB);
debugCodeAssign("NClob", TraceObject.CLOB, id, "createNClob()"); debugCodeAssign("NClob", TraceObject.CLOB, id, "createNClob()");
checkClosedForWrite(); checkClosedForWrite();
ValueLob v = ValueLob.createSmallLob(Value.CLOB, ByteUtils.EMPTY); ValueLob v = ValueLob.createSmallLob(Value.CLOB, MemoryUtils.EMPTY_BYTES);
return new JdbcClob(this, v, id); return new JdbcClob(this, v, id);
} catch (Exception e) { } catch (Exception e) {
throw logAndConvert(e); throw logAndConvert(e);
......
...@@ -666,8 +666,8 @@ public class PageLog { ...@@ -666,8 +666,8 @@ public class PageLog {
d.write(null); d.write(null);
} }
/** /**
* Called after the recvovery has been completed. * Called after the recovery has been completed.
*/ */
void recoverEnd() { void recoverEnd() {
sessionStates = New.hashMap(); sessionStates = New.hashMap();
......
...@@ -1019,7 +1019,7 @@ public class PageStore implements CacheWriter { ...@@ -1019,7 +1019,7 @@ public class PageStore implements CacheWriter {
/** /**
* Create an array of SearchRow with the given size. * Create an array of SearchRow with the given size.
* *
* @param len the number of bytes requested * @param entryCount the number of elements
* @return the array * @return the array
*/ */
public static SearchRow[] newSearchRows(int entryCount) { public static SearchRow[] newSearchRows(int entryCount) {
......
...@@ -1071,7 +1071,11 @@ public abstract class TestBase { ...@@ -1071,7 +1071,11 @@ public abstract class TestBase {
return "-Dh2.pageStore=" + System.getProperty("h2.pageStore"); return "-Dh2.pageStore=" + System.getProperty("h2.pageStore");
} }
/**
* Use up almost all memory.
*
* @param remainingKB the number of kilobytes that are not referenced
*/
protected void eatMemory(int remainingKB) { protected void eatMemory(int remainingKB) {
byte[] reserve = new byte[remainingKB * 1024]; byte[] reserve = new byte[remainingKB * 1024];
int max = 128 * 1024 * 1024; int max = 128 * 1024 * 1024;
...@@ -1106,6 +1110,9 @@ public abstract class TestBase { ...@@ -1106,6 +1110,9 @@ public abstract class TestBase {
reserve = null; reserve = null;
} }
/**
* Remove the hard reference to the memory.
*/
protected void freeMemory() { protected void freeMemory() {
memory.clear(); memory.clear();
} }
......
...@@ -103,6 +103,9 @@ public class TestMemoryUsage extends TestBase { ...@@ -103,6 +103,9 @@ public class TestMemoryUsage extends TestBase {
} }
} }
/**
* Eat memory so that all soft references are garbage collected.
*/
void freeSoftReferences() { void freeSoftReferences() {
try { try {
eatMemory(1); eatMemory(1);
......
...@@ -594,4 +594,4 @@ ops jopr googlegroups fletcher prefer djava expires fffe polish articles ...@@ -594,4 +594,4 @@ ops jopr googlegroups fletcher prefer djava expires fffe polish articles
attachment transiently cleanup dbsnmp olapsys wmsys tsmsys outln ctxsys mddata attachment transiently cleanup dbsnmp olapsys wmsys tsmsys outln ctxsys mddata
ordsys ordplugins mgmt dmsys exfsys mdsys sysman informtn textarray tmzone cdo ordsys ordplugins mgmt dmsys exfsys mdsys sysman informtn textarray tmzone cdo
emf decompile streamed setmaxlengthinplacelob setcompresslob compressing emf decompile streamed setmaxlengthinplacelob setcompresslob compressing
compressible subclass compressible subclass ints seeks kilobytes
\ No newline at end of file \ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论