Class PagedTypeSerializer<T>

java.lang.Object
org.apache.flink.api.common.typeutils.TypeSerializer<T>
org.apache.flink.table.runtime.typeutils.PagedTypeSerializer<T>
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AbstractRowDataSerializer, WindowKeySerializer

@Internal public abstract class PagedTypeSerializer<T> extends org.apache.flink.api.common.typeutils.TypeSerializer<T>
A type serializer which provides paged serialize and deserialize methods.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract T
    deserializeFromPages(org.apache.flink.runtime.memory.AbstractPagedInputView source)
    De-serializes a record from the given source paged input view.
    abstract T
    deserializeFromPages(T reuse, org.apache.flink.runtime.memory.AbstractPagedInputView source)
    abstract T
    mapFromPages(T reuse, org.apache.flink.runtime.memory.AbstractPagedInputView source)
    Map a reused record from the given source paged input view.
    abstract int
    serializeToPages(T record, org.apache.flink.runtime.memory.AbstractPagedOutputView target)
    Serializes the given record to the given target paged output view.
    abstract void
    skipRecordFromPages(org.apache.flink.runtime.memory.AbstractPagedInputView source)
    Skip over bytes of one record from the paged input view, discarding the skipped bytes.

    Methods inherited from class org.apache.flink.api.common.typeutils.TypeSerializer

    copy, copy, copy, createInstance, deserialize, deserialize, duplicate, equals, getLength, hashCode, isImmutableType, serialize, snapshotConfiguration

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PagedTypeSerializer

      public PagedTypeSerializer()
  • Method Details

    • serializeToPages

      public abstract int serializeToPages(T record, org.apache.flink.runtime.memory.AbstractPagedOutputView target) throws IOException
      Serializes the given record to the given target paged output view. Some implementations may skip some bytes if current page does not have enough space left, .e.g BinaryRowData.
      Parameters:
      record - The record to serialize.
      target - The output view to write the serialized data to.
      Returns:
      Returns the skipped number of bytes.
      Throws:
      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.
    • deserializeFromPages

      public abstract T deserializeFromPages(org.apache.flink.runtime.memory.AbstractPagedInputView source) throws IOException
      De-serializes a record from the given source paged input view. For consistency with serialize format, some implementations may need to skip some bytes of source before de-serializing, .e.g BinaryRowData. 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 mapFromPages(T, AbstractPagedInputView).
      Parameters:
      source - The input view from which to read the data.
      Returns:
      The de-serialized element.
      Throws:
      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.
    • deserializeFromPages

      public abstract T deserializeFromPages(T reuse, org.apache.flink.runtime.memory.AbstractPagedInputView source) throws IOException
      Throws:
      IOException
    • mapFromPages

      public abstract T mapFromPages(T reuse, org.apache.flink.runtime.memory.AbstractPagedInputView source) throws IOException
      Map a reused record from the given source paged input view. This method provides a possibility to achieve zero copy when de-serializing. You can either choose copy or not copy the content read from source, but we encourage to make it zero copy.

      If you choose the zero copy way, you have to deal with the lifecycle of the pages properly.

      Parameters:
      reuse - the reused record to be mapped
      source - The input view from which to read the data.
      Returns:
      The mapped record.
      Throws:
      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.
    • skipRecordFromPages

      public abstract void skipRecordFromPages(org.apache.flink.runtime.memory.AbstractPagedInputView source) throws IOException
      Skip over bytes of one record from the paged input view, discarding the skipped bytes.
      Throws:
      IOException