Package org.roaringbitmap.bsi
Class WritableUtils
- java.lang.Object
-
- org.roaringbitmap.bsi.WritableUtils
-
public class WritableUtils extends java.lang.ObjectWritableUtilscopy from org.apache.hadoop.io.WritableUtils
-
-
Constructor Summary
Constructors Constructor Description WritableUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intdecodeVIntSize(byte value)Parse the first byte of a vint/vlong to determine the number of bytesstatic booleanisNegativeVInt(byte value)Given the first byte of a vint/vlong, determine the signstatic intreadVInt(java.io.DataInput stream)Reads a zero-compressed encoded integer from input stream and returns it.static longreadVLong(java.io.DataInput stream)Reads a zero-compressed encoded long from input stream and returns it.static voidwriteVInt(java.io.DataOutput stream, int i)Serializes an integer to a binary stream with zero-compressed encoding.static voidwriteVLong(java.io.DataOutput stream, long i)Serializes a long to a binary stream with zero-compressed encoding.
-
-
-
Method Detail
-
writeVInt
public static void writeVInt(java.io.DataOutput stream, int i) throws java.io.IOExceptionSerializes an integer to a binary stream with zero-compressed encoding. For -120 <= i <= 127, only one byte is used with the actual value. For other values of i, the first byte value indicates whether the integer is positive or negative, and the number of bytes that follow. If the first byte value v is between -121 and -124, the following integer is positive, with number of bytes that follow are -(v+120). If the first byte value v is between -125 and -128, the following integer is negative, with number of bytes that follow are -(v+124). Bytes are stored in the high-non-zero-byte-first order.- Parameters:
stream- Binary output streami- Integer to be serialized- Throws:
java.io.IOException
-
writeVLong
public static void writeVLong(java.io.DataOutput stream, long i) throws java.io.IOExceptionSerializes a long to a binary stream with zero-compressed encoding. For -112 <= i <= 127, only one byte is used with the actual value. For other values of i, the first byte value indicates whether the long is positive or negative, and the number of bytes that follow. If the first byte value v is between -113 and -120, the following long is positive, with number of bytes that follow are -(v+112). If the first byte value v is between -121 and -128, the following long is negative, with number of bytes that follow are -(v+120). Bytes are stored in the high-non-zero-byte-first order.- Parameters:
stream- Binary output streami- Long to be serialized- Throws:
java.io.IOException
-
readVLong
public static long readVLong(java.io.DataInput stream) throws java.io.IOExceptionReads a zero-compressed encoded long from input stream and returns it.- Parameters:
stream- Binary input stream- Returns:
- deserialized long from stream.
- Throws:
java.io.IOException
-
readVInt
public static int readVInt(java.io.DataInput stream) throws java.io.IOExceptionReads a zero-compressed encoded integer from input stream and returns it.- Parameters:
stream- Binary input stream- Returns:
- deserialized integer from stream.
- Throws:
java.io.IOException
-
isNegativeVInt
public static boolean isNegativeVInt(byte value)
Given the first byte of a vint/vlong, determine the sign- Parameters:
value- the first byte- Returns:
- is the value negative
-
decodeVIntSize
public static int decodeVIntSize(byte value)
Parse the first byte of a vint/vlong to determine the number of bytes- Parameters:
value- the first byte of the vint/vlong- Returns:
- the total number of bytes (1 to 9)
-
-