diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2008-03-18 03:14:04 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2008-03-18 03:14:04 +0000 |
commit | 774f1c4cfeec607a8152f122f4186f4a21228e69 (patch) | |
tree | 25648281cd5e59984cf471a7f4c0c2d30b3e525f /src/java/com/healthmarketscience/jackcess/PageChannel.java | |
parent | 3d7b5f9a2a0e42d0e1a0179233dde8f7fe81c401 (diff) | |
download | jackcess-774f1c4cfeec607a8152f122f4186f4a21228e69.tar.gz jackcess-774f1c4cfeec607a8152f122f4186f4a21228e69.zip |
completely fix problems with sporadic usage map corruption; add some soft buffer caching in various places
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@281 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/java/com/healthmarketscience/jackcess/PageChannel.java')
-rw-r--r-- | src/java/com/healthmarketscience/jackcess/PageChannel.java | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/java/com/healthmarketscience/jackcess/PageChannel.java b/src/java/com/healthmarketscience/jackcess/PageChannel.java index 4aaa08b..b51e869 100644 --- a/src/java/com/healthmarketscience/jackcess/PageChannel.java +++ b/src/java/com/healthmarketscience/jackcess/PageChannel.java @@ -47,6 +47,8 @@ public class PageChannel implements Channel, Flushable { static final int INVALID_PAGE_NUMBER = -1; + static final ByteOrder DEFAULT_BYTE_ORDER = ByteOrder.LITTLE_ENDIAN; + /** dummy buffer used when allocating new pages */ private static final ByteBuffer FORCE_BYTES = ByteBuffer.allocate(1); @@ -107,10 +109,8 @@ public class PageChannel implements Channel, Flushable { /** * @param buffer Buffer to read the page into * @param pageNumber Number of the page to read in (starting at 0) - * @return True if the page was successfully read into the buffer, false if - * that page doesn't exist. */ - public boolean readPage(ByteBuffer buffer, int pageNumber) + public void readPage(ByteBuffer buffer, int pageNumber) throws IOException { if(pageNumber == INVALID_PAGE_NUMBER) { @@ -120,9 +120,14 @@ public class PageChannel implements Channel, Flushable { LOG.debug("Reading in page " + Integer.toHexString(pageNumber)); } buffer.clear(); - boolean rtn = _channel.read(buffer, (long) pageNumber * (long) getFormat().PAGE_SIZE) != -1; + int bytesRead = _channel.read( + buffer, (long) pageNumber * (long) getFormat().PAGE_SIZE); buffer.flip(); - return rtn; + if(bytesRead != getFormat().PAGE_SIZE) { + throw new IOException("Failed attempting to read " + + getFormat().PAGE_SIZE + " bytes from page " + + pageNumber + ", only read " + bytesRead); + } } /** |