Google Cloud Dataflow SDK for Java, version 1.9.1
Class TupleTag<V>
- java.lang.Object
-
- com.google.cloud.dataflow.sdk.values.TupleTag<V>
-
- Type Parameters:
V
- the type of the elements or values of the tagged thing, e.g., aPCollection<V>
.
- All Implemented Interfaces:
- Serializable
public class TupleTag<V> extends Object implements Serializable
ATupleTag
is a typed tag to use as the key of a heterogeneously typed tuple, likePCollectionTuple
. Its generic type parameter allows tracking the static type of things stored in tuples.To aid in assigning default
Coders
for results of side outputs ofParDo
, an outputTupleTag
should be instantiated with an extra{}
so it is an instance of an anonymous subclass without generic type parameters. InputTupleTags
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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description TupleTag()
Constructs a newTupleTag
, with a fresh unique id.TupleTag(String id)
Constructs a newTupleTag
with the given id.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description com.google.cloud.dataflow.sdk.util.CloudObject
asCloudObject()
boolean
equals(Object that)
String
getId()
Returns the id of thisTupleTag
.String
getOutName(int outIndex)
If thisTupleTag
is tagging outputoutputIndex
of aPTransform
, returns the name that should be used by default for the output.TypeDescriptor<V>
getTypeDescriptor()
Returns aTypeDescriptor
capturing what is known statically about the type of thisTupleTag
instance's most-derived class.int
hashCode()
String
toString()
-
-
-
Constructor Detail
-
TupleTag
public TupleTag()
Constructs a newTupleTag
, with a fresh unique id.This is the normal way
TupleTag
s are constructed.
-
TupleTag
public TupleTag(String id)
Constructs a newTupleTag
with the given id.It is up to the user to ensure that two
TupleTag
s 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 ofTupleTag
s are written in separate modules and can only coordinate via ids rather than sharedTupleTag
instances. Most of the time,TupleTag()
should be preferred.
-
-
Method Detail
-
getId
public String getId()
Returns the id of thisTupleTag
.Two
TupleTag
s with the same id are considered equal.TupleTag
s 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
public String getOutName(int outIndex)
If thisTupleTag
is tagging outputoutputIndex
of aPTransform
, returns the name that should be used by default for the output.
-
getTypeDescriptor
public TypeDescriptor<V> getTypeDescriptor()
Returns aTypeDescriptor
capturing what is known statically about the type of thisTupleTag
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>(){}
.
-
asCloudObject
public com.google.cloud.dataflow.sdk.util.CloudObject asCloudObject()
-
-