Package org.apache.beam.sdk.util
Class VarInt
- java.lang.Object
-
- org.apache.beam.sdk.util.VarInt
-
public class VarInt extends java.lang.Object
Variable-length encoding for integers.Handles, in a common encoding format, signed bytes, shorts, ints, and longs. Takes between 1 and 10 bytes. Less efficient than BigEndian{Int,Long} coder for negative or large numbers. All negative ints are encoded using 5 bytes, longs take 10 bytes.
-
-
Constructor Summary
Constructors Constructor Description VarInt()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
decodeInt(java.io.InputStream stream)
Decodes an integer value from the given stream.static long
decodeLong(java.io.InputStream stream)
Decodes a long value from the given stream.static void
encode(int v, java.io.OutputStream stream)
Encodes the given value onto the stream.static void
encode(long v, java.io.OutputStream stream)
Encodes the given value onto the stream.static int
getLength(int v)
Returns the length of the encoding of the given value (in bytes).static int
getLength(long v)
Returns the length of the encoding of the given value (in bytes).
-
-
-
Method Detail
-
encode
public static void encode(int v, java.io.OutputStream stream) throws java.io.IOException
Encodes the given value onto the stream.- Throws:
java.io.IOException
-
encode
public static void encode(long v, java.io.OutputStream stream) throws java.io.IOException
Encodes the given value onto the stream.- Throws:
java.io.IOException
-
decodeInt
public static int decodeInt(java.io.InputStream stream) throws java.io.IOException
Decodes an integer value from the given stream.- Throws:
java.io.IOException
-
decodeLong
public static long decodeLong(java.io.InputStream stream) throws java.io.IOException
Decodes a long value from the given stream.- Throws:
java.io.IOException
-
getLength
public static int getLength(int v)
Returns the length of the encoding of the given value (in bytes).
-
getLength
public static int getLength(long v)
Returns the length of the encoding of the given value (in bytes).
-
-