long[] writeTableToDataFile(Table table) throws IOException {
Session session = database.getSessionManager().getSysSession();
PersistentStore store = table.getRowStore(session);
RowOutputInterface rowOut = dataCache.rowOut.duplicate();
long[] rootsArray = table.getIndexRootsArray();
long pos = fileOffset;
long count = 0;
pointerLookup.removeAll();
pointerLookup.setKeysSearchTarget();
database.logger.logDetailEvent("lookup begins " + table.getName().name
+ " " + stopw.elapsedTime());
// all rows
RowIterator it = table.rowIteratorClustered(store);
for (; it.hasNext(); count++) {
CachedObject row = it.getNextRow();
pointerLookup.addUnsorted((int) row.getPos(), (int) (pos / scale));
if (count != 0 && count % 100000 == 0) {
database.logger.logDetailEvent("pointer pair for row " + count
+ " " + row.getPos() + " "
+ pos);
}
pos += row.getStorageSize();
}
database.logger.logDetailEvent("table read " + table.getName().name
+ " " + stopw.elapsedTime());
count = 0;
it = table.rowIteratorClustered(store);
for (; it.hasNext(); count++) {
CachedObject row = it.getNextRow();
rowOut.reset();
row.write(rowOut, pointerLookup);
randomAccessOut.write(rowOut.getOutputStream().getBuffer(), 0,
rowOut.size());
fileOffset += row.getStorageSize();
if (count != 0 && count % 100000 == 0) {
database.logger.logDetailEvent("rows count " + count + " "