Skip to content

Commit

Permalink
Simplify calcs
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmudd committed Sep 16, 2024
1 parent 6ff9452 commit 15aa700
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Chunk> chunks;

Expand Down Expand Up @@ -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());

Expand Down Expand Up @@ -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++) {
Expand Down

0 comments on commit 15aa700

Please sign in to comment.