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