Class IndexKey
- All Implemented Interfaces:
Comparable<IndexKey>
Index.
Index keys are always represented as a byte array. Convenience functions to use String
and long as keys are provided this type.
The serialized representation of an IndexKey is its binary representation terminated
by a 0x01 byte. 0x01 appearing in the value is escaped as 0x02 0x01,
0x02 appearing in the value is escaped as 0x02 0x02,
The implementation assumes that 0x00 byte values appear more often, for example, when
serializing plain long keys, hence the choice to use 0x01/0x02.
The serialized representation of IndexKeys is safe to be "partially serialized", as
done by index implementations, which does not serialize the common prefix of a key compared to
the previously serialized key.
IndexKeys are comparable, the results reflect the outcome of the unsigned
comparison of the respective byte representations.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final IndexValueSerializer<IndexKey> static final intMaximum number of characters in a key. -
Method Summary
Modifier and TypeMethodDescriptionlongasLong()intstatic IndexKeydeserializeKey(ByteBuffer buffer) booleaninthashCode()static IndexKeykey(long value) static IndexKeystatic IndexKeykey(ByteBuffer buffer) serialize(ByteBuffer target) intvoidserializeNoFail(ByteBuffer target) static voidskip(ByteBuffer buffer) booleanstartsWith(IndexKey prefix) toSafeString(String prefix) toString()
-
Field Details
-
MAX_LENGTH
public static final int MAX_LENGTHMaximum number of characters in a key. Note: characters can take up to 3 bytes via UTF-8.- See Also:
-
INDEX_KEY_SERIALIZER
-
-
Method Details
-
key
-
key
-
key
-
deserializeKey
-
skip
-
serializedSize
public int serializedSize() -
serialize
-
serializeNoFail
-
compareTo
- Specified by:
compareToin interfaceComparable<IndexKey>
-
hashCode
public int hashCode() -
equals
-
toString
-
toSafeString
-
startsWith
-
asLong
public long asLong() -
asByteBuffer
-