MapCoder (Google Cloud Dataflow SDK 1.9.1 API)

Google Cloud Dataflow SDK for Java, version 1.9.1

Class MapCoder<K,V>

  • Type Parameters:
    K - the type of the keys of the KVs being transcoded
    V - the type of the values of the KVs being transcoded
    All Implemented Interfaces:
    Coder<Map<K,V>>, Serializable

    public class MapCoder<K,V>
    extends MapCoderBase<Map<K,V>>
    A Coder for Maps that encodes them according to provided coders for keys and values.
    See Also:
    Serialized Form
    • Method Detail

      • of

        public static <K,V> MapCoder<K,V> of(Coder<K> keyCoder,
                                             Coder<V> valueCoder)
        Produces a MapCoder with the given keyCoder and valueCoder.
      • getInstanceComponents

        public static <K,V> List<Object> getInstanceComponents(Map<K,V> exampleValue)
        Returns the key and value for an arbitrary element of this map, if it is non-empty, otherwise returns null.
      • getKeyCoder

        public Coder<K> getKeyCoder()
      • getValueCoder

        public Coder<V> getValueCoder()
      • getCoderArguments

        public 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.
        a List containing the key coder at index 0 at the and value coder at index 1.
      • verifyDeterministic

        public 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.

        NonDeterministicException - always. Not all maps have a deterministic encoding. For example, HashMap comparison does not depend on element order, so two HashMap instances may be equal but produce different encodings.
        Coder.NonDeterministicException - if this coder is not deterministic.