Class CompactRawSerialisationUtils
- java.lang.Object
-
- uk.gov.gchq.gaffer.serialisation.implementation.raw.CompactRawSerialisationUtils
-
public final class CompactRawSerialisationUtils extends Object
The methods in this class are used in bothCompactRawIntegerSerialiser
andCompactRawLongSerialiser
. They are based on methods from the org.apache.hadoop.io.WritableUtils class in Apache Hadoop. They are implemented as static methods in a utility class so that other classes can use them directly without the need to create a Serialisation class.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
decodeVIntSize(byte value)
static long
read(InputStream input)
Reads a long from the providedInputStream
.static long
readLong(byte[] bytes)
static long
readLong(byte[] allBytes, int offset)
static void
write(long l, OutputStream output)
Writes a long to the providedOutputStream
.static byte[]
writeLong(long l)
-
-
-
Method Detail
-
writeLong
public static byte[] writeLong(long l)
-
readLong
public static long readLong(byte[] allBytes, int offset) throws SerialisationException
- Throws:
SerialisationException
-
readLong
public static long readLong(byte[] bytes) throws SerialisationException
- Throws:
SerialisationException
-
write
public static void write(long l, OutputStream output) throws SerialisationException
Writes a long to the providedOutputStream
. NB: This code is very similar to the code in thewriteLong(long)
method. This violates the DRY principle, but the alternative is to implement the code in thewriteLong(long)
method by creating a ByteArrayOutputStream from the byte array and then using this method. This approach avoids that expense.- Parameters:
l
- The long to write.output
- TheOutputStream
to write data to.- Throws:
SerialisationException
- if there is anIOException
writing the long.
-
read
public static long read(InputStream input) throws SerialisationException
Reads a long from the providedInputStream
. This requires the long to have been written bywrite(long, OutputStream)
. NB: This code is very similar to the code in thereadLong(byte[])
method. This violates the DRY principle, but the alternative is to implement the code in thereadLong(byte[])
method by creating a ByteArrayInputStream from the byte array and then using this method. This approach avoids that expense.- Parameters:
input
- TheInputStream
to read data from.- Returns:
- The value of the serialised long.
- Throws:
SerialisationException
- if there is anIOException
converting the data to a long.
-
decodeVIntSize
public static int decodeVIntSize(byte value)
-
-