Class VarIntUtil

java.lang.Object
org.yamcs.utils.VarIntUtil

public class VarIntUtil extends Object
  • 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

      public static void writeVarInt32(ByteBuffer bb, int x)
    • writeVarInt64

      public static void writeVarInt64(ByteBuffer bb, long x)
    • readVarInt32

      public static int readVarInt32(ByteBuffer bb) throws DecodingException
      Throws:
      DecodingException
    • readVarInt64

      public static long readVarInt64(ByteBuffer bb)
    • writeSignedVarint32

      public static void writeSignedVarint32(ByteBuffer bb, int x)
    • readSignedVarInt32

      public static int readSignedVarInt32(ByteBuffer bb) throws DecodingException
      Throws:
      DecodingException
    • encodeSigned

      public static int encodeSigned(byte[] buf, int pos, int x)
    • newArrayDecoder

      public static VarIntUtil.ArrayDecoder newArrayDecoder(byte[] buf)
    • decodeZigZag

      public static int decodeZigZag(int x)
    • encodeZigZag

      public static int encodeZigZag(int x)
    • writeSizeDelimitedString

      public static void writeSizeDelimitedString(ByteBuffer bb, String s)
    • readSizeDelimitedString

      public static String readSizeDelimitedString(ByteBuffer bb) throws DecodingException
      Throws:
      DecodingException
    • encodeDeltaDeltaZigZag

      public static int[] encodeDeltaDeltaZigZag(int[] x)
    • decodeDeltaDeltaZigZag

      public static int[] decodeDeltaDeltaZigZag(int[] ddz)
    • encodeDeltaDeltaZigZag

      public static int[] encodeDeltaDeltaZigZag(SortedIntArray a)
    • encodeDeltaDeltaZigZag

      public static int[] encodeDeltaDeltaZigZag(IntArray a)
    • getEncodedSize

      public static int getEncodedSize(int value)
      get the number of bytes necessary to encode value
      Parameters:
      value -
      Returns:
    • encodeDeltaIntArray

      public static byte[] encodeDeltaIntArray(IntArray s)
      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

      public static IntArray decodeDeltaIntArray(byte[] buf)
      The reverse of the encodeDeltaIntArray(IntArray) method.
      Parameters:
      buf -
      Returns: