A coder for encoding Objects as row objects with a given schema.

This is particularly useful for cross-language interoperability, and is more efficient than the general object encoding scheme as the fields (and their types) are fixed and do not have to be encoded along with each individual element.

While RowCoders can be instantiated directly from a schema object, there is also the convenience method RowCoder.fromJSON() method that can infer a RowCoder from a prototypical example, e.g.

const my_row_coder = RowCoder.fromJSON({int_field: 0, str_field: ""});

Hierarchy

  • RowCoder

Implements

Constructors

Properties

components: Coder<any>[]
encodingPositions: number[]
encodingPositionsAreTrivial: boolean = true
encodingPositionsArgsSorted: number[]
fieldNames: string[]
fieldNullable: (undefined | boolean)[]
hasNullableFields: boolean
nFields: number
schema: Schema
URN: string = "beam:coder:row:v1"

Methods

  • Decode an element from an incoming stream of bytes.

    Parameters

    • reader: Reader

      a reader that interfaces the coder with the input byte stream

    • context: Context

      the context within which the element should be encoded

    Returns any

  • Encode an element into a stream of bytes.

    Parameters

    • element: any

      an element within a PCollection

    • writer: Writer

      a writer that interfaces the coder with the output byte stream.

    • context: Context

      the context within which the element should be encoded.

    Returns void

  • Convert this coder into its protocol buffer representation for the Runner API. A coder in protobuf format can be shared with other components such as Beam runners, SDK workers; and reconstructed into its runtime representation if necessary.

    Parameters

    • pipelineContext: ProtoContext

      a context that holds relevant pipeline attributes such as other coders already in the pipeline.

    Returns Coder

Generated using TypeDoc