Package org.apache.druid.segment.data
Class VByte
java.lang.Object
org.apache.druid.segment.data.VByte
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcomputeIntSize(int val) Compute number of bytes required to represent variable byte encoded integer.static intreadInt(ByteBuffer buffer) Read a variable byte (vbyte) encoded integer from aByteBufferat the current position.static intwriteInt(ByteBuffer buffer, int val) Write a variable byte (vbyte) encoded integer to aByteBufferat the current position, advancing the buffer position by the number of bytes required to represent the integer, between 1 and 5 bytes.
-
Constructor Details
-
VByte
public VByte()
-
-
Method Details
-
readInt
Read a variable byte (vbyte) encoded integer from aByteBufferat the current position. Moves the buffer ahead by 1 to 5 bytes depending on how many bytes was required to encode the integer value. vbyte encoding stores values in the last 7 bits of a byte and reserves the high bit for the 'contination'. If 0, one or more aditional bytes must be read to complete the value, and a 1 indicates the terminal byte. Because of this, it can only store positive values, and larger integers can take up to 5 bytes. implementation based on: https://github.com/lemire/JavaFastPFOR/blob/master/src/main/java/me/lemire/integercompression/VariableByte.java -
writeInt
Write a variable byte (vbyte) encoded integer to aByteBufferat the current position, advancing the buffer position by the number of bytes required to represent the integer, between 1 and 5 bytes. vbyte encoding stores values in the last 7 bits of a byte and reserves the high bit for the 'contination'. If 0, one or more aditional bytes must be read to complete the value, and a 1 indicates the terminal byte. Because of this, it can only store positive values, and larger integers can take up to 5 bytes. implementation based on: https://github.com/lemire/JavaFastPFOR/blob/master/src/main/java/me/lemire/integercompression/VariableByte.java -
computeIntSize
public static int computeIntSize(int val) Compute number of bytes required to represent variable byte encoded integer. vbyte encoding stores values in the last 7 bits of a byte and reserves the high bit for the 'contination'. If 0, one or more aditional bytes must be read to complete the value, and a 1 indicates the terminal byte. Because of this, it can only store positive values, and larger integers can take up to 5 bytes.
-