@Test public void testCartesianCollection() { ImmutableList<ImmutableList<Integer>> testCases = ImmutableList.of( ImmutableList.of(1, 2, 3, 4, 5), ImmutableList.<Integer>of(1, 2, 3), ImmutableList.<Integer>of()); for (int t1 = 0; t1 < testCases.size(); t1++) { ImmutableList<Integer> testCase1 = testCases.get(t1); for (int t2 = t1; t2 < testCases.size(); t2++) { ImmutableList<Integer> testCase2 = testCases.get(t2); PCollection<Integer> X = MemPipeline.typedCollectionOf(Writables.ints(), testCase1); PCollection<Integer> Y = MemPipeline.typedCollectionOf(Writables.ints(), testCase2); PCollection<Pair<Integer,Integer>> cross = Cartesian.cross(X, Y); HashSet<Pair<Integer, Integer>> crossSet = new HashSet<Pair<Integer, Integer>>(); for (Iterator<Pair<Integer, Integer>> i = cross.materialize().iterator(); i.hasNext(); ) { crossSet.add(i.next()); } assertEquals(crossSet.size(), testCase1.size() * testCase2.size()); for (int i = 0; i < testCase1.size(); i++) { for (int j = 0; j < testCase2.size(); j++) { assertTrue(crossSet.contains(Pair.of(testCase1.get(i), testCase2.get(j)))); } } } } }
public static <K1, K2, U, V> PTable<Pair<K1, K2>, Pair<U, V>> cross( PTable<K1, U> left, PTable<K2, V> right) { return cross(left, right, DEFAULT_PARALLELISM); }
Cartesian { public static <K1, K2, U, V> PTable<Pair<K1, K2>, Pair<U, V>> cross( PTable<K1, U> left, PTable<K2, V> right) { return cross(left, right, DEFAULT_PARALLELISM); } }
Cartesian { public static <K1, K2, U, V> PTable<Pair<K1, K2>, Pair<U, V>> cross( PTable<K1, U> left, PTable<K2, V> right) { return cross(left, right, DEFAULT_PARALLELISM); }  }
Cartesian { public static <K1, K2, U, V> PTable<Pair<K1, K2>, Pair<U, V>> cross( PTable<K1, U> left, PTable<K2, V> right) { return cross(left, right, DEFAULT_PARALLELISM); }  static PTable<Pair<K1, K2>, Pair<U, V>> cross(
      PTable<K1, U> left,
      PTable<K2, V> right); static PTable<Pair<K1, K2>, Pair<U, V>> cross(
      PTable<K1, U> left,
      PTable<K2, V> right,
      int parallelism); static PCollection<Pair<U, V>> cross(
      PCollection<U> left,
      PCollection<V> right); static PCollection<Pair<U, V>> cross(
      PCollection<U> left,
      PCollection<V> right,
      int parallelism); }
Cartesian { public static <K1, K2, U, V> PTable<Pair<K1, K2>, Pair<U, V>> cross( PTable<K1, U> left, PTable<K2, V> right) { return cross(left, right, DEFAULT_PARALLELISM); }  static PTable<Pair<K1, K2>, Pair<U, V>> cross(
      PTable<K1, U> left,
      PTable<K2, V> right); static PTable<Pair<K1, K2>, Pair<U, V>> cross(
      PTable<K1, U> left,
      PTable<K2, V> right,
      int parallelism); static PCollection<Pair<U, V>> cross(
      PCollection<U> left,
      PCollection<V> right); static PCollection<Pair<U, V>> cross(
      PCollection<U> left,
      PCollection<V> right,
      int parallelism);  }