From 15aa70077d7d91b24a500b01bfc35b43cfbd8905 Mon Sep 17 00:00:00 2001 From: James Mudd Date: Mon, 16 Sep 2024 21:39:15 +0100 Subject: [PATCH] Simplify calcs --- .../dataset/chunked/indexing/FixedArrayIndex.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/jhdf/src/main/java/io/jhdf/dataset/chunked/indexing/FixedArrayIndex.java b/jhdf/src/main/java/io/jhdf/dataset/chunked/indexing/FixedArrayIndex.java index b14d28c8..4c4209ca 100644 --- a/jhdf/src/main/java/io/jhdf/dataset/chunked/indexing/FixedArrayIndex.java +++ b/jhdf/src/main/java/io/jhdf/dataset/chunked/indexing/FixedArrayIndex.java @@ -41,7 +41,6 @@ public class FixedArrayIndex implements ChunkIndex { private final int pageBits; private final int maxNumberOfEntries; private final long dataBlockAddress; - private final boolean paged; private final int pages; private final List chunks; @@ -73,9 +72,8 @@ public FixedArrayIndex(HdfBackingStorage hdfBackingStorage, long address, Datase pageBits = bb.get(); maxNumberOfEntries = Utils.readBytesAsUnsignedInt(bb, hdfBackingStorage.getSizeOfLengths()); - final int pageSize = BigInteger.valueOf(2).pow(pageBits).intValue(); - paged = maxNumberOfEntries > pageSize; - pages = (int) Math.ceil((double) maxNumberOfEntries / pageSize); + final int pageSize = 1 << pageBits; + pages = (maxNumberOfEntries + pageSize -1) / pageSize; dataBlockAddress = Utils.readBytesAsUnsignedLong(bb, hdfBackingStorage.getSizeOfOffsets()); @@ -121,15 +119,15 @@ private FixedArrayDataBlock(FixedArrayIndex fixedArrayIndex, HdfBackingStorage h throw new HdfException("Fixed array data block header address missmatch"); } - if(paged) { + if(pages > 1) { // throw new HdfException("Paged"); // pageBits - int pageBitmapBytes = (int) Math.ceil((double) pages / 8); + int pageBitmapBytes = (pages + 7) / 8; +// pageBitmapSize = (pageCount + 7) / 8; // byte[] pageBitmap = new byte[pageBitmapBytes]; // bb.get(pageBitmapBytes); - bb.position(bb.position() + pageBitmapBytes + 1); + bb.position(bb.position() + pageBitmapBytes ); } - // TODO ignoring paging here might need to revisit if (clientId == 0) { // Not filtered for (int i = 0; i < fixedArrayIndex.maxNumberOfEntries; i++) {