int[] writeTableToDataFile(Table paramTable)
throws IOException, HsqlException
{
Session localSession = this.database.getSessionManager().getSysSession();
RowOutputBinary localRowOutputBinary = new RowOutputBinary();
DoubleIntIndex localDoubleIntIndex = new DoubleIntIndex(paramTable.getPrimaryIndex().sizeEstimate(), false);
int[] arrayOfInt = paramTable.getIndexRootsArray();
long l = this.fileOffset;
int i = 0;
localDoubleIntIndex.setKeysSearchTarget();
Trace.printSystemOut("lookup begins: " + this.stopw.elapsedTime());
RowIterator localRowIterator = paramTable.rowIterator(localSession);
Row localRow;
while (localRowIterator.hasNext())
{
localRow = localRowIterator.next();
localDoubleIntIndex.addUnsorted(localRow.getPos(), (int)(l / this.scale));
if (i % 50000 == 0)
Trace.printSystemOut("pointer pair for row " + i + " " + localRow.getPos() + " " + l);
l += localRow.getStorageSize();
i++;
}
Trace.printSystemOut(paramTable.getName().name + " list done ", this.stopw.elapsedTime());
i = 0;
localRowIterator = paramTable.rowIterator(localSession);
while (localRowIterator.hasNext())
{
localRow = localRowIterator.next();
localRowOutputBinary.reset();
localRow.write(localRowOutputBinary, localDoubleIntIndex);
this.fileStreamOut.write(localRowOutputBinary.getOutputStream().getBuffer(), 0, localRowOutputBinary.size());
this.fileOffset += localRow.getStorageSize();
if (i % 50000 == 0)
Trace.printSystemOut(i + " rows " + this.stopw.elapsedTime());
i++;
}
for (int j = 0; j < arrayOfInt.length; j++)
{
if (arrayOfInt[j] == -1)
continue;
int k = localDoubleIntIndex.findFirstEqualKeyIndex(arrayOfInt[j]);
if (k == -1)
throw Trace.error(129);
arrayOfInt[j] = localDoubleIntIndex.getValue(k);
}
setTransactionRowLookups(localDoubleIntIndex);
Trace.printSystemOut(paramTable.getName().name + " : table converted");
return arrayOfInt;
}