Class ByteSource.AbstractEscaper
java.lang.Object
org.apache.cassandra.utils.bytecomparable.ByteSource.AbstractEscaper
- All Implemented Interfaces:
ByteSource
- Direct Known Subclasses:
ByteSource.AccessorEscaper,ByteSource.ArrayEscaper,ByteSource.BufferEscaper,ByteSource.MemoryEscaper
- Enclosing interface:
- ByteSource
Variable-length encoding. Escapes 0s as ESCAPE + zero or more ESCAPED_0_CONT + ESCAPED_0_DONE.
If the source ends in 0, we use ESCAPED_0_CONT to make sure that the encoding remains smaller than that source
with a further 0 at the end.
Finishes in an escaped state (either with ESCAPE or ESCAPED_0_CONT), which in
ByteSource.Multi is followed by
a component separator between 0x10 and 0xFE.
E.g. "A\0\0B" translates to 4100FEFF4200
"A\0B\0" 4100FF4200FE (+00 for ByteComparable.Version.LEGACY)
"A\0" 4100FE (+00 for ByteComparable.Version.LEGACY)
"AB" 414200
If in a single byte source, the bytes could be simply passed unchanged, but this would not allow us to
combine components. This translation preserves order, and since the encoding for 0 is higher than the separator
also makes sure shorter components are treated as smaller.
The encoding is not prefix-free, since e.g. the encoding of "A" (4100) is a prefix of the encoding of "A\0"
(4100FE), but the byte following the prefix is guaranteed to be FE or FF, which makes the encoding weakly
prefix-free. Additionally, any such prefix sequence will compare smaller than the value to which it is a prefix,
because any permitted separator byte will be smaller than the byte following the prefix.-
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 -
Method Summary
-
Method Details
-
next
public final 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
-
get
protected abstract byte get(int index) -
limit
protected abstract int limit()
-