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 TypeMethodDescriptionboolean
decodeToIterable
(List<T> decodedElements) Builds an instance ofIterableT
, this coder's associatedIterable
-like subtype, from a list of decoded elements.Returns theTypeDescriptor
for 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.void
List 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, registerByteSizeObserver
Methods inherited from class org.apache.beam.sdk.coders.StructuredCoder
equals, getComponents, hashCode, toString
Methods 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:IterableLikeCoder
Builds 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:
decodeToIterable
in classIterableLikeCoder<T,
List<T>>
-
consistentWithEquals
public boolean consistentWithEquals()Description copied from class:Coder
Returnstrue
if thisCoder
is 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:
consistentWithEquals
in classCoder<List<T>>
-
structuralValue
Description copied from class:Coder
Returns an object with anObject.equals()
method that represents structural equality on the argument.For any two values
x
andy
of 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
null
should 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:
structuralValue
in classCoder<List<T>>
-
verifyDeterministic
List sizes are always known, so ListIterable may be deterministic while the general IterableLikeCoder is not.- Overrides:
verifyDeterministic
in classIterableLikeCoder<T,
List<T>> - Throws:
Coder.NonDeterministicException
- always. Encoding is not deterministic for the generalIterable
case, 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:Coder
Returns theTypeDescriptor
for the type encoded.- Overrides:
getEncodedTypeDescriptor
in classCoder<List<T>>
-