diff --git a/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/BaseEvaluatorTest.java b/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/BaseEvaluatorTest.java index 2fd5a246329d4..2f44855ead66e 100644 --- a/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/BaseEvaluatorTest.java +++ b/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/BaseEvaluatorTest.java @@ -278,7 +278,7 @@ void releaseRecordBatch(ArrowRecordBatch recordBatch) { List buffers = recordBatch.getBuffers(); recordBatch.close(); for (ArrowBuf buf : buffers) { - buf.release(); + buf.getReferenceManager().release(); } } diff --git a/java/memory/src/main/java/io/netty/buffer/ArrowBuf.java b/java/memory/src/main/java/io/netty/buffer/ArrowBuf.java index 02f780a77f774..36890bbdf540d 100644 --- a/java/memory/src/main/java/io/netty/buffer/ArrowBuf.java +++ b/java/memory/src/main/java/io/netty/buffer/ArrowBuf.java @@ -136,11 +136,15 @@ private void ensureAccessible() { * @return netty compliant {@link NettyArrowBuf} */ public NettyArrowBuf asNettyBuffer() { - return new NettyArrowBuf((UnsafeDirectLittleEndian)referenceManager.getUnderlying(), - this, - referenceManager.getByteBufAllocator(), - referenceManager.getOffsetForBuffer(this), - length); + final NettyArrowBuf nettyArrowBuf = new NettyArrowBuf( + (UnsafeDirectLittleEndian)referenceManager.getUnderlying(), + this, + referenceManager.getByteBufAllocator(), + referenceManager.getOffsetForBuffer(this), + length); + nettyArrowBuf.readerIndex(readerIndex); + nettyArrowBuf.writerIndex(writerIndex); + return nettyArrowBuf; } /** diff --git a/java/memory/src/main/java/io/netty/buffer/NettyArrowBuf.java b/java/memory/src/main/java/io/netty/buffer/NettyArrowBuf.java index 01a5641ccfc24..8fc3f48747b84 100644 --- a/java/memory/src/main/java/io/netty/buffer/NettyArrowBuf.java +++ b/java/memory/src/main/java/io/netty/buffer/NettyArrowBuf.java @@ -174,6 +174,16 @@ public int capacity() { return arrowBuf.capacity(); } + @Override + public NettyArrowBuf slice() { + return arrowBuf.slice().asNettyBuffer(); + } + + @Override + public NettyArrowBuf slice(int index, int length) { + return arrowBuf.slice(index, length).asNettyBuffer(); + } + @Override public void close() { arrowBuf.close(); @@ -200,13 +210,17 @@ public int writerIndex() { } @Override - public int readableBytes() { - return arrowBuf.readableBytes(); + public NettyArrowBuf readerIndex(int readerIndex) { + super.readerIndex(readerIndex); + //arrowBuf.readerIndex(readerIndex); + return this; } @Override - public int writableBytes() { - return arrowBuf.writableBytes(); + public NettyArrowBuf writerIndex(int writerIndex) { + super.writerIndex(writerIndex); + //arrowBuf.writerIndex(writerIndex); + return this; } @Override