public class LongBinding extends ComparableBinding
ByteIterables of length 8, LongBinding has a pair of methods for
serialization/deserialization of non-negative values to/from compressed entries:
longToCompressedEntry(long) and compressedEntryToLong(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 LongBinding |
BINDING |
| Modifier and Type | Method and Description |
|---|---|
static long |
compressedEntryToLong(@NotNull ByteIterable entry)
De-serializes compressed ByteIterable entry to an unsigned
long value. |
static long |
compressedEntryToSignedLong(@NotNull ByteIterable entry)
De-serializes compressed ByteIterable entry to a signed
long value. |
static long |
entryToLong(@NotNull ByteIterable entry)
De-serializes ByteIterable entry to a
long value. |
static long |
entryToUnsignedLong(@NotNull byte[] bytes,
int offset,
int length) |
static long |
entryToUnsignedLong(@NotNull ByteIterator bi,
int length) |
static ArrayByteIterable |
longToCompressedEntry(long object)
Serializes unsigned
long value to the compressed ArrayByteIterable entry. |
static ArrayByteIterable |
longToEntry(long object)
Serializes
long value to the ArrayByteIterable entry. |
static long |
readCompressed(@NotNull ByteIterator iterator) |
java.lang.Long |
readObject(@NotNull java.io.ByteArrayInputStream stream) |
static ArrayByteIterable |
signedLongToCompressedEntry(long object)
Serializes signed
long value in the range [Long.MIN_VALUE/2..Long.MAX_VALUE/2]
to the compressed ArrayByteIterable entry. |
static void |
writeCompressed(@NotNull LightOutputStream output,
long l) |
static void |
writeCompressed(@NotNull LightOutputStream output,
long l,
int[] bytes) |
void |
writeObject(@NotNull LightOutputStream output,
@NotNull java.lang.Comparable object) |
static void |
writeUnsignedLong(long l,
int bytesPerLong,
@NotNull LightOutputStream output) |
entryToObject, objectToEntrypublic static final LongBinding BINDING
public java.lang.Long 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 long entryToLong(@NotNull
@NotNull ByteIterable entry)
long value.
The entry should be an output of longToEntry(long).entry - ByteIterable instancelongToEntry(long),
compressedEntryToLong(ByteIterable),
longToCompressedEntry(long),
compressedEntryToSignedLong(ByteIterable),
signedLongToCompressedEntry(long)public static ArrayByteIterable longToEntry(long object)
long value to the ArrayByteIterable entry.object - value to serializeentryToLong(ByteIterable),
compressedEntryToLong(ByteIterable),
longToCompressedEntry(long),
compressedEntryToSignedLong(ByteIterable),
signedLongToCompressedEntry(long)public static long compressedEntryToLong(@NotNull
@NotNull ByteIterable entry)
long value.
The entry should be an output of longToCompressedEntry(long).entry - ByteIterable instanceentryToLong(ByteIterable),
longToEntry(long),
longToCompressedEntry(long),
compressedEntryToSignedLong(ByteIterable),
signedLongToCompressedEntry(long)public static ArrayByteIterable longToCompressedEntry(long object)
long value to the compressed ArrayByteIterable entry.object - non-negative value to serializeentryToLong(ByteIterable),
longToEntry(long),
compressedEntryToLong(ByteIterable),
compressedEntryToSignedLong(ByteIterable),
signedLongToCompressedEntry(long)public static long compressedEntryToSignedLong(@NotNull
@NotNull ByteIterable entry)
long value.
The entry should be an output of signedLongToCompressedEntry(long).
ZigZag encoding is used,
so it doesn't save the order of values like other ComparableBindings do.
entry - ByteIterable instanceentryToLong(ByteIterable),
longToEntry(long),
compressedEntryToLong(ByteIterable),
longToCompressedEntry(long),
signedLongToCompressedEntry(long)public static ArrayByteIterable signedLongToCompressedEntry(long object)
long value in the range [Long.MIN_VALUE/2..Long.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 [Long.MIN_VALUE/2..Long.MAX_VALUE/2]entryToLong(ByteIterable),
longToEntry(long),
compressedEntryToLong(ByteIterable),
longToCompressedEntry(long),
compressedEntryToSignedLong(ByteIterable)public static void writeUnsignedLong(long l,
int bytesPerLong,
@NotNull
@NotNull LightOutputStream output)
public static long entryToUnsignedLong(@NotNull
@NotNull ByteIterator bi,
int length)
public static long entryToUnsignedLong(@NotNull
@NotNull byte[] bytes,
int offset,
int length)
public static long readCompressed(@NotNull
@NotNull ByteIterator iterator)
public static void writeCompressed(@NotNull
@NotNull LightOutputStream output,
long l)
public static void writeCompressed(@NotNull
@NotNull LightOutputStream output,
long l,
int[] bytes)