java.lang.Object
org.yamcs.utils.VarIntUtil
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classdecodes an array of varintsstatic class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int[]decodeDeltaDeltaZigZag(int[] ddz) static IntArraydecodeDeltaIntArray(byte[] buf) The reverse of theencodeDeltaIntArray(IntArray)method.static intdecodeZigZag(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 intencodeSigned(byte[] buf, int pos, int x) static intencodeZigZag(int x) static intgetEncodedSize(int value) get the number of bytes necessary to encode valuestatic VarIntUtil.ArrayDecodernewArrayDecoder(byte[] buf) static intstatic Stringstatic intstatic longstatic voidwriteSignedVarint32(ByteBuffer bb, int x) static voidstatic intwriteVarInt32(byte[] buf, int pos, int x) Encodes x as varint in the buffer at position pos and returns the new positionstatic voidwriteVarInt32(ByteBuffer bb, int x) static voidwriteVarInt64(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:
-