@Beta @NonNullByDefault public final class WritableObjects extends Object
WritableObjects.| Modifier and Type | Method and Description |
|---|---|
static int |
longHeaderFlags(byte header)
Extract user-defined flags from a compressed long header.
|
static long |
readFirstLong(DataInput in,
byte header)
Read first long value from an input.
|
static long |
readLong(DataInput in)
Read a long value from a
DataInput which was previously written via writeLong(DataOutput, long). |
static long |
readLongBody(DataInput in,
byte header)
Read a long value from a
DataInput as hinted by the result of readLongHeader(DataInput). |
static byte |
readLongHeader(DataInput in)
Read the header of a compressed long value.
|
static long |
readSecondLong(DataInput in,
byte header)
Read second long value from an input.
|
static void |
writeLong(DataOutput out,
long value)
Shorthand for
writeLong(DataOutput, long, int) with zero flags. |
static void |
writeLong(DataOutput out,
long value,
int flags)
Write a long value into a
DataOutput, compressing potential zero bytes. |
static void |
writeLongs(DataOutput out,
long value0,
long value1)
Write two consecutive long values.
|
public static void writeLong(DataOutput out, long value) throws IOException
writeLong(DataOutput, long, int) with zero flags.out - Data outputvalue - long value to writeIOException - if an I/O error occursNullPointerException - if output is nullpublic static void writeLong(DataOutput out, long value, int flags) throws IOException
DataOutput, compressing potential zero bytes. This method is useful for
serializing counters and similar, which have a wide range, but typically do not use it. The value provided is
treated as unsigned.
This methods writes the number of trailing non-zero in the value. It then writes the minimum required bytes
to reconstruct the value by left-padding zeroes. Inverse operation is performed by readLong(DataInput)
or a combination of readLongHeader(DataInput) and readLongBody(DataInput, byte).
Additionally the caller can use the top four bits (i.e. 0xF0) for caller-specific flags. These will be
ignored by readLong(DataInput), but can be extracted via readLongHeader(DataInput).
out - Data outputvalue - long value to writeflags - flags to storeIOException - if an I/O error occursNullPointerException - if output is nullpublic static long readLong(DataInput in) throws IOException
DataInput which was previously written via writeLong(DataOutput, long).in - Data inputIOException - if an I/O error occursNullPointerException - if input is nullpublic static byte readLongHeader(DataInput in) throws IOException
longHeaderFlags(byte).in - Data inputIOException - if an I/O error occursNullPointerException - if input is nullpublic static int longHeaderFlags(byte header)
writeLong(DataOutput, long).header - Value header, as returned by readLongHeader(DataInput)public static long readLongBody(DataInput in, byte header) throws IOException
DataInput as hinted by the result of readLongHeader(DataInput).in - Data inputheader - Value header, as returned by readLongHeader(DataInput)IOException - if an I/O error occursNullPointerException - if input is nullpublic static void writeLongs(DataOutput out, long value0, long value1) throws IOException
readLongHeader(DataInput),
readFirstLong(DataInput, byte) and readSecondLong(DataInput, byte).
This is a more efficient way of serializing two longs than writeLong(DataOutput, long). This is
achieved by using the flags field to hold the length of the second long -- hence saving one byte.
out - Data outputvalue0 - first long value to writevalue1 - second long value to writeIOException - if an I/O error occursNullPointerException - if output is nullpublic static long readFirstLong(DataInput in, byte header) throws IOException
in - Data inputheader - Value header, as returned by readLongHeader(DataInput)writeLongs(DataOutput, long, long)IOException - if an I/O error occursNullPointerException - if input is nullpublic static long readSecondLong(DataInput in, byte header) throws IOException
in - Data inputheader - Value header, as returned by readLongHeader(DataInput)writeLongs(DataOutput, long, long)IOException - if an I/O error occursNullPointerException - if input is nullCopyright © 2019 OpenDaylight. All rights reserved.