public class BinaryRowSerializer extends AbstractRowSerializer<BinaryRow>
BinaryRow
.Modifier and Type | Class and Description |
---|---|
static class |
BinaryRowSerializer.BinaryRowSerializerSnapshot
|
Modifier and Type | Field and Description |
---|---|
static int |
LENGTH_SIZE_IN_BYTES |
Constructor and Description |
---|
BinaryRowSerializer(int numFields) |
Modifier and Type | Method and Description |
---|---|
void |
checkSkipReadForFixLengthPart(AbstractPagedInputView source)
We need skip bytes to read when the remain bytes of current segment is not
enough to write binary row fixed part.
|
BinaryRow |
copy(BinaryRow from)
Creates a deep copy of the given element in a new element.
|
BinaryRow |
copy(BinaryRow from,
BinaryRow reuse)
Creates a copy from the given element.
|
void |
copy(DataInputView source,
DataOutputView target)
Copies exactly one record from the source input view to the target output view.
|
void |
copyFromPagesToView(AbstractPagedInputView source,
DataOutputView target)
Copy a binaryRow which stored in paged input view to output view.
|
BinaryRow |
createInstance()
Creates a new instance of the data type.
|
BinaryRow |
deserialize(BinaryRow reuse,
DataInputView source)
De-serializes a record from the given source input view into the given reuse record instance if mutable.
|
BinaryRow |
deserialize(DataInputView source)
De-serializes a record from the given source input view.
|
BinaryRow |
deserializeFromPages(AbstractPagedInputView headerLessView)
De-serializes a record from the given source paged input view.
|
BinaryRow |
deserializeFromPages(BinaryRow reuse,
AbstractPagedInputView headerLessView)
Reuse version of
AbstractRowSerializer.deserializeFromPages(AbstractPagedInputView) . |
TypeSerializer<BinaryRow> |
duplicate()
Creates a deep copy of this serializer if it is necessary, i.e.
|
boolean |
equals(Object obj) |
int |
getArity()
Get the number of fields.
|
int |
getFixedLengthPartSize() |
int |
getLength()
Gets the length of the data type, if it is a fix length data type.
|
int |
getSerializedRowFixedPartLength()
Return fixed part length to serialize one row.
|
int |
hashCode() |
boolean |
isImmutableType()
Gets whether the type is an immutable type.
|
BinaryRow |
mapFromPages(AbstractPagedInputView headerLessView)
Map a record from the given source paged input view.
|
BinaryRow |
mapFromPages(BinaryRow reuse,
AbstractPagedInputView headerLessView)
Reuse version of
AbstractRowSerializer.mapFromPages(AbstractPagedInputView) . |
void |
pointTo(int length,
BinaryRow reuse,
AbstractPagedInputView headerLessView)
Point row to memory segments with offset(in the AbstractPagedInputView) and length.
|
void |
serialize(BinaryRow record,
DataOutputView target)
Serializes the given record to the given target output view.
|
int |
serializeToPages(BinaryRow record,
AbstractPagedOutputView headerLessView)
Serializes the given record to the given target paged output view.
|
static void |
serializeWithoutLengthSlow(BinaryRow record,
MemorySegmentWritable out) |
TypeSerializerSnapshot<BinaryRow> |
snapshotConfiguration()
Snapshots the configuration of this TypeSerializer.
|
BinaryRow |
toBinaryRow(BinaryRow baseRow)
|
public static final int LENGTH_SIZE_IN_BYTES
public boolean isImmutableType()
TypeSerializer
isImmutableType
in class TypeSerializer<BinaryRow>
public TypeSerializer<BinaryRow> duplicate()
TypeSerializer
duplicate
in class TypeSerializer<BinaryRow>
public BinaryRow createInstance()
TypeSerializer
createInstance
in class TypeSerializer<BinaryRow>
public BinaryRow copy(BinaryRow from)
TypeSerializer
copy
in class TypeSerializer<BinaryRow>
from
- The element reuse be copied.public BinaryRow copy(BinaryRow from, BinaryRow reuse)
TypeSerializer
copy
in class TypeSerializer<BinaryRow>
from
- The element to be copied.reuse
- The element to be reused. May or may not be used.public int getLength()
TypeSerializer
getLength
in class TypeSerializer<BinaryRow>
-1
for variable length data types.public void serialize(BinaryRow record, DataOutputView target) throws IOException
TypeSerializer
serialize
in class TypeSerializer<BinaryRow>
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 BinaryRow deserialize(DataInputView source) throws IOException
TypeSerializer
deserialize
in class TypeSerializer<BinaryRow>
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.public BinaryRow deserialize(BinaryRow reuse, DataInputView source) throws IOException
TypeSerializer
deserialize
in class TypeSerializer<BinaryRow>
reuse
- The record instance into which to de-serialize the data.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.public int getArity()
AbstractRowSerializer
getArity
in class AbstractRowSerializer<BinaryRow>
public BinaryRow toBinaryRow(BinaryRow baseRow) throws IOException
AbstractRowSerializer
toBinaryRow
in class AbstractRowSerializer<BinaryRow>
IOException
public int serializeToPages(BinaryRow record, AbstractPagedOutputView headerLessView) throws IOException
AbstractRowSerializer
BinaryRow
.serializeToPages
in class AbstractRowSerializer<BinaryRow>
record
- The record to serialize.headerLessView
- 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 static void serializeWithoutLengthSlow(BinaryRow record, MemorySegmentWritable out) throws IOException
IOException
public BinaryRow deserializeFromPages(AbstractPagedInputView headerLessView) throws IOException
AbstractRowSerializer
BinaryRow
. Typically, the content read from source should be copied out when
de-serializing, and we are not expecting the underlying data from source is reused. If you
have such requirement, see AbstractRowSerializer.mapFromPages(AbstractPagedInputView)
.deserializeFromPages
in class AbstractRowSerializer<BinaryRow>
headerLessView
- 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.public BinaryRow deserializeFromPages(BinaryRow reuse, AbstractPagedInputView headerLessView) throws IOException
AbstractRowSerializer
AbstractRowSerializer.deserializeFromPages(AbstractPagedInputView)
.deserializeFromPages
in class AbstractRowSerializer<BinaryRow>
IOException
public BinaryRow mapFromPages(AbstractPagedInputView headerLessView) throws IOException
AbstractRowSerializer
If you choose the zero copy way, you have to deal with the lifecycle of the pages properly.
mapFromPages
in class AbstractRowSerializer<BinaryRow>
headerLessView
- 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.public BinaryRow mapFromPages(BinaryRow reuse, AbstractPagedInputView headerLessView) throws IOException
AbstractRowSerializer
AbstractRowSerializer.mapFromPages(AbstractPagedInputView)
.mapFromPages
in class AbstractRowSerializer<BinaryRow>
IOException
public void copyFromPagesToView(AbstractPagedInputView source, DataOutputView target) throws IOException
source
- source paged input view where the binary row storedtarget
- the target output view.IOException
public void pointTo(int length, BinaryRow reuse, AbstractPagedInputView headerLessView) throws IOException
length
- row length.reuse
- reuse BinaryRow object.headerLessView
- source memory segments container.IOException
public void checkSkipReadForFixLengthPart(AbstractPagedInputView source) throws IOException
BinaryRow
.IOException
public int getSerializedRowFixedPartLength()
public int getFixedLengthPartSize()
public void copy(DataInputView source, DataOutputView target) throws IOException
TypeSerializer
target.write(source, 8);
.copy
in class TypeSerializer<BinaryRow>
source
- The input view from which to read the record.target
- The target output view to which to write the record.IOException
- Thrown if any of the two views raises an exception.public boolean equals(Object obj)
equals
in class TypeSerializer<BinaryRow>
public int hashCode()
hashCode
in class TypeSerializer<BinaryRow>
public TypeSerializerSnapshot<BinaryRow> snapshotConfiguration()
TypeSerializer
The snapshot of the TypeSerializer is supposed to contain all information that affects the serialization format of the serializer. The snapshot serves two purposes: First, to reproduce the serializer when the checkpoint/savepoint is restored, and second, to check whether the serialization format is compatible with the serializer used in the restored program.
IMPORTANT: TypeSerializerSnapshots changed after Flink 1.6. Serializers implemented against Flink versions up to 1.6 should still work, but adjust to new model to enable state evolution and be future-proof. See the class-level comments, section "Upgrading TypeSerializers to the new TypeSerializerSnapshot model" for details.
snapshotConfiguration
in class TypeSerializer<BinaryRow>
null
).TypeSerializerSnapshot.resolveSchemaCompatibility(TypeSerializer)
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.