Google Cloud Dataflow SDK for Java, version 1.9.1
com.google.cloud.dataflow.sdk.coders
Class SetCoder<T>
- java.lang.Object
-
- com.google.cloud.dataflow.sdk.coders.StandardCoder<IterableT>
-
- com.google.cloud.dataflow.sdk.coders.IterableLikeCoder<T,Set<T>>
-
- com.google.cloud.dataflow.sdk.coders.SetCoder<T>
-
- Type Parameters:
T
- the type of the elements of the set
- All Implemented Interfaces:
- Coder<Set<T>>, Serializable
public class SetCoder<T> extends IterableLikeCoder<T,Set<T>>
ASetCoder
encodes anySet
using the format ofIterableLikeCoder
. The elements may not be in a deterministic order, depending on theSet
implementation.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.cloud.dataflow.sdk.coders.Coder
Coder.Context, Coder.NonDeterministicException
-
-
Constructor Summary
Constructors Modifier Constructor and Description protected
SetCoder(Coder<T> elemCoder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description protected Set<T>
decodeToIterable(List<T> decodedElements)
Builds an instance ofIterableT
, this coder's associatedIterable
-like subtype, from a list of decoded elements.static <T> List<Object>
getInstanceComponents(Set<T> exampleValue)
Returns the first element in this set if it is non-empty, otherwise returnsnull
.static <T> SetCoder<T>
of(Coder<T> elementCoder)
Produces aSetCoder
with the givenelementCoder
.static SetCoder<?>
of(List<Object> components)
Dynamically typed constructor for JSON deserialization.void
verifyDeterministic()
ThrowCoder.NonDeterministicException
if the coding is not deterministic.-
Methods inherited from class com.google.cloud.dataflow.sdk.coders.IterableLikeCoder
decode, encode, getCoderArguments, getElemCoder, getInstanceComponentsHelper, isRegisterByteSizeObserverCheap, registerByteSizeObserver
-
Methods inherited from class com.google.cloud.dataflow.sdk.coders.StandardCoder
asCloudObject, consistentWithEquals, equals, getAllowedEncodings, getComponents, getEncodedElementByteSize, getEncodingId, hashCode, structuralValue, toString, verifyDeterministic, verifyDeterministic
-
-
-
-
Method Detail
-
of
public static <T> SetCoder<T> of(Coder<T> elementCoder)
Produces aSetCoder
with the givenelementCoder
.
-
of
public static SetCoder<?> of(List<Object> components)
Dynamically typed constructor for JSON deserialization.
-
verifyDeterministic
public void verifyDeterministic() throws Coder.NonDeterministicException
ThrowCoder.NonDeterministicException
if the coding is not deterministic.In order for a
Coder
to be considered deterministic, the following must be true:- two values that compare as equal (via
Object.equals()
orComparable.compareTo()
, if supported) have the same encoding. - the
Coder
always produces a canonical encoding, which is the same for an instance of an object even if produced on different computers at different times.
- Specified by:
verifyDeterministic
in interfaceCoder<Set<T>>
- Overrides:
verifyDeterministic
in classIterableLikeCoder<T,Set<T>>
- Throws:
NonDeterministicException
- always. Sets are not ordered, but they are encoded in the order of an arbitrary iteration.Coder.NonDeterministicException
- if this coder is not deterministic.
- two values that compare as equal (via
-
getInstanceComponents
public static <T> List<Object> getInstanceComponents(Set<T> exampleValue)
Returns the first element in this set if it is non-empty, otherwise returnsnull
.
-
decodeToIterable
protected final Set<T> decodeToIterable(List<T> decodedElements)
Builds an instance ofIterableT
, this coder's associatedIterable
-like subtype, from a list of decoded elements.- Specified by:
decodeToIterable
in classIterableLikeCoder<T,Set<T>>
- Returns:
- A new
Set
built from the elements in theList
decoded byIterableLikeCoder
.
-
-