Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17898#discussion_r115210488
  
    --- Diff: core/src/main/scala/org/apache/spark/rdd/CartesianRDD.scala ---
    @@ -72,8 +72,10 @@ class CartesianRDD[T: ClassTag, U: ClassTag](
     
       override def compute(split: Partition, context: TaskContext): 
Iterator[(T, U)] = {
         val currSplit = split.asInstanceOf[CartesianPartition]
    -    for (x <- rdd1.iterator(currSplit.s1, context);
    -         y <- rdd2.iterator(currSplit.s2, context)) yield (x, y)
    +    val groupSize = 500;
    +    for (x <- rdd1.iterator(currSplit.s1, context).grouped(groupSize);
    +         y <- rdd2.iterator(currSplit.s2, context).grouped(groupSize);
    --- End diff --
    
    Pardon, doesn't this change the type of the result? you're iterating over 
groupings not elements, and emitting pairs of groups. As in below, but maybe 
I'm missing something.
    
    ```
    scala> val foo = List(1,2,3)
    foo: List[Int] = List(1, 2, 3)
    
    scala> val bar = List(4,5,6)
    bar: List[Int] = List(4, 5, 6)
    
    scala> for (x <- foo; y <- bar) yield (x, y)
    res0: List[(Int, Int)] = List((1,4), (1,5), (1,6), (2,4), (2,5), (2,6), 
(3,4), (3,5), (3,6))
    
    scala> (for (x <- foo.grouped(2); y <- bar.grouped(2)) yield (x, 
y)).foreach(println)
    (List(1, 2),List(4, 5))
    (List(1, 2),List(6))
    (List(3),List(4, 5))
    (List(3),List(6))
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to