adarshsanjeev commented on code in PR #16708: URL: https://github.com/apache/druid/pull/16708#discussion_r1673397534
########## processing/src/main/java/org/apache/druid/segment/data/VByte.java: ########## @@ -58,6 +60,40 @@ public static int readInt(ByteBuffer buffer) return v; } + public static int writeInt(WritableByteChannel out, int val) throws IOException + { + final byte[] bytes = new byte[5]; + final int numBytes; + if (val < (1 << 7)) { + bytes[0] = (byte) (val | (1 << 7)); + numBytes = 1; + } else if (val < (1 << 14)) { + bytes[0] = extract7bits(0, val); + bytes[1] = (byte) (extract7bitsmaskless(1, (val)) | (1 << 7)); + numBytes = 2; + } else if (val < (1 << 21)) { + bytes[0] = extract7bits(0, val); + bytes[1] = extract7bits(1, val); + bytes[2] = (byte) (extract7bitsmaskless(2, (val)) | (1 << 7)); + numBytes = 3; + } else if (val < (1 << 28)) { + bytes[0] = extract7bits(0, val); + bytes[1] = extract7bits(1, val); + bytes[2] = extract7bits(2, val); + bytes[3] = (byte) (extract7bitsmaskless(3, (val)) | (1 << 7)); + numBytes = 4; + } else { + bytes[0] = extract7bits(0, val); + bytes[1] = extract7bits(1, val); + bytes[2] = extract7bits(2, val); + bytes[3] = extract7bits(3, val); + bytes[4] = (byte) (extract7bitsmaskless(4, (val)) | (1 << 7)); + numBytes = 5; + } + out.write(ByteBuffer.wrap(bytes, 0, numBytes)); Review Comment: Removed this as well, I think the above function would be reusable. Will add it later. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org For additional commands, e-mail: commits-h...@druid.apache.org