msgpack-java icon indicating copy to clipboard operation
msgpack-java copied to clipboard

Support unpacking HeapByteBfuferR

Open takaaki7 opened this issue 1 year ago • 0 comments

Currently MessagePack.newDefaultUnpacker(ByteBuffer buffer) doesn't support HeapByteBuffer

When passing Read Only ByteBuffer, following exception happened. Because HeapByteBfuferR.hashArray() and HeapByteBfuferR.isDirect() returns false.

throw new IllegalArgumentException("Only the array-backed ByteBuffer or DirectBuffer is supported");

https://github.com/msgpack/msgpack-java/blob/main/msgpack-core/src/main/java/org/msgpack/core/buffer/MessageBuffer.java#L400

I want to unpacking HeapByteBufferR without copying bytes. Because I save msgpack data in BigTable, and BigTable library returns ByteString, and it only able to be no-copy converted to HeapByteBufferR with asReadOnlyByteBuffer().

takaaki7 avatar Dec 08 '24 08:12 takaaki7