V - the type of the elements or values of the tagged thing, e.g., a PCollection<V>.public class TupleTag<V>
extends java.lang.Object
implements java.io.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>(){};
| Constructor and Description |
|---|
TupleTag()
Constructs a new
TupleTag, with a fresh unique id. |
TupleTag(java.lang.String id)
Constructs a new
TupleTag with the given id. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object that) |
java.lang.String |
getId()
Returns the id of this
TupleTag. |
java.lang.String |
getOutName(int outIndex)
If this
TupleTag is tagging output outputIndex of
a PTransform, returns the name that should be used by
default for the output. |
TypeDescriptor<V> |
getTypeDescriptor()
Returns a
TypeDescriptor capturing what is known statically
about the type of this TupleTag instance's most-derived
class. |
int |
hashCode() |
java.lang.String |
toString() |
public TupleTag()
TupleTag, with a fresh unique id.
This is the normal way TupleTags are constructed.
public TupleTag(java.lang.String id)
TupleTag with 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 of TupleTags are written in
separate modules and can only coordinate via ids rather than
shared TupleTag instances. Most of the time,
TupleTag() should be preferred.
public java.lang.String getId()
TupleTag.
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.
public java.lang.String getOutName(int outIndex)
TupleTag is tagging output outputIndex of
a PTransform, returns the name that should be used by
default for the output.public TypeDescriptor<V> getTypeDescriptor()
TypeDescriptor capturing what is known statically
about the type of this TupleTag instance's most-derived
class.
This is useful for a TupleTag constructed as an
instance of an anonymous subclass with a trailing {},
e.g., new TupleTag<SomeType>(){}.
public boolean equals(java.lang.Object that)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object