From: Tim McCune Date: Fri, 3 Feb 2006 23:55:47 +0000 (+0000) Subject: Applied Jon Iles' patch to allow large table definitions to be read. X-Git-Tag: rel_1_1_3~3 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5d9a02b8df3575a4d3b9522de882f0d6a97af68a;p=jackcess.git Applied Jon Iles' patch to allow large table definitions to be read. git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@32 f203690c-595d-4dc9-a70b-905162fa7fd2 --- diff --git a/CREDITS.txt b/CREDITS.txt index f78ece8..b6c6a68 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -1,3 +1,5 @@ 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 diff --git a/src/java/com/healthmarketscience/jackcess/Table.java b/src/java/com/healthmarketscience/jackcess/Table.java index b0223b6..a9a6944 100644 --- a/src/java/com/healthmarketscience/jackcess/Table.java +++ b/src/java/com/healthmarketscience/jackcess/Table.java @@ -29,6 +29,7 @@ package com.healthmarketscience.jackcess; import java.io.IOException; import java.nio.ByteBuffer; +import java.nio.ByteOrder; import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; @@ -107,10 +108,22 @@ public class Table { _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(); } /**