Class OrderedBytes
java.lang.Object
io.confluent.serializers.OrderedBytes
Partial implementation of the HBase OrderedBytes encoding scheme -
https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/util/OrderedBytes.html
These byte arrays maintain the sort order of the original data structures so they can be used for scans in RocksDB - Each type begins with a byte marker - Nulls are allowed and they sort first before any other type - Strings are UTF-8 encoded with a null byte end marker - Fixed-length integers are encoded big endian
Rather than drag in hbase-common and it's dependencies, we're opting to implement a subset of the spec
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intflipSignBit(int in) static longflipSignBit(long in) static shortflipSignBit(short in) static intgetMaxNumBytes(String string) static IntegerreadInt(ByteBuffer buffer) static LongreadLong(ByteBuffer buffer) static ShortreadShort(ByteBuffer buffer) static StringreadString(ByteBuffer buffer) static booleanstartsWith(byte[] array, byte[] prefix) static intwriteInt(ByteBuffer buffer, Integer value) Appends value to buffer, using (value ^ Integer.MIN_VALUE) to invert to sign bit so that the appended bytes will sort correctlystatic intwriteLong(ByteBuffer buffer, Long value) Appends value to buffer, using (value ^ Long.MIN_VALUE) to invert to sign bit so that the appended bytes will sort correctlystatic intwriteNull(ByteBuffer buffer) static intwriteShort(ByteBuffer buffer, Short value) Appends value to buffer, using (value ^ Short.MIN_VALUE) to invert to sign bit so that the appended bytes will sort correctlystatic intwriteString(ByteBuffer buffer, String value)
-
Field Details
-
NULL_SIZE
public static final int NULL_SIZE- See Also:
-
FIXED_INT_16_SIZE
public static final int FIXED_INT_16_SIZE- See Also:
-
FIXED_INT_32_SIZE
public static final int FIXED_INT_32_SIZE- See Also:
-
FIXED_INT_64_SIZE
public static final int FIXED_INT_64_SIZE- See Also:
-
MARKER_NULL
public static final byte MARKER_NULL- See Also:
-
MARKER_START_STRING
public static final byte MARKER_START_STRING- See Also:
-
MARKER_END_STRING
public static final byte MARKER_END_STRING- See Also:
-
MARKER_START_FIXED_INT_16
public static final byte MARKER_START_FIXED_INT_16- See Also:
-
MARKER_START_FIXED_INT_32
public static final byte MARKER_START_FIXED_INT_32- See Also:
-
MARKER_START_FIXED_INT_64
public static final byte MARKER_START_FIXED_INT_64- See Also:
-
-
Constructor Details
-
OrderedBytes
public OrderedBytes()
-
-
Method Details
-
writeNull
-
startsWith
public static boolean startsWith(byte[] array, byte[] prefix) -
getMaxNumBytes
-
readString
-
writeString
-
readInt
-
writeInt
Appends value to buffer, using (value ^ Integer.MIN_VALUE) to invert to sign bit so that the appended bytes will sort correctly- Parameters:
buffer- to append tovalue- to append- Returns:
- # of bytes written to buffer
-
readLong
-
writeLong
Appends value to buffer, using (value ^ Long.MIN_VALUE) to invert to sign bit so that the appended bytes will sort correctly- Parameters:
buffer- to append tovalue- to append- Returns:
- # of bytes written to buffer
-
readShort
-
writeShort
Appends value to buffer, using (value ^ Short.MIN_VALUE) to invert to sign bit so that the appended bytes will sort correctly- Parameters:
buffer- to append tovalue- to append- Returns:
- # of bytes written to buffer
-
flipSignBit
public static long flipSignBit(long in) -
flipSignBit
public static int flipSignBit(int in) -
flipSignBit
public static short flipSignBit(short in)
-