Tim McCune - Original author and project founder
Rob DiMarco - Added ability to import delimited text into new tables
Mitchell J. Friedman - Added support for additional JDBC data types
+James Ahlborn - Added support for NUMERIC data type
+Jon Iles - Added support for reading table definitions that span multiple pages
import java.io.IOException;
import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
_format = format;
_tableDefPageNumber = pageNumber;
int nextPage;
- do {
- readPage();
- nextPage = _buffer.getInt(_format.OFFSET_NEXT_TABLE_DEF_PAGE);
- } while (nextPage > 0);
+ ByteBuffer nextPageBuffer = null;
+ nextPage = _buffer.getInt(_format.OFFSET_NEXT_TABLE_DEF_PAGE);
+ while (nextPage != 0) {
+ if (nextPageBuffer == null) {
+ nextPageBuffer = ByteBuffer.allocate(format.PAGE_SIZE);
+ nextPageBuffer.order(ByteOrder.LITTLE_ENDIAN);
+ }
+ _pageChannel.readPage(nextPageBuffer, nextPage);
+ nextPage = nextPageBuffer.getInt(_format.OFFSET_NEXT_TABLE_DEF_PAGE);
+ ByteBuffer newBuffer = ByteBuffer.allocate(_buffer.capacity() + format.PAGE_SIZE - 8);
+ newBuffer.order(ByteOrder.LITTLE_ENDIAN);
+ newBuffer.put(_buffer);
+ newBuffer.put(nextPageBuffer.array(), 8, format.PAGE_SIZE - 8);
+ _buffer = newBuffer;
+ }
+ readPage();
}
/**