T - the type of the elements of the Iterables being transcodedIT - the type of the Iterables being transcodedpublic abstract class IterableLikeCoder<T,IT extends java.lang.Iterable<T>> extends StandardCoder<IT>
Coder.Context, Coder.NonDeterministicException| Modifier | Constructor and Description |
|---|---|
protected |
IterableLikeCoder(Coder<T> elementCoder) |
| Modifier and Type | Method and Description |
|---|---|
IT |
decode(java.io.InputStream inStream,
Coder.Context context)
Decodes a value of type
T from the given input stream in
the given context. |
protected abstract IT |
decodeToIterable(java.util.List<T> decodedElements)
Builds an instance of the coder's associated
Iterable from a list
of decoded elements. |
void |
encode(IT iterable,
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. |
Coder<T> |
getElemCoder() |
protected static <T,IT extends java.lang.Iterable<T>> |
getInstanceComponentsHelper(IT exampleValue)
Returns the first element in this iterable-like if it is non-empty,
otherwise returns
null. |
boolean |
isDeterministic()
Deprecated.
|
boolean |
isRegisterByteSizeObserverCheap(IT iterable,
Coder.Context context)
Returns whether iterable can use lazy counting, since that
requires minimal extra computation.
|
void |
registerByteSizeObserver(IT iterable,
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. |
asCloudObject, equals, getComponents, getEncodedElementByteSize, hashCode, toString, verifyDeterministic, verifyDeterministicprotected abstract IT decodeToIterable(java.util.List<T> decodedElements)
Iterable from a list
of decoded elements. If IT is a supertype of List<T>, the
derived class implementation is permitted to return decodedElements
directly.protected static <T,IT extends java.lang.Iterable<T>> java.util.List<java.lang.Object> getInstanceComponentsHelper(IT exampleValue)
null.public void encode(IT iterable, 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 IT 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()
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<IT extends java.lang.Iterable<T>>verifyDeterministic in class StandardCoder<IT extends java.lang.Iterable<T>>Coder.NonDeterministicException - if this coder is not deterministic.public boolean isRegisterByteSizeObserverCheap(IT iterable, Coder.Context context)
isRegisterByteSizeObserverCheap in interface Coder<IT extends java.lang.Iterable<T>>isRegisterByteSizeObserverCheap in class StandardCoder<IT extends java.lang.Iterable<T>>public void registerByteSizeObserver(IT iterable, com.google.cloud.dataflow.sdk.util.common.ElementByteSizeObserver observer, Coder.Context context) throws java.lang.Exception
registerByteSizeObserver in interface Coder<IT extends java.lang.Iterable<T>>registerByteSizeObserver in class StandardCoder<IT extends java.lang.Iterable<T>>java.lang.Exception