Package org.yamcs.utils
Class VarIntUtil
java.lang.Object
org.yamcs.utils.VarIntUtil
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
decodes an array of varintsstatic class
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int[]
decodeDeltaDeltaZigZag
(int[] ddz) static IntArray
decodeDeltaIntArray
(byte[] buf) The reverse of theencodeDeltaIntArray(IntArray)
method.static int
decodeZigZag
(int x) static int[]
encodeDeltaDeltaZigZag
(int[] x) static int[]
static int[]
static byte[]
Encode an int array as a sequence of varints representing the deltas between the subsequent elements of the input array.static int
encodeSigned
(byte[] buf, int pos, int x) static int
encodeZigZag
(int x) static int
getEncodedSize
(int value) get the number of bytes necessary to encode valuestatic VarIntUtil.ArrayDecoder
newArrayDecoder
(byte[] buf) static int
static String
static int
static long
static void
writeSignedVarint32
(ByteBuffer bb, int x) static void
static int
writeVarInt32
(byte[] buf, int pos, int x) Encodes x as varint in the buffer at position pos and returns the new positionstatic void
writeVarInt32
(ByteBuffer bb, int x) static void
writeVarInt64
(ByteBuffer bb, long x)
-
Constructor Details
-
VarIntUtil
public VarIntUtil()
-
-
Method Details
-
writeVarInt32
public static int writeVarInt32(byte[] buf, int pos, int x) Encodes x as varint in the buffer at position pos and returns the new position- Parameters:
buf
-x
-- Returns:
- the decoded integer
-
writeVarInt32
-
writeVarInt64
-
readVarInt32
- Throws:
DecodingException
-
readVarInt64
-
writeSignedVarint32
-
readSignedVarInt32
- Throws:
DecodingException
-
encodeSigned
public static int encodeSigned(byte[] buf, int pos, int x) -
newArrayDecoder
-
decodeZigZag
public static int decodeZigZag(int x) -
encodeZigZag
public static int encodeZigZag(int x) -
writeSizeDelimitedString
-
readSizeDelimitedString
- Throws:
DecodingException
-
encodeDeltaDeltaZigZag
public static int[] encodeDeltaDeltaZigZag(int[] x) -
decodeDeltaDeltaZigZag
public static int[] decodeDeltaDeltaZigZag(int[] ddz) -
encodeDeltaDeltaZigZag
-
encodeDeltaDeltaZigZag
-
getEncodedSize
public static int getEncodedSize(int value) get the number of bytes necessary to encode value- Parameters:
value
-- Returns:
-
encodeDeltaIntArray
Encode an int array as a sequence of varints representing the deltas between the subsequent elements of the input array. It is best if the array is sorted in ascending order (because encoding negative numbers in varint is not efficient).- Parameters:
s
-- Returns:
-
decodeDeltaIntArray
The reverse of theencodeDeltaIntArray(IntArray)
method.- Parameters:
buf
-- Returns:
-