Package org.apache.beam.sdk.coders
Class SetCoder<T>
java.lang.Object
org.apache.beam.sdk.coders.Coder<Set<T>>
org.apache.beam.sdk.coders.StructuredCoder<Set<T>>
org.apache.beam.sdk.coders.IterableLikeCoder<T,Set<T>>
org.apache.beam.sdk.coders.SetCoder<T>
- Type Parameters:
T
- the type of the elements of the set
- All Implemented Interfaces:
Serializable
A
SetCoder
encodes any Set
using the format of IterableLikeCoder
. The
elements may not be in a deterministic order, depending on the Set
implementation.- 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 TypeMethodDescriptiondecodeToIterable
(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> SetCoder
<T> Produces aSetCoder
with the givenelementCoder
.void
ThrowCoder.NonDeterministicException
if the coding is not deterministic.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
consistentWithEquals, decode, encode, getEncodedElementByteSize, getEncodedElementByteSizeUsingCoder, structuralValue, verifyDeterministic, verifyDeterministic
-
Constructor Details
-
SetCoder
-
-
Method Details
-
of
Produces aSetCoder
with the givenelementCoder
. -
verifyDeterministic
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.
- Overrides:
verifyDeterministic
in classIterableLikeCoder<T,
Set<T>> - Throws:
Coder.NonDeterministicException
- always. Sets are not ordered, but they are encoded in the order of an arbitrary iteration.
- two values that compare as equal (via
-
getEncodedTypeDescriptor
Description copied from class:Coder
Returns theTypeDescriptor
for the type encoded.- Overrides:
getEncodedTypeDescriptor
in classCoder<Set<T>>
-
decodeToIterable
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,
Set<T>> - Returns:
- A new
Set
built from the elements in theList
decoded byIterableLikeCoder
.
-