提交 98860f4b authored 作者: Thomas Mueller's avatar Thomas Mueller

Experimental page store.

上级 4e1eed4e
...@@ -66,6 +66,7 @@ public class Recover extends Tool implements DataHandler { ...@@ -66,6 +66,7 @@ public class Recover extends Tool implements DataHandler {
private int block; private int block;
private int blockCount; private int blockCount;
private int storageId; private int storageId;
private String storageName;
private int recordLength; private int recordLength;
private int valueId; private int valueId;
private boolean trace; private boolean trace;
...@@ -193,7 +194,7 @@ public class Recover extends Tool implements DataHandler { ...@@ -193,7 +194,7 @@ public class Recover extends Tool implements DataHandler {
long start = store.getFilePointer(); long start = store.getFilePointer();
store.readFully(bytes, 0, blockSize); store.readFully(bytes, 0, blockSize);
blockCount = s.readInt(); blockCount = s.readInt();
storageId = -1; setStorage(-1);
recordLength = -1; recordLength = -1;
valueId = -1; valueId = -1;
if (blockCount == 0) { if (blockCount == 0) {
...@@ -219,7 +220,7 @@ public class Recover extends Tool implements DataHandler { ...@@ -219,7 +220,7 @@ public class Recover extends Tool implements DataHandler {
blockCount = 1; blockCount = 1;
continue; continue;
} }
storageId = s.readInt(); setStorage(s.readInt());
if (storageId != 0) { if (storageId != 0) {
continue; continue;
} }
...@@ -633,7 +634,7 @@ public class Recover extends Tool implements DataHandler { ...@@ -633,7 +634,7 @@ public class Recover extends Tool implements DataHandler {
DataPage s = DataPage.create(this, buff); DataPage s = DataPage.create(this, buff);
store.readFully(buff, 0, blockSize); store.readFully(buff, 0, blockSize);
blockCount = s.readInt(); blockCount = s.readInt();
storageId = -1; setStorage(-1);
recordLength = -1; recordLength = -1;
valueId = -1; valueId = -1;
if (blockCount == 0) { if (blockCount == 0) {
...@@ -666,7 +667,7 @@ public class Recover extends Tool implements DataHandler { ...@@ -666,7 +667,7 @@ public class Recover extends Tool implements DataHandler {
blockCount = 1; blockCount = 1;
continue; continue;
} }
storageId = s.readInt(); setStorage(s.readInt());
if (storageId < 0) { if (storageId < 0) {
writeDataError(writer, "storageId<0", s.getBytes(), blockCount); writeDataError(writer, "storageId<0", s.getBytes(), blockCount);
continue; continue;
...@@ -810,7 +811,7 @@ public class Recover extends Tool implements DataHandler { ...@@ -810,7 +811,7 @@ public class Recover extends Tool implements DataHandler {
writer.println("-- undo page " + pageId); writer.println("-- undo page " + pageId);
} else if (x == PageLog.ADD || x == PageLog.REMOVE) { } else if (x == PageLog.ADD || x == PageLog.REMOVE) {
int sessionId = in.readInt(); int sessionId = in.readInt();
storageId = in.readInt(); setStorage(in.readInt());
Row row = PageLog.readRow(in, s); Row row = PageLog.readRow(in, s);
writer.println("-- session " + sessionId + writer.println("-- session " + sessionId +
" table " + storageId + " table " + storageId +
...@@ -823,6 +824,11 @@ public class Recover extends Tool implements DataHandler { ...@@ -823,6 +824,11 @@ public class Recover extends Tool implements DataHandler {
} }
private void setStorage(int storageId) {
this.storageId = storageId;
this.storageName = String.valueOf(storageId).replace('-', 'M');
}
/** /**
* An input stream that reads the data from a page store. * An input stream that reads the data from a page store.
*/ */
...@@ -934,7 +940,7 @@ public class Recover extends Tool implements DataHandler { ...@@ -934,7 +940,7 @@ public class Recover extends Tool implements DataHandler {
} }
private void dumpPageDataLeaf(FileStore store, int pageSize, PrintWriter writer, DataPage s, boolean last, long pageId) throws SQLException { private void dumpPageDataLeaf(FileStore store, int pageSize, PrintWriter writer, DataPage s, boolean last, long pageId) throws SQLException {
storageId = s.readInt(); setStorage(s.readInt());
int entryCount = s.readShortInt(); int entryCount = s.readShortInt();
int[] keys = new int[entryCount]; int[] keys = new int[entryCount];
int[] offsets = new int[entryCount]; int[] offsets = new int[entryCount];
...@@ -1036,7 +1042,7 @@ public class Recover extends Tool implements DataHandler { ...@@ -1036,7 +1042,7 @@ public class Recover extends Tool implements DataHandler {
private void writeRow(PrintWriter writer, DataPage s, Value[] data) { private void writeRow(PrintWriter writer, DataPage s, Value[] data) {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
sb.append("INSERT INTO O_" + storageId + " VALUES("); sb.append("INSERT INTO O_" + storageName + " VALUES(");
for (valueId = 0; valueId < recordLength; valueId++) { for (valueId = 0; valueId < recordLength; valueId++) {
try { try {
Value v = s.readValue(); Value v = s.readValue();
...@@ -1103,7 +1109,7 @@ public class Recover extends Tool implements DataHandler { ...@@ -1103,7 +1109,7 @@ public class Recover extends Tool implements DataHandler {
DataPage s = DataPage.create(this, buff); DataPage s = DataPage.create(this, buff);
store.readFully(buff, 0, blockSize); store.readFully(buff, 0, blockSize);
blockCount = s.readInt(); blockCount = s.readInt();
storageId = -1; setStorage(-1);
recordLength = -1; recordLength = -1;
valueId = -1; valueId = -1;
if (blockCount == 0) { if (blockCount == 0) {
...@@ -1149,7 +1155,7 @@ public class Recover extends Tool implements DataHandler { ...@@ -1149,7 +1155,7 @@ public class Recover extends Tool implements DataHandler {
blockCount = 1; blockCount = 1;
continue; continue;
} }
storageId = s.readInt(); setStorage(s.readInt());
if (storageId < 0) { if (storageId < 0) {
writeDataError(writer, "storageId<0", s.getBytes(), blockCount); writeDataError(writer, "storageId<0", s.getBytes(), blockCount);
continue; continue;
...@@ -1203,7 +1209,7 @@ public class Recover extends Tool implements DataHandler { ...@@ -1203,7 +1209,7 @@ public class Recover extends Tool implements DataHandler {
if (!objectIdSet.contains(ObjectUtils.getInteger(storageId))) { if (!objectIdSet.contains(ObjectUtils.getInteger(storageId))) {
objectIdSet.add(ObjectUtils.getInteger(storageId)); objectIdSet.add(ObjectUtils.getInteger(storageId));
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
sb.append("CREATE TABLE O_" + storageId + "("); sb.append("CREATE TABLE O_" + storageName + "(");
for (int i = 0; i < recordLength; i++) { for (int i = 0; i < recordLength; i++) {
if (i > 0) { if (i > 0) {
sb.append(", "); sb.append(", ");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论