T
- The type of element in the list.public final class ListSerializer<T> extends Object implements Serializer<List<T>>
Lists
. The serializer relies on an element serializer for the
serialization of the list's elements.
The serialization format for the list is as follows: four bytes for the length of the lost, followed by the serialized representation of each element.
Constructor and Description |
---|
ListSerializer(Serializer<T> elementSerializer)
Creates a list serializer that uses the given serializer to serialize the list's elements.
|
Modifier and Type | Method and Description |
---|---|
List<T> |
copy(List<T> from)
Creates a deep copy of the given element in a new element.
|
List<T> |
deserialize(DataInputView source)
De-serializes a record from the given source input view.
|
Serializer<List<T>> |
duplicate()
Creates a deep copy of this serializer if it is necessary, i.e.
|
boolean |
equals(Object obj) |
Serializer<T> |
getElementSerializer()
Gets the serializer for the elements of the list.
|
int |
hashCode() |
void |
serialize(List<T> list,
DataOutputView target)
Serializes the given record to the given target output view.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
deserializeFromString, serializeToString
public ListSerializer(Serializer<T> elementSerializer)
elementSerializer
- The serializer for the elements of the listpublic Serializer<T> getElementSerializer()
public Serializer<List<T>> duplicate()
Serializer
We 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
in interface Serializer<List<T>>
public List<T> copy(List<T> from)
Serializer
copy
in interface Serializer<List<T>>
from
- The element reuse be copied.public void serialize(List<T> list, DataOutputView target) throws IOException
Serializer
serialize
in interface Serializer<List<T>>
list
- 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 List<T> deserialize(DataInputView source) throws IOException
Serializer
deserialize
in interface Serializer<List<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–2024 The Apache Software Foundation. All rights reserved.