diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2008-03-25 01:47:11 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2008-03-25 01:47:11 +0000 |
commit | 5ed67386298122627309687845b6d784a6e9f022 (patch) | |
tree | 1e1a11f1e044f24caa85cce2e51e05b7344ce75d | |
parent | fc589ceff501a6de3a46de3d45cfc29de109e0bd (diff) | |
download | jackcess-5ed67386298122627309687845b6d784a6e9f022.tar.gz jackcess-5ed67386298122627309687845b6d784a6e9f022.zip |
better max size calculation
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@299 f203690c-595d-4dc9-a70b-905162fa7fd2
-rw-r--r-- | src/java/com/healthmarketscience/jackcess/Index.java | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/java/com/healthmarketscience/jackcess/Index.java b/src/java/com/healthmarketscience/jackcess/Index.java index 020f42f..b462b77 100644 --- a/src/java/com/healthmarketscience/jackcess/Index.java +++ b/src/java/com/healthmarketscience/jackcess/Index.java @@ -334,15 +334,16 @@ public class Index implements Comparable<Index> { buffer.put((byte) 0); //Unknown buffer.put((byte) 0); //Unknown byte[] entryMask = new byte[getFormat().SIZE_INDEX_ENTRY_MASK]; + int maxTotalSize = getFormat().PAGE_SIZE - + (getFormat().OFFSET_INDEX_ENTRY_MASK + entryMask.length); int totalSize = 0; for(Entry entry : _entries) { - int size = entry.size(); - totalSize += size; - int idx = totalSize / 8; - if(idx >= entryMask.length) { + totalSize += entry.size(); + if(totalSize > maxTotalSize) { throw new UnsupportedOperationException( "FIXME cannot write large index yet"); } + int idx = totalSize / 8; entryMask[idx] |= (1 << (totalSize % 8)); } buffer.put(entryMask); @@ -499,7 +500,7 @@ public class Index implements Comparable<Index> { indexPage, getFormat().OFFSET_INDEX_COMPRESSED_BYTE_COUNT); int entryMaskLength = getFormat().SIZE_INDEX_ENTRY_MASK; int entryMaskPos = getFormat().OFFSET_INDEX_ENTRY_MASK; - int entryPos = entryMaskPos + getFormat().SIZE_INDEX_ENTRY_MASK; + int entryPos = entryMaskPos + entryMaskLength; int lastStart = 0; byte[] valuePrefix = null; boolean firstEntry = true; |