K - the type of the keys of the KVs being transcodedV - the type of the values of the KVs being transcodedpublic class KvCoder<K,V> extends KvCoderBase<KV<K,V>>
Coder.Context, Coder.NonDeterministicException| Modifier and Type | Method and Description |
|---|---|
com.google.cloud.dataflow.sdk.util.CloudObject |
asCloudObject()
Returns the
CloudObject that represents this Coder. |
KV<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(KV<K,V> kv,
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(KV<K,V> exampleValue) |
Coder<K> |
getKeyCoder() |
Coder<V> |
getValueCoder() |
boolean |
isDeterministic()
Deprecated.
|
boolean |
isRegisterByteSizeObserverCheap(KV<K,V> kv,
Coder.Context context)
Returns whether both keyCoder and valueCoder are considered not expensive.
|
static <K,V> KvCoder<K,V> |
of(Coder<K> keyCoder,
Coder<V> valueCoder) |
static KvCoder<?,?> |
of(java.util.List<Coder<?>> components) |
void |
registerByteSizeObserver(KV<K,V> kv,
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. |
ofequals, getComponents, getEncodedElementByteSize, hashCode, toString, verifyDeterministic, verifyDeterministicpublic static <K,V> java.util.List<java.lang.Object> getInstanceComponents(KV<K,V> exampleValue)
public void encode(KV<K,V> kv, 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 KV<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()
Coder 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.
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<KV<K,V>>verifyDeterministic in class StandardCoder<KV<K,V>>Coder.NonDeterministicException - if this coder is not deterministic.public com.google.cloud.dataflow.sdk.util.CloudObject asCloudObject()
CoderCloudObject that represents this Coder.asCloudObject in interface Coder<KV<K,V>>asCloudObject in class StandardCoder<KV<K,V>>public boolean isRegisterByteSizeObserverCheap(KV<K,V> kv, Coder.Context context)
isRegisterByteSizeObserverCheap in interface Coder<KV<K,V>>isRegisterByteSizeObserverCheap in class StandardCoder<KV<K,V>>public void registerByteSizeObserver(KV<K,V> kv, com.google.cloud.dataflow.sdk.util.common.ElementByteSizeObserver observer, Coder.Context context) throws java.lang.Exception
registerByteSizeObserver in interface Coder<KV<K,V>>registerByteSizeObserver in class StandardCoder<KV<K,V>>java.lang.Exception