@PublicEvolving public class SimpleVersionedSerialization extends Object
SimpleVersionedSerializer
.Modifier and Type | Method and Description |
---|---|
static <T> T |
readVersionAndDeSerialize(SimpleVersionedSerializer<T> serializer,
byte[] bytes)
Deserializes the version and datum from a byte array.
|
static <T> T |
readVersionAndDeSerialize(SimpleVersionedSerializer<T> serializer,
DataInputView in)
Deserializes the version and datum from a stream.
|
static <T> byte[] |
writeVersionAndSerialize(SimpleVersionedSerializer<T> serializer,
T datum)
Serializes the version and datum into a byte array.
|
static <T> void |
writeVersionAndSerialize(SimpleVersionedSerializer<T> serializer,
T datum,
DataOutputView out)
Serializes the version and datum into a stream.
|
public static <T> void writeVersionAndSerialize(SimpleVersionedSerializer<T> serializer, T datum, DataOutputView out) throws IOException
Data serialized via this method can be deserialized via
readVersionAndDeSerialize(SimpleVersionedSerializer, DataInputView)
.
The first four bytes will be occupied by the version, as returned by
SimpleVersionedSerializer.getVersion()
. The remaining bytes will be the serialized
datum, as produced by SimpleVersionedSerializer.serialize(Object)
, plus its length.
The resulting array will hence be eight bytes larger than the serialized datum.
serializer
- The serializer to serialize the datum with.datum
- The datum to serialize.out
- The stream to serialize to.IOException
public static <T> T readVersionAndDeSerialize(SimpleVersionedSerializer<T> serializer, DataInputView in) throws IOException
This method deserializes data serialized via
writeVersionAndSerialize(SimpleVersionedSerializer, Object, DataOutputView)
.
The first four bytes will be interpreted as the version. The next four bytes will be
interpreted as the length of the datum bytes, then length-many bytes will be read.
Finally, the datum is deserialized via the SimpleVersionedSerializer.deserialize(int, byte[])
method.
serializer
- The serializer to serialize the datum with.in
- The stream to deserialize from.IOException
public static <T> byte[] writeVersionAndSerialize(SimpleVersionedSerializer<T> serializer, T datum) throws IOException
SimpleVersionedSerializer.getVersion()
),
written in big-endian encoding. The remaining bytes will be the serialized
datum, as produced by SimpleVersionedSerializer.serialize(Object)
. The resulting array
will hence be four bytes larger than the serialized datum.
Data serialized via this method can be deserialized via
readVersionAndDeSerialize(SimpleVersionedSerializer, byte[])
.
serializer
- The serializer to serialize the datum with.datum
- The datum to serialize.IOException
- Exceptions from the SimpleVersionedSerializer.serialize(Object)
method are forwarded.public static <T> T readVersionAndDeSerialize(SimpleVersionedSerializer<T> serializer, byte[] bytes) throws IOException
SimpleVersionedSerializer.deserialize(int, byte[])
.serializer
- The serializer to deserialize the datum with.bytes
- The bytes to deserialize from.IOException
- Exceptions from the SimpleVersionedSerializer.deserialize(int, byte[])
method are forwarded.Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.