Package org.apache.druid.segment.data
Class VByte
- java.lang.Object
-
- org.apache.druid.segment.data.VByte
-
public class VByte extends Object
-
-
Constructor Summary
Constructors Constructor Description VByte()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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.
-
-
-
Method Detail
-
readInt
public static int readInt(ByteBuffer buffer)
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
public static int writeInt(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. 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.
-
-