Class ListCoder<T>
- Type Parameters:
T- the type of the elements of the Lists being transcoded
- All Implemented Interfaces:
Serializable
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.beam.sdk.coders.Coder
Coder.Context, Coder.NonDeterministicException -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleandecodeToIterable(List<T> decodedElements) Builds an instance ofIterableT, this coder's associatedIterable-like subtype, from a list of decoded elements.Returns theTypeDescriptorfor the type encoded.static <T> ListCoder<T> structuralValue(List<T> values) Returns an object with anObject.equals()method that represents structural equality on the argument.voidList sizes are always known, so ListIterable may be deterministic while the general IterableLikeCoder is not.Methods inherited from class org.apache.beam.sdk.coders.IterableLikeCoder
decode, decodeToIterable, encode, getCoderArguments, getElemCoder, isRegisterByteSizeObserverCheap, registerByteSizeObserverMethods inherited from class org.apache.beam.sdk.coders.StructuredCoder
equals, getComponents, hashCode, toStringMethods inherited from class org.apache.beam.sdk.coders.Coder
decode, encode, getEncodedElementByteSize, getEncodedElementByteSizeUsingCoder, verifyDeterministic, verifyDeterministic
-
Constructor Details
-
ListCoder
-
-
Method Details
-
of
-
decodeToIterable
Description copied from class:IterableLikeCoderBuilds an instance ofIterableT, this coder's associatedIterable-like subtype, from a list of decoded elements.Override
IterableLikeCoder.decodeToIterable(List, long, InputStream)if you need access to the terminator value and theInputStream.- Specified by:
decodeToIterablein classIterableLikeCoder<T,List<T>>
-
consistentWithEquals
public boolean consistentWithEquals()Description copied from class:CoderReturnstrueif thisCoderis injective with respect toObject.equals(java.lang.Object).Whenever the encoded bytes of two values are equal, then the original values are equal according to
Objects.equals(). Note that this is well-defined fornull.This condition is most notably false for arrays. More generally, this condition is false whenever
equals()compares object identity, rather than performing a semantic/structural comparison.By default, returns false.
- Overrides:
consistentWithEqualsin classCoder<List<T>>
-
structuralValue
Description copied from class:CoderReturns an object with anObject.equals()method that represents structural equality on the argument.For any two values
xandyof typeT, if their encoded bytes are the same, then it must be the case thatstructuralValue(x).equals(structuralValue(y)).Most notably:
- The structural value for an array coder should perform a structural comparison of the contents of the arrays, rather than the default behavior of comparing according to object identity.
- The structural value for a coder accepting
nullshould be a proper object with anequals()method, even if the input value isnull.
See also
Coder.consistentWithEquals().By default, if this coder is
Coder.consistentWithEquals(), and the value is not null, returns the provided object. Otherwise, encodes the value into abyte[], and returns an object that performs array equality on the encoded bytes.- Overrides:
structuralValuein classCoder<List<T>>
-
verifyDeterministic
List sizes are always known, so ListIterable may be deterministic while the general IterableLikeCoder is not.- Overrides:
verifyDeterministicin classIterableLikeCoder<T,List<T>> - Throws:
Coder.NonDeterministicException- always. Encoding is not deterministic for the generalIterablecase, as it depends upon the type of iterable. This may allow two objects to compare as equal while the encoding differs.
-
getEncodedTypeDescriptor
Description copied from class:CoderReturns theTypeDescriptorfor the type encoded.- Overrides:
getEncodedTypeDescriptorin classCoder<List<T>>
-