try {
btree.beginTrans(SqlJetTransactionMode.WRITE);
for (int x = 1; x <= 3; x++) {
final int table = btree.createTable(SqlJetUtility.of(SqlJetBtreeTableCreateFlags.INTKEY,
SqlJetBtreeTableCreateFlags.LEAFDATA));
final ISqlJetBtreeCursor c = btree.getCursor(table, true, null);
c.enterCursor();
try {
for (int y = 1; y <= 3; y++) {
c.insert(null, y, pData, pData.remaining(), 0, false);
}
c.closeCursor();
} finally {
c.leaveCursor();
}
}
btree.commit();
} finally {
btree.close();
}
data = "Data test";
bytes = SqlJetUtility.getBytes(data);
pData = SqlJetUtility.wrapPtr(bytes);
btree.open(testTempFile, db, btreeFlags, SqlJetFileType.MAIN_DB, fileFlags);
try {
btree.beginTrans(SqlJetTransactionMode.WRITE);
final int pageCount = btree.getPager().getPageCount();
for (int x = 1; x <= pageCount; x++) {
final ISqlJetBtreeCursor c = btree.getCursor(x, true, null);
c.enterCursor();
try {
if (!c.first()) {
c.cacheOverflow();
do {
c.putData(0, pData.remaining(), pData);
} while (!c.next());
}
} finally {
c.leaveCursor();
}
}
btree.commit();
} finally {
btree.close();
}
btree.open(testTempFile, db, btreeFlags, SqlJetFileType.MAIN_DB, fileFlags);
try {
final int pageCount = btree.getPager().getPageCount();
for (int i = 1; i <= pageCount; i++) {
final ISqlJetBtreeCursor c = btree.getCursor(i, false, null);
c.enterCursor();
try {
if (!c.first()) {
logger.info("table " + i);
do {
StringBuilder s = new StringBuilder();
final long key = c.getKeySize();
if (key != 0)
s.append("record ").append(key).append(" : ");
final int dataSize = c.getDataSize();
if (dataSize > 0) {
ISqlJetMemoryPointer b = SqlJetUtility.allocatePtr(dataSize);
c.data(0, dataSize, b);
final String str = SqlJetUtility.toString(b, SqlJetEncoding.UTF8);
s.append("\"").append(str.replaceAll("[^\\p{Print}]", "?")).append("\"");
Assert.assertEquals(data, str);
}
if (s.length() > 0)
logger.info(s.toString());
} while (!c.next());
}
} finally {
c.leaveCursor();
}
}
} finally {
btree.close();
}