Coder (Google Cloud Dataflow SDK 1.9.0 API)

Interface Coder<T>

    • Method Detail

      • getCoderArguments

        List<? extends Coder<?>> getCoderArguments()
        If this is a Coder for a parameterized type, returns the list of Coders being used for each of the parameters, or returns null if this cannot be done or this is not a parameterized type.
      • asCloudObject asCloudObject()
        Returns the CloudObject that represents this Coder.
      • verifyDeterministic

        void verifyDeterministic()
                          throws Coder.NonDeterministicException
        Throw Coder.NonDeterministicException if the coding is not deterministic.

        In order for a Coder to be considered deterministic, the following must be true:

        • two values that compare as equal (via Object.equals() or Comparable.compareTo(), if supported) have the same encoding.
        • the Coder always produces a canonical encoding, which is the same for an instance of an object even if produced on different computers at different times.
        Coder.NonDeterministicException - if this coder is not deterministic.
      • consistentWithEquals

        boolean consistentWithEquals()
        Returns true if this Coder is injective with respect to Object.equals(java.lang.Object).

        Whenever the encoded bytes of two values are equal, then the original values are equal according to Objects.equals(). Note that this is well-defined for null.

        This condition is most notably false for arrays. More generally, this condition is false whenever equals() compares object identity, rather than performing a semantic/structural comparison.

      • structuralValue

        Object structuralValue(T value)
                        throws Exception
        Returns an object with an Object.equals() method that represents structural equality on the argument.

        For any two values x and y of type T, if their encoded bytes are the same, then it must be the case that structuralValue(x).equals(@code structuralValue(y).

        Most notably:

        • The structural value for an array coder should perform a structural comparison of the contents of the arrays, rather than the default behavior of comparing according to object identity.
        • The structural value for a coder accepting null should be a proper object with an equals() method, even if the input value is null.

        See also consistentWithEquals().

      • registerByteSizeObserver

        void registerByteSizeObserver(T value,
                                      Coder.Context context)
                               throws Exception
        Notifies the ElementByteSizeObserver about the byte size of the encoded value using this Coder.

        Not intended to be called by user code, but instead by PipelineRunner implementations.

      • getEncodingId

        String getEncodingId()
        An identifier for the binary format written by encode(T,,

        This value, along with the fully qualified class name, forms an identifier for the binary format of this coder. Whenever this value changes, the new encoding is considered incompatible with the prior format: It is presumed that the prior version of the coder will be unable to correctly read the new format and the new version of the coder will be unable to correctly read the old format.

        If the format is changed in a backwards-compatible way (the Coder can still accept data from the prior format), such as by adding optional fields to a Protocol Buffer or Avro definition, and you want Dataflow to understand that the new coder is compatible with the prior coder, this value must remain unchanged. It is then the responsibility of decode(, to correctly read data from the prior format.

Send feedback about...

Cloud Dataflow