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
2 changes: 1 addition & 1 deletion java/memory/src/main/java/io/netty/buffer/ArrowBuf.java
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ public String toString(int index, int length, Charset charset) {
return "";
}

return ByteBufUtil.decodeString(nioBuffer(index, length), charset);
return ByteBufUtil.decodeString(this, index, length, charset);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public boolean matches(String name, Metric metric) {
}

private UnsafeDirectLittleEndian newDirectBufferL(int initialCapacity, int maxCapacity) {
PoolThreadCache cache = threadCache.get();
PoolThreadCache cache = threadCache();
PoolArena<ByteBuffer> directArena = cache.directArena;

if (directArena != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

import io.netty.util.internal.PlatformDependent;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteOrder;
import java.util.concurrent.atomic.AtomicLong;

Expand Down Expand Up @@ -93,11 +96,6 @@ public ByteBuf slice(int index, int length) {
return new SlicedByteBuf(this, index, length);
}

@Override
public ByteOrder order() {
return ByteOrder.LITTLE_ENDIAN;
}

@Override
public ByteBuf order(ByteOrder endianness) {
return this;
Expand Down Expand Up @@ -254,6 +252,28 @@ public boolean release(int decrement) {
return released;
}

@Override
public int setBytes(int index, InputStream in, int length) throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

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

why overriding the implementation? is it because some change in netty's behaviour which cause ArrowBuf to fail?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, Netty now relies on ByteBufAllocator.heapBuffer() to allocate byte arrays on heap, most likely to cache and reuse them if possible.

wrapped.checkIndex(index, length);
byte[] tmp = new byte[length];
int readBytes = in.read(tmp);
if (readBytes > 0) {
PlatformDependent.copyMemory(tmp, 0, addr(index), readBytes);
}
return readBytes;
}

@Override
public ByteBuf getBytes(int index, OutputStream out, int length) throws IOException {
wrapped.checkIndex(index, length);
if (length != 0) {
byte[] tmp = new byte[length];
PlatformDependent.copyMemory(addr(index), tmp, 0, length);
out.write(tmp);
}
return this;
}

@Override
public int hashCode() {
return System.identityHashCode(this);
Expand Down
2 changes: 1 addition & 1 deletion java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<version>4.0.27.Final</version>
<version>4.0.41.Final</version>
</dependency>

<dependency>
Expand Down