diff --git a/engine/runtime-language-arrow/src/main/java/org/enso/interpreter/arrow/runtime/ByteBufferDirect.java b/engine/runtime-language-arrow/src/main/java/org/enso/interpreter/arrow/runtime/ByteBufferDirect.java index a5462418b8473..faa667835bd22 100644 --- a/engine/runtime-language-arrow/src/main/java/org/enso/interpreter/arrow/runtime/ByteBufferDirect.java +++ b/engine/runtime-language-arrow/src/main/java/org/enso/interpreter/arrow/runtime/ByteBufferDirect.java @@ -184,7 +184,7 @@ 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; } @@ -192,7 +192,7 @@ public boolean isNull(int index) { 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)); } @@ -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();