Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion java/memory/src/main/java/io/netty/buffer/ArrowBuf.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -1204,4 +1204,51 @@ public ArrowBuf reallocIfNeeded(final int size) {
"Realloc is only available in the context of operator's UDFs");
}
}

/**
* Following are wrapper methods to keep this backward compatible.
*/
@Deprecated
public void release() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we mark these as "@deprecated", so clients know they should moving off of them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Copy link
Contributor

@pravindra pravindra May 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why deprecate ? It's a useful convenience fn, so also retain.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree this should be deprecated - readerIndex and writerIndex should move to NettyArrowBuf

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally we should not have duplicate methods doing the same work, at some point in the future we should remove the older..

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()));
}
}
}
8 changes: 6 additions & 2 deletions java/memory/src/main/java/io/netty/buffer/NettyArrowBuf.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ public ByteBuf retain() {
return this;
}

public ArrowBuf arrowBuf() {
return arrowBuf;
}

@Override
public ByteBuf retain(final int increment) {
arrowBuf.getReferenceManager().retain(increment);
Expand Down Expand Up @@ -351,12 +355,12 @@ public int getBytes(int index, FileChannel out, long position, int length) throw

@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
Expand Down