Class ByteSource.VariableLengthInteger
java.lang.Object
org.apache.cassandra.utils.bytecomparable.ByteSource.VariableLengthInteger
- All Implemented Interfaces:
ByteSource
- Enclosing interface:
- ByteSource
Variable-length encoding for signed integers.
The encoding is based on the unsigned encoding above, where the first bit stored is the inverted sign,
followed by as many matching bits as there are additional bytes in the encoding, followed by the two's
complement of the number.
Because of the inverted sign bit, negative numbers compare smaller than positives, and because the length
bits match the sign, longer positive numbers compare greater and longer negative ones compare smaller.
Examples:
0 encodes as 80
1 encodes as 81
-1 encodes as 7F
63 encodes as BF
64 encodes as C040
-64 encodes as 40
-65 encodes as 3FBF
2^20-1 encodes as EFFFFF
2^20 encodes as F0100000
-2^20 encodes as 100000
2^64-1 encodes as FFFFFFFFFFFFFFFFFF
-2^64 encodes as 000000000000000000
As the number of bytes is specified in bits 2-9, no value is a prefix of another.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.cassandra.utils.bytecomparable.ByteSource
ByteSource.AbstractEscaper, ByteSource.AccessorEscaper<V>, ByteSource.ArrayEscaper, ByteSource.BufferEscaper, ByteSource.MemoryEscaper, ByteSource.Multi, ByteSource.Number, ByteSource.Peekable, ByteSource.Separator, ByteSource.SignedFixedLengthFloat<V>, ByteSource.SignedFixedLengthNumber<V>, ByteSource.VariableLengthInteger, ByteSource.VariableLengthUnsignedInteger -
Field Summary
Fields inherited from interface org.apache.cassandra.utils.bytecomparable.ByteSource
EMPTY, END_OF_STREAM, ESCAPE, ESCAPED_0_CONT, ESCAPED_0_DONE, EXCLUDED, GT_NEXT_COMPONENT, GTGT_NEXT_COMPONENT, LT_NEXT_COMPONENT, LTLT_NEXT_COMPONENT, MAX_NEXT_COMPONENT, MAX_SEPARATOR, MIN_NEXT_COMPONENT, MIN_SEPARATOR, NEXT_COMPONENT, NEXT_COMPONENT_EMPTY, NEXT_COMPONENT_EMPTY_REVERSED, NEXT_COMPONENT_NULL, TERMINATOR -
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
VariableLengthInteger
public VariableLengthInteger(long value)
-
-
Method Details
-
next
public int next()Description copied from interface:ByteSourceConsume the next byte, unsigned. Must be between 0 and 255, or END_OF_STREAM if there are no more bytes.- Specified by:
nextin interfaceByteSource
-