/** * Cogroup this table with another {@link LTable} with the same key type, collecting the set of values from * each side. */ default <U> LTable<K, Pair<Collection<V>, Collection<U>>> cogroup(LTable<K, U> other) { return factory().wrap(underlying().cogroup(other.underlying())); }
leftCross.cogroup(rightCross);
/** * Helper for building the artificial cross keys. This technique was taken from Pig's CROSS. */ private static class GFCross<V> extends DoFn<V, Pair<Pair<Integer, Integer>, V>>{ private final int constantField; private final int parallelism; private final Random r; public GFCross(int constantField, int parallelism) { this.constantField = constantField; this.parallelism = parallelism; this.r = new Random(); } public void process(V input, Emitter<Pair<Pair<Integer, Integer>, V>> emitter) { int c = r.nextInt(parallelism); if (constantField == 0) { for (int i = 0; i < parallelism; i++) { emitter.emit(Pair.of(Pair.of(c, i), input)); } } else { for (int i = 0; i < parallelism; i++) { emitter.emit(Pair.of(Pair.of(i, c), input)); } } } }