Package org.apache.flink.util
Class SerializedValue<T>
- java.lang.Object
-
- org.apache.flink.util.SerializedValue<T>
-
- Type Parameters:
T
- The type of the value held.
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
CompressedSerializedValue
@Internal public class SerializedValue<T> extends Object implements Serializable
This class is used to transfer (via serialization) objects whose classes are not available in the system class loader. When those objects are deserialized without access to their special class loader, the deserialization fails with aClassNotFoundException
.To work around that issue, the SerializedValue serialized data immediately into a byte array. When send through RPC or another service that uses serialization, only the byte array is transferred. The object is deserialized later (upon access) and requires the accessor to provide the corresponding class loader.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SerializedValue(byte[] serializedData)
SerializedValue(T value)
Constructs a serialized value.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description T
deserializeValue(ClassLoader loader)
boolean
equals(Object obj)
static <T> SerializedValue<T>
fromBytes(byte[] serializedData)
Constructs serialized value from serialized data.byte[]
getByteArray()
Returns byte array for serialized data.int
hashCode()
String
toString()
-
-
-
Constructor Detail
-
SerializedValue
protected SerializedValue(byte[] serializedData)
-
SerializedValue
public SerializedValue(T value) throws IOException
Constructs a serialized value.- Parameters:
value
- value to serialize- Throws:
NullPointerException
- if value is nullIOException
- exception during serialization
-
-
Method Detail
-
deserializeValue
public T deserializeValue(ClassLoader loader) throws IOException, ClassNotFoundException
- Throws:
IOException
ClassNotFoundException
-
getByteArray
public byte[] getByteArray()
Returns byte array for serialized data.- Returns:
- Serialized data.
-
fromBytes
public static <T> SerializedValue<T> fromBytes(byte[] serializedData)
Constructs serialized value from serialized data.- Type Parameters:
T
- type- Parameters:
serializedData
- serialized data- Returns:
- serialized value
- Throws:
NullPointerException
- if serialized data is nullIllegalArgumentException
- if serialized data is empty
-
-