public class OrderedBytes
extends java.lang.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(java.lang.String string) |
static java.lang.Integer |
readInt(java.nio.ByteBuffer buffer) |
static java.lang.Long |
readLong(java.nio.ByteBuffer buffer) |
static java.lang.Short |
readShort(java.nio.ByteBuffer buffer) |
static java.lang.String |
readString(java.nio.ByteBuffer buffer) |
static boolean |
startsWith(byte[] array,
byte[] prefix) |
static int |
writeInt(java.nio.ByteBuffer buffer,
java.lang.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(java.nio.ByteBuffer buffer,
java.lang.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(java.nio.ByteBuffer buffer) |
static int |
writeShort(java.nio.ByteBuffer buffer,
java.lang.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(java.nio.ByteBuffer buffer,
java.lang.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(java.nio.ByteBuffer buffer)
public static boolean startsWith(byte[] array, byte[] prefix)
public static int getMaxNumBytes(java.lang.String string)
public static java.lang.String readString(java.nio.ByteBuffer buffer)
public static int writeString(java.nio.ByteBuffer buffer, java.lang.String value)
public static java.lang.Integer readInt(java.nio.ByteBuffer buffer)
public static int writeInt(java.nio.ByteBuffer buffer, java.lang.Integer value)
buffer
- to append tovalue
- to appendpublic static java.lang.Long readLong(java.nio.ByteBuffer buffer)
public static int writeLong(java.nio.ByteBuffer buffer, java.lang.Long value)
buffer
- to append tovalue
- to appendpublic static java.lang.Short readShort(java.nio.ByteBuffer buffer)
public static int writeShort(java.nio.ByteBuffer buffer, java.lang.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)