public class OrderedBytes extends Object
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
Modifier and Type | Field and Description |
---|---|
static int |
FIXED_INT_16_SIZE |
static int |
FIXED_INT_32_SIZE |
static int |
FIXED_INT_64_SIZE |
static byte |
MARKER_END_STRING |
static byte |
MARKER_NULL |
static byte |
MARKER_START_FIXED_INT_16 |
static byte |
MARKER_START_FIXED_INT_32 |
static byte |
MARKER_START_FIXED_INT_64 |
static byte |
MARKER_START_STRING |
static int |
NULL_SIZE |
Constructor and Description |
---|
OrderedBytes() |
Modifier and Type | Method and Description |
---|---|
static int |
flipSignBit(int in) |
static long |
flipSignBit(long in) |
static short |
flipSignBit(short in) |
static int |
getMaxNumBytes(String string) |
static Integer |
readInt(ByteBuffer buffer) |
static Long |
readLong(ByteBuffer buffer) |
static Short |
readShort(ByteBuffer buffer) |
static String |
readString(ByteBuffer buffer) |
static boolean |
startsWith(byte[] array,
byte[] prefix) |
static int |
writeInt(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 correctly
|
static int |
writeLong(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 correctly
|
static int |
writeNull(ByteBuffer buffer) |
static int |
writeShort(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 correctly
|
static int |
writeString(ByteBuffer buffer,
String value) |
public static final int NULL_SIZE
public static final int FIXED_INT_16_SIZE
public static final int FIXED_INT_32_SIZE
public static final int FIXED_INT_64_SIZE
public static final byte MARKER_NULL
public static final byte MARKER_START_STRING
public static final byte MARKER_END_STRING
public static final byte MARKER_START_FIXED_INT_16
public static final byte MARKER_START_FIXED_INT_32
public static final byte MARKER_START_FIXED_INT_64
public static int writeNull(ByteBuffer buffer)
public static boolean startsWith(byte[] array, byte[] prefix)
public static int getMaxNumBytes(String string)
public static String readString(ByteBuffer buffer)
public static int writeString(ByteBuffer buffer, String value)
public static Integer readInt(ByteBuffer buffer)
public static int writeInt(ByteBuffer buffer, Integer value)
buffer
- to append tovalue
- to appendpublic static Long readLong(ByteBuffer buffer)
public static int writeLong(ByteBuffer buffer, Long value)
buffer
- to append tovalue
- to appendpublic static Short readShort(ByteBuffer buffer)
public static int writeShort(ByteBuffer buffer, Short value)
buffer
- to append tovalue
- to appendpublic static long flipSignBit(long in)
public static int flipSignBit(int in)
public static short flipSignBit(short in)