* The right-side table of the join, whose contents will be fully
* read into memory
* @return A table keyed on the join key, containing pairs of joined values
*/
public static <K, U, V> PTable<K, Pair<U, V>> join(PTable<K, U> left, PTable<K, V> right) {
PTypeFamily tf = left.getTypeFamily();
Iterable<Pair<K, V>> iterable = right.materialize();
if (iterable instanceof MaterializableIterable) {
MaterializableIterable<Pair<K, V>> mi = (MaterializableIterable<Pair<K, V>>) iterable;
MapsideJoinDoFn<K, U, V> mapJoinDoFn = new MapsideJoinDoFn<K, U, V>(mi.getPath().toString(),
right.getPType());
ParallelDoOptions.Builder optionsBuilder = ParallelDoOptions.builder();
if (mi.isSourceTarget()) {
optionsBuilder.sourceTargets((SourceTarget) mi.getSource());
}
return left.parallelDo("mapjoin", mapJoinDoFn,
tf.tableOf(left.getKeyType(), tf.pairs(left.getValueType(), right.getValueType())),
optionsBuilder.build());
} else { // in-memory pipeline
return left.parallelDo(new InMemoryJoinFn<K, U, V>(iterable),
tf.tableOf(left.getKeyType(), tf.pairs(left.getValueType(), right.getValueType())));
}
}