Viraj Jasani created PHOENIX-7617: ------------------------------------- Summary: BSON serialization should retain ByteBuffer offset Key: PHOENIX-7617 URL: https://issues.apache.org/jira/browse/PHOENIX-7617 Project: Phoenix Issue Type: Bug Reporter: Viraj Jasani
The serialization of Phoenix BSON data type requires retrieval of bytes from BsonDocument ByteBuffer. BSON data type uses HBase provided Bytes utility to get the bytes from ByteBuffer. However, HBase Bytes resets the offset position to 0 before copying the bytes: {code:java} /** * Returns a new byte array, copied from the given {@code buf}, from the index 0 (inclusive) to * the limit (exclusive), regardless of the current position. The position and the other index * parameters are not changed. * @param buf a byte buffer * @return the byte array * @see #getBytes(ByteBuffer) */ public static byte[] toBytes(ByteBuffer buf) { ByteBuffer dup = buf.duplicate(); dup.position(0); return readBytes(dup); } {code} Therefore, BSON data type needs to have its own utility to address retaining offset while serializing the bytes. -- This message was sent by Atlassian Jira (v8.20.10#820010)