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| 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()
Encoding is not deterministic for the general Iterable case, as it depends
upon the type of iterable.
|
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.
|
asCloudObject, equals, getComponents, getEncodedElementByteSize, hashCode, toStringprotected 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.public boolean isDeterministic()
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