You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ra...@apache.org on 2019/05/29 13:21:16 UTC
[arrow] branch master updated: ARROW-5434: [Memory][Java] Introduce
wrappers for backward compatibility.
This is an automated email from the ASF dual-hosted git repository.
ravindra pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new a833444 ARROW-5434: [Memory][Java] Introduce wrappers for backward compatibility.
a833444 is described below
commit a833444ae0cba2e507d79a39ad563e4f4572e1f7
Author: Praveen <pr...@dremio.com>
AuthorDate: Wed May 29 18:50:50 2019 +0530
ARROW-5434: [Memory][Java] Introduce wrappers for backward compatibility.
- Introduce some wrapper methods to reduce amount of client changes.
- Changes were introduced as part of patch to support arrow buffers on random memory.
Author: Praveen <pr...@dremio.com>
Closes #4406 from praveenbingo/ARROW-3191-1 and squashes the following commits:
389c1075 <Praveen> Fix review comments and ci.
fdab3dd7 <Praveen> ARROW-3191: Introduce wrappers to keep backward compatibility.
---
.../src/main/java/io/netty/buffer/ArrowBuf.java | 49 +++++++++++++++++++++-
.../main/java/io/netty/buffer/NettyArrowBuf.java | 8 +++-
2 files changed, 54 insertions(+), 3 deletions(-)
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 2a1746f..c3b34b6 100644
--- a/java/memory/src/main/java/io/netty/buffer/ArrowBuf.java
+++ b/java/memory/src/main/java/io/netty/buffer/ArrowBuf.java
@@ -77,7 +77,7 @@ public final class ArrowBuf implements AutoCloseable {
private int readerIndex;
private int writerIndex;
private final HistoricalLog historicalLog = BaseAllocator.DEBUG ?
- new HistoricalLog(BaseAllocator.DEBUG_LOG_LENGTH, "ArrowBuf[%d]", id) : null;
+ new HistoricalLog(BaseAllocator.DEBUG_LOG_LENGTH, "ArrowBuf[%d]", id) : null;
private volatile int length;
/**
@@ -1204,4 +1204,51 @@ public final class ArrowBuf implements AutoCloseable {
"Realloc is only available in the context of operator's UDFs");
}
}
+
+ /**
+ * Following are wrapper methods to keep this backward compatible.
+ */
+ @Deprecated
+ public void release() {
+ referenceManager.release();
+ }
+
+ @Deprecated
+ public void release(int decrement) {
+ referenceManager.release(decrement);
+ }
+
+ @Deprecated
+ public void retain() {
+ referenceManager.retain();
+ }
+
+ @Deprecated
+ public void retain(int increment) {
+ referenceManager.retain(increment);
+ }
+
+ @Deprecated
+ public ArrowBuf clear() {
+ this.readerIndex = this.writerIndex = 0;
+ return this;
+ }
+
+ /**
+ * Initialize the reader and writer index.
+ * @param readerIndex index to read from
+ * @param writerIndex index to write to
+ * @return this
+ */
+ @Deprecated
+ public ArrowBuf setIndex(int readerIndex, int writerIndex) {
+ if (readerIndex >= 0 && readerIndex <= writerIndex && writerIndex <= this.capacity()) {
+ this.readerIndex = readerIndex;
+ this.writerIndex = writerIndex;
+ return this;
+ } else {
+ throw new IndexOutOfBoundsException(String.format("readerIndex: %d, writerIndex: %d " +
+ "(expected:0 <= readerIndex <= writerIndex <= capacity(%d))", readerIndex, writerIndex, this.capacity()));
+ }
+ }
}
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 766b2b1..3c6bd5e 100644
--- a/java/memory/src/main/java/io/netty/buffer/NettyArrowBuf.java
+++ b/java/memory/src/main/java/io/netty/buffer/NettyArrowBuf.java
@@ -76,6 +76,10 @@ public class NettyArrowBuf extends AbstractByteBuf implements AutoCloseable {
return this;
}
+ public ArrowBuf arrowBuf() {
+ return arrowBuf;
+ }
+
@Override
public ByteBuf retain(final int increment) {
arrowBuf.getReferenceManager().retain(increment);
@@ -351,12 +355,12 @@ public class NettyArrowBuf extends AbstractByteBuf implements AutoCloseable {
@Override
public int setBytes(int index, ScatteringByteChannel in, int length) throws IOException {
- throw new UnsupportedOperationException("Operation not supported");
+ return (int) in.read(nioBuffers(index, length));
}
@Override
public int setBytes(int index, FileChannel in, long position, int length) throws IOException {
- throw new UnsupportedOperationException("Operation not supported");
+ return (int) in.read(nioBuffers(index, length));
}
@Override