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<Map<K,V>>
MapCoder encodes Maps.Coder.Context, Coder.NonDeterministicException| Modifier and Type | Method and Description |
|---|---|
Map<K,V> |
decode(InputStream inStream,
Coder.Context context)
Decodes a value of type
T from the given input stream in
the given context. |
void |
encode(Map<K,V> map,
OutputStream outStream,
Coder.Context context)
Encodes the given value of type
T onto the given output stream
in the given context. |
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> 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. |
Coder<K> |
getKeyCoder() |
Coder<V> |
getValueCoder() |
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(List<Coder<?>> components) |
void |
registerByteSizeObserver(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()
Not all maps have a deterministic encoding.
|
ofasCloudObject, consistentWithEquals, equals, getComponents, getEncodedElementByteSize, hashCode, isRegisterByteSizeObserverCheap, structuralValue, toString, verifyDeterministic, verifyDeterministicpublic static <K,V> MapCoder<K,V> of(Coder<K> keyCoder, Coder<V> valueCoder)
public static <K,V> List<Object> getInstanceComponents(Map<K,V> exampleValue)
null.public void encode(Map<K,V> map, OutputStream outStream, Coder.Context context) throws IOException, CoderException
CoderT onto the given output stream
in the given context.IOException - if writing to the OutputStream fails
for some reasonCoderException - if the value could not be encoded for some reasonpublic Map<K,V> decode(InputStream inStream, Coder.Context context) throws IOException, CoderException
CoderT from the given input stream in
the given context. Returns the decoded value.IOException - if reading from the InputStream fails
for some reasonCoderException - if the value could not be decoded for some reasonpublic 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.public void verifyDeterministic()
throws Coder.NonDeterministicException
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.public void registerByteSizeObserver(Map<K,V> map, com.google.cloud.dataflow.sdk.util.common.ElementByteSizeObserver observer, Coder.Context context) throws Exception
registerByteSizeObserver in interface Coder<Map<K,V>>registerByteSizeObserver in class StandardCoder<Map<K,V>>Exception