Skip to content

Commit

Permalink
Fix byte mask used for index calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
hubertp committed Jun 3, 2024
1 parent f9a802e commit a157891
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ public int capacity() throws UnsupportedMessageException {
public boolean isNull(int index) {
var bufferIndex = index >> 3;
var slot = bitmapBuffer.get(bufferIndex);
var byteIndex = index & ~(1 << 3);
var byteIndex = index & byteMask;
var mask = 1 << byteIndex;
return (slot & mask) == 0;
}

public void setNull(int index) {
var bufferIndex = index >> 3;
var slot = bitmapBuffer.get(bufferIndex);
var byteIndex = index & ~(1 << 3);
var byteIndex = index & byteMask;
var mask = ~(1 << byteIndex);
bitmapBuffer.put(bufferIndex, (byte) (slot & mask));
}
Expand All @@ -201,12 +201,17 @@ private void setValidityBitmap(int index0, int unitSize) {
var index = index0 / unitSize;
var bufferIndex = index >> 3;
var slot = bitmapBuffer.get(bufferIndex);
var byteIndex = index & ~(1 << 3);

var byteIndex = index & byteMask;
var test = index & byteMask;

var mask = 1 << byteIndex;
var updated = (slot | mask);
bitmapBuffer.put(bufferIndex, (byte) (updated));
}

private static final int byteMask = ~(~(1 << 3) + 1); // 7

@Override
public void close() throws Exception {
this.dataBuffer.clear();
Expand Down

0 comments on commit a157891

Please sign in to comment.