public class SerializationUtils extends Object
SerializationUtils class internally uses Kryo serializer for serializing / deserializing objects.| Modifier and Type | Class and Description |
|---|---|
static class |
SerializationUtils.AvroUtf8Serializer
NOTE: This
Serializer could deserialize instance of Utf8 serialized
by implicitly generated Kryo serializer (based on com.esotericsoftware.kryo.serializers.FieldSerializer |
| Constructor and Description |
|---|
SerializationUtils() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
deserialize(byte[] objectData)
Deserializes a single
Object from an array of bytes. |
static byte[] |
serialize(Object obj)
Serializes an
Object to a byte array for storage/serialization. |
public static byte[] serialize(Object obj) throws IOException
Serializes an Object to a byte array for storage/serialization.
obj - the object to serialize to bytesIOException - if the serialization failspublic static <T> T deserialize(byte[] objectData)
Deserializes a single Object from an array of bytes.
If the call site incorrectly types the return value, a ClassCastException is thrown from the call site.
Without Generics in this declaration, the call site must type cast and can cause the same ClassCastException. Note
that in both cases, the ClassCastException is in the call site, not in this method.
T - the object type to be deserializedobjectData - the serialized object, must not be nullIllegalArgumentException - if objectData is nullCopyright © 2024 The Apache Software Foundation. All rights reserved.