public class IntegerBinding extends ComparableBinding
ByteIterables of length 4, IntegerBinding has a pair of methods for
serialization/deserialization of non-negative values to/from compressed entries:
intToCompressedEntry(int) and compressedEntryToInt(ByteIterable). The lower the value,
the shorter the compressed entry. In some cases, compressed entries let you significantly decrease database size.
Serialization of non-negative integers and longs to compressed entries also saves the order of values.ComparableBinding| Modifier and Type | Field and Description |
|---|---|
static IntegerBinding |
BINDING |
| Modifier and Type | Method and Description |
|---|---|
static int |
compressedEntryToInt(@NotNull ByteIterable entry)
De-serializes compressed ByteIterable entry to an unsigned
int value. |
static int |
compressedEntryToSignedInt(@NotNull ByteIterable entry)
De-serializes compressed ByteIterable entry to a signed
int value. |
static int |
entryToInt(@NotNull ByteIterable entry)
De-serializes ByteIterable entry to an
int value. |
static ArrayByteIterable |
intToCompressedEntry(int object)
Serializes unsigned
int value to the compressed ArrayByteIterable entry. |
static ArrayByteIterable |
intToEntry(int object)
Serializes
int value to the ArrayByteIterable entry. |
static int |
readCompressed(@NotNull byte[] bytes) |
static int |
readCompressed(@NotNull ByteIterator iterator) |
java.lang.Integer |
readObject(@NotNull java.io.ByteArrayInputStream stream) |
static ArrayByteIterable |
signedIntToCompressedEntry(int object)
Serializes signed
int value in the range [Integer.MIN_VALUE/2..Integer.MAX_VALUE/2]
to the compressed ArrayByteIterable entry. |
static void |
writeCompressed(@NotNull LightOutputStream output,
int i) |
static void |
writeCompressed(@NotNull LightOutputStream output,
int i,
int[] bytes) |
void |
writeObject(@NotNull LightOutputStream output,
@NotNull java.lang.Comparable object) |
entryToObject, objectToEntrypublic static final IntegerBinding BINDING
public java.lang.Integer readObject(@NotNull
@NotNull java.io.ByteArrayInputStream stream)
readObject in class ComparableBindingpublic void writeObject(@NotNull
@NotNull LightOutputStream output,
@NotNull
@NotNull java.lang.Comparable object)
writeObject in class ComparableBindingpublic static int entryToInt(@NotNull
@NotNull ByteIterable entry)
entry - ByteIterable instanceintToEntry(int),
compressedEntryToInt(ByteIterable),
intToCompressedEntry(int),
compressedEntryToSignedInt(ByteIterable),
signedIntToCompressedEntry(int)public static ArrayByteIterable intToEntry(int object)
int value to the ArrayByteIterable entry.object - value to serializeentryToInt(ByteIterable),
compressedEntryToInt(ByteIterable),
intToCompressedEntry(int),
compressedEntryToSignedInt(ByteIterable),
signedIntToCompressedEntry(int)public static int compressedEntryToInt(@NotNull
@NotNull ByteIterable entry)
int value.
The entry should be an output of intToCompressedEntry(int).entry - ByteIterable instanceentryToInt(ByteIterable),
intToEntry(int),
intToCompressedEntry(int),
compressedEntryToSignedInt(ByteIterable),
signedIntToCompressedEntry(int)public static ArrayByteIterable intToCompressedEntry(int object)
int value to the compressed ArrayByteIterable entry.object - non-negative value to serializeentryToInt(ByteIterable),
intToEntry(int),
compressedEntryToInt(ByteIterable),
compressedEntryToSignedInt(ByteIterable),
signedIntToCompressedEntry(int)public static int compressedEntryToSignedInt(@NotNull
@NotNull ByteIterable entry)
int value.
The entry should be an output of signedIntToCompressedEntry(int).
ZigZag encoding is used,
so it doesn't save the order of values like other ComparableBindings do.
entry - ByteIterable instanceentryToInt(ByteIterable),
intToEntry(int),
compressedEntryToInt(ByteIterable),
intToCompressedEntry(int),
signedIntToCompressedEntry(int)public static ArrayByteIterable signedIntToCompressedEntry(int object)
int value in the range [Integer.MIN_VALUE/2..Integer.MAX_VALUE/2]
to the compressed ArrayByteIterable entry.
ZigZag encoding is used,
so it doesn't save the order of values like other ComparableBindings do.
object - value to serialize in the range [Integer.MIN_VALUE/2..Integer.MAX_VALUE/2]entryToInt(ByteIterable),
intToEntry(int),
compressedEntryToInt(ByteIterable),
intToCompressedEntry(int),
compressedEntryToSignedInt(ByteIterable)public static int readCompressed(@NotNull
@NotNull ByteIterator iterator)
public static int readCompressed(@NotNull
@NotNull byte[] bytes)
public static void writeCompressed(@NotNull
@NotNull LightOutputStream output,
int i)
public static void writeCompressed(@NotNull
@NotNull LightOutputStream output,
int i,
int[] bytes)