Class TupleTag<V>
- Type Parameters:
V- the type of the elements or values of the tagged thing, e.g., aPCollection<V>.
- All Implemented Interfaces:
Serializable
TupleTag is a typed tag to use as the key of a heterogeneously typed tuple, like PCollectionTuple. Its generic type parameter allows tracking the static type of things stored in
tuples.
To aid in assigning default Coders for results of a
ParDo, an output TupleTag should be instantiated with an extra {} so it
is an instance of an anonymous subclass without generic type parameters. Input TupleTags require no such extra instantiation (although it doesn't hurt). For example:
TupleTag<SomeType> inputTag = new TupleTag<>();
TupleTag<SomeOtherType> outputTag = new TupleTag<SomeOtherType>(){};
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleangetId()Returns the id of thisTupleTag.getOutName(int outIndex) If thisTupleTagis tagging outputoutputIndexof aPTransform, returns the name that should be used by default for the output.Returns aTypeDescriptorcapturing what is known statically about the type of thisTupleTaginstance's most-derived class.inthashCode()toString()
-
Constructor Details
-
TupleTag
public TupleTag()Constructs a newTupleTag, with a fresh unique id.This is the normal way
TupleTags are constructed. -
TupleTag
Constructs a newTupleTagwith the given id.It is up to the user to ensure that two
TupleTags with the same id actually mean the same tag and carry the same generic type parameter. Violating this invariant can lead to hard-to-diagnose runtime type errors. Consequently, this operation should be used very sparingly, such as when the producer and consumer ofTupleTags are written in separate modules and can only coordinate via ids rather than sharedTupleTaginstances. Most of the time,TupleTag()should be preferred.
-
-
Method Details
-
getId
Returns the id of thisTupleTag.Two
TupleTags with the same id are considered equal.TupleTags are not ordered, i.e., the class does not implement Comparable interface. TupleTags implement equals and hashCode, making them suitable for use as keys in HashMap and HashSet. -
getOutName
If thisTupleTagis tagging outputoutputIndexof aPTransform, returns the name that should be used by default for the output. -
getTypeDescriptor
Returns aTypeDescriptorcapturing what is known statically about the type of thisTupleTaginstance's most-derived class.This is useful for a
TupleTagconstructed as an instance of an anonymous subclass with a trailing{}, e.g.,new TupleTag<SomeType>(){}. -
equals
-
hashCode
public int hashCode() -
toString
-