public class PTuple extends Object
PTuple is an immutable tuple of
heterogeneously-typed values, "keyed" by TupleTags.
PTuples can be created and accessed like follows:
String v1 = ...;
Integer v2 = ...;
Iterable<String> v3 = ...;
// Create TupleTags for each of the values to put in the
// PTuple (the type of the TupleTag enables tracking the
// static type of each of the values in the PTuple):
TupleTag<String> tag1 = new TupleTag<>();
TupleTag<Integer> tag2 = new TupleTag<>();
TupleTag<Iterable<String>> tag3 = new TupleTag<>();
// Create a PTuple with three values:
PTuple povs =
PTuple.of(tag1, v1)
.and(tag2, v2)
.and(tag3, v3);
// Create an empty PTuple:
Pipeline p = ...;
PTuple povs2 = PTuple.empty(p);
// Get values out of a PTuple, using the same tags
// that were used to put them in:
Integer vX = povs.get(tag2);
String vY = povs.get(tag1);
Iterable<String> vZ = povs.get(tag3);
// Get a map of all values in a PTuple:
Map<TupleTag<?>, ?> allVs = povs.getAll();
| Modifier and Type | Method and Description |
|---|---|
<V> PTuple |
and(TupleTag<V> tag,
V value)
Returns a new PTuple that has all the values and
tags of this PTuple plus the given value and tag.
|
static PTuple |
empty()
Returns an empty PTuple.
|
<V> V |
get(TupleTag<V> tag)
Returns the value with the given tag in this
PTuple.
|
Map<TupleTag<?>,?> |
getAll()
Returns an immutable Map from TupleTag to corresponding
value, for all the members of this PTuple.
|
<V> boolean |
has(TupleTag<V> tag)
Returns whether this PTuple contains a value with
the given tag.
|
boolean |
isEmpty()
Returns true if this
PTuple is empty. |
static <V> PTuple |
of(TupleTag<V> tag,
V value)
Returns a singleton PTuple containing the given
value keyed by the given TupleTag.
|
static PTuple |
ofInternal(Map<TupleTag<?>,?> valueMap)
Returns a PTuple with each of the given tags mapping
to the corresponding value.
|
public static PTuple empty()
Longer PTuples can be created by calling
and(com.google.cloud.dataflow.sdk.values.TupleTag<V>, V) on the result.
public static <V> PTuple of(TupleTag<V> tag, V value)
Longer PTuples can be created by calling
and(com.google.cloud.dataflow.sdk.values.TupleTag<V>, V) on the result.
public <V> PTuple and(TupleTag<V> tag, V value)
The given TupleTag should not already be mapped to a value in this PTuple.
public <V> boolean has(TupleTag<V> tag)
public boolean isEmpty()
PTuple is empty.public <V> V get(TupleTag<V> tag)
!has(tag).public Map<TupleTag<?>,?> getAll()