Class DequeCoder<T>
- java.lang.Object
-
- org.apache.beam.sdk.coders.Coder<T>
-
- org.apache.beam.sdk.coders.StructuredCoder<IterableT>
-
- org.apache.beam.sdk.coders.IterableLikeCoder<T,java.util.Deque<T>>
-
- org.apache.beam.sdk.coders.DequeCoder<T>
-
- Type Parameters:
T
- the type of the elements of the Deques being transcoded
- All Implemented Interfaces:
java.io.Serializable
public class DequeCoder<T> extends IterableLikeCoder<T,java.util.Deque<T>>
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.beam.sdk.coders.Coder
Coder.Context, Coder.NonDeterministicException
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DequeCoder(Coder<T> elemCoder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
consistentWithEquals()
protected java.util.Deque<T>
decodeToIterable(java.util.List<T> decodedElements)
Builds an instance ofIterableT
, this coder's associatedIterable
-like subtype, from a list of decoded elements.TypeDescriptor<java.util.Deque<T>>
getEncodedTypeDescriptor()
Returns theTypeDescriptor
for the type encoded.static <T> DequeCoder<T>
of(Coder<T> elemCoder)
java.lang.Object
structuralValue(java.util.Deque<T> values)
Returns an object with anObject.equals()
method that represents structural equality on the argument.void
verifyDeterministic()
Deque sizes are always known, so DequeIterable 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, verifyDeterministic, verifyDeterministic
-
-
-
-
Method Detail
-
of
public static <T> DequeCoder<T> of(Coder<T> elemCoder)
-
decodeToIterable
protected java.util.Deque<T> decodeToIterable(java.util.List<T> decodedElements)
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,java.util.Deque<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<java.util.Deque<T>>
-
structuralValue
public java.lang.Object structuralValue(java.util.Deque<T> values)
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<java.util.Deque<T>>
-
verifyDeterministic
public void verifyDeterministic() throws Coder.NonDeterministicException
Deque sizes are always known, so DequeIterable may be deterministic while the general IterableLikeCoder is not.- Overrides:
verifyDeterministic
in classIterableLikeCoder<T,java.util.Deque<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
public TypeDescriptor<java.util.Deque<T>> getEncodedTypeDescriptor()
Description copied from class:Coder
Returns theTypeDescriptor
for the type encoded.- Overrides:
getEncodedTypeDescriptor
in classCoder<java.util.Deque<T>>
-
-