K - the type of the keys of the KVs being transcodedV - the type of the values of the KVs being transcodedpublic class MapCoder<K,V> extends MapCoderBase<java.util.Map<K,V>>
Coder.Context, Coder.NonDeterministicException| Modifier and Type | Method and Description |
|---|---|
java.util.Map<K,V> |
decode(java.io.InputStream inStream,
Coder.Context context)
Decodes a value of type
T from the given input stream in
the given context. |
void |
encode(java.util.Map<K,V> map,
java.io.OutputStream outStream,
Coder.Context context)
Encodes the given value of type
T onto the given output stream
in the given context. |
java.util.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. |
static <K,V> java.util.List<java.lang.Object> |
getInstanceComponents(java.util.Map<K,V> exampleValue)
Returns the key and value for an arbitrary element of this map,
if it is non-empty, otherwise returns
null. |
Coder<K> |
getKeyCoder() |
Coder<V> |
getValueCoder() |
boolean |
isDeterministic()
Deprecated.
|
static <K,V> MapCoder<K,V> |
of(Coder<K> keyCoder,
Coder<V> valueCoder)
Produces a MapCoder with the given keyCoder and valueCoder.
|
static MapCoder<?,?> |
of(java.util.List<Coder<?>> components) |
void |
registerByteSizeObserver(java.util.Map<K,V> map,
com.google.cloud.dataflow.sdk.util.common.ElementByteSizeObserver observer,
Coder.Context context)
Notifies ElementByteSizeObserver about the byte size of the
encoded value using this coder.
|
void |
verifyDeterministic()
Throw
Coder.NonDeterministicException if the coding is not deterministic. |
ofasCloudObject, equals, getComponents, getEncodedElementByteSize, hashCode, isRegisterByteSizeObserverCheap, toString, verifyDeterministic, verifyDeterministicpublic static <K,V> MapCoder<K,V> of(Coder<K> keyCoder, Coder<V> valueCoder)
public static <K,V> java.util.List<java.lang.Object> getInstanceComponents(java.util.Map<K,V> exampleValue)
null.public void encode(java.util.Map<K,V> map, java.io.OutputStream outStream, Coder.Context context) throws java.io.IOException, CoderException
CoderT onto the given output stream
in the given context.java.io.IOException - if writing to the OutputStream fails
for some reasonCoderException - if the value could not be encoded for some reasonpublic java.util.Map<K,V> decode(java.io.InputStream inStream, Coder.Context context) throws java.io.IOException, CoderException
CoderT from the given input stream in
the given context. Returns the decoded value.java.io.IOException - if reading from the InputStream fails
for some reasonCoderException - if the value could not be decoded for some reasonpublic java.util.List<? extends Coder<?>> getCoderArguments()
CoderCoder 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.@Deprecated public boolean isDeterministic()
For example, HashMap comparison does not depend on element order, so two HashMap instances may be equal but produce different encodings.
public void verifyDeterministic()
throws Coder.NonDeterministicException
CoderCoder.NonDeterministicException if the coding is not deterministic.
In order for a Coder to be considered deterministic,
the following must be true:
Object.equals()
or Comparable.compareTo(), if supported), have the same
encoding.
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.
verifyDeterministic in interface Coder<java.util.Map<K,V>>verifyDeterministic in class StandardCoder<java.util.Map<K,V>>Coder.NonDeterministicException - if this coder is not deterministic.public void registerByteSizeObserver(java.util.Map<K,V> map, com.google.cloud.dataflow.sdk.util.common.ElementByteSizeObserver observer, Coder.Context context) throws java.lang.Exception
registerByteSizeObserver in interface Coder<java.util.Map<K,V>>registerByteSizeObserver in class StandardCoder<java.util.Map<K,V>>java.lang.Exception