public class NullableSerializer<T> extends Object implements Serializer<T>
null value serialization.| 限定符和类型 | 方法和说明 |
|---|---|
static <T> boolean |
checkIfNullSupported(Serializer<T> serializer)
This method checks if
serializer supports null value. |
T |
copy(T from)
Creates a deep copy of the given element in a new element.
|
T |
deserialize(DataInputView source)
De-serializes a record from the given source input view.
|
Serializer<T> |
duplicate()
Creates a deep copy of this serializer if it is necessary, i.e. if it is stateful.
|
boolean |
equals(Object obj) |
int |
hashCode() |
void |
serialize(T record,
DataOutputView target)
Serializes the given record to the given target output view.
|
static <T> Serializer<T> |
wrap(Serializer<T> originalSerializer)
This method wraps the
originalSerializer with the NullableSerializer if not
already wrapped. |
static <T> Serializer<T> |
wrapIfNullIsNotSupported(Serializer<T> originalSerializer)
This method tries to serialize
null value with the originalSerializer and
wraps it in case of NullPointerException, otherwise it returns the originalSerializer. |
public static <T> Serializer<T> wrapIfNullIsNotSupported(@Nonnull Serializer<T> originalSerializer)
null value with the originalSerializer and
wraps it in case of NullPointerException, otherwise it returns the originalSerializer.originalSerializer - serializer to wrap and add null supportnull valuespublic static <T> boolean checkIfNullSupported(Serializer<T> serializer)
serializer supports null value.serializer - serializer to checkpublic static <T> Serializer<T> wrap(Serializer<T> originalSerializer)
originalSerializer with the NullableSerializer if not
already wrapped.originalSerializer - serializer to wrap and add null supportnull valuespublic Serializer<T> duplicate()
SerializerWe need this because Serializers might be used in several threads. Stateless serializers are inherently thread-safe while stateful serializers might not be thread-safe.
duplicate 在接口中 Serializer<T>public T copy(T from)
Serializercopy 在接口中 Serializer<T>from - The element reuse be copied.public void serialize(T record, DataOutputView target) throws IOException
Serializerserialize 在接口中 Serializer<T>record - The record to serialize.target - The output view to write the serialized data to.IOException - Thrown, if the serialization encountered an I/O related error. Typically
raised by the output view, which may have an underlying I/O channel to which it
delegates.public T deserialize(DataInputView source) throws IOException
Serializerdeserialize 在接口中 Serializer<T>source - The input view from which to read the data.IOException - Thrown, if the de-serialization encountered an I/O related error.
Typically raised by the input view, which may have an underlying I/O channel from which
it reads.Copyright © 2023 The Apache Software Foundation. All rights reserved.