Class VarLenInt
- 
Nested Class Summary
Nested Classes - 
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe max number of bytes used to encodelongvalues.static final longThe max value supported by this variable-length codec, 2^62-1. - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionstatic intdecodeInt(ByteBuffer byteBuffer) Decodes anintvalue from the givenByteBuffer.static longdecodeLong(ByteBuffer byteBuffer) Decodes alongvalue from the givenByteBuffer.static voidencode(ByteBuffer byteBuffer, long value) Variable-length encodes the givenlongvalue into the givenByteBuffer, starting at its current position.static intlength(long value) Returns the number of bytes necessary to variable-length encode the givenlongvalue.booleantryDecode(ByteBuffer byteBuffer, LongConsumer consumer) Tries to decode a variable-lengthlongfrom the givenByteBuffer.booleantryDecode(ByteBuffer byteBuffer, VarLenInt.IntLongConsumer consumer) Tries to decode a variable-lengthlongfrom the givenByteBuffer. 
- 
Field Details
- 
MAX_VALUE
public static final long MAX_VALUEThe max value supported by this variable-length codec, 2^62-1.- See Also:
 
 - 
MAX_LENGTH
public static final int MAX_LENGTHThe max number of bytes used to encodelongvalues.- See Also:
 
 
 - 
 - 
Constructor Details
- 
VarLenInt
public VarLenInt() 
 - 
 - 
Method Details
- 
tryDecode
Tries to decode a variable-length
longfrom the givenByteBuffer.If there are enough bytes to decode the
longvalue, the givenConsumeris invoked with the value, and this method returnstrue. Otherwise, there are not enough bytes to decode thelongvalue, and this method returnsfalse.- Parameters:
 byteBuffer- theByteBufferto decode fromconsumer- theLongConsumerto invoke when the decoding is complete- Returns:
 - whether the decoding was complete
 
 - 
tryDecode
Tries to decode a variable-length
longfrom the givenByteBuffer.If there are enough bytes to decode the
longvalue, the givenIntLongConsumeris invoked with the number of bytes consumed and the value, and this method returnstrue. Otherwise, there are not enough bytes to decode thelongvalue, and this method returnsfalse.- Parameters:
 byteBuffer- theByteBufferto decode fromconsumer- theLongConsumerto invoke when the decoding is complete- Returns:
 - whether the decoding was complete
 
 - 
decodeInt
Decodes an
intvalue from the givenByteBuffer.- Parameters:
 byteBuffer- theByteBufferto decode from- Returns:
 - the decoded 
intvalue 
 - 
decodeLong
Decodes a
longvalue from the givenByteBuffer.- Parameters:
 byteBuffer- theByteBufferto decode from- Returns:
 - the decoded 
longvalue 
 - 
encode
Variable-length encodes the given
longvalue into the givenByteBuffer, starting at its current position.- Parameters:
 byteBuffer- theByteBufferto encode intovalue- thelongvalue to encode
 - 
length
public static int length(long value) Returns the number of bytes necessary to variable-length encode the given
longvalue.- Parameters:
 value- thelongvalue to encode- Returns:
 - the number of bytes necessary to variable-length encode the given 
longvalue 
 
 -