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

    https://github.com/apache/spark/pull/6454#discussion_r31267472
  
    --- Diff: core/src/main/scala/org/apache/spark/rdd/RDD.scala ---
    @@ -580,7 +580,18 @@ abstract class RDD[T: ClassTag](
        * elements (a, b) where a is in `this` and b is in `other`.
        */
       def cartesian[U: ClassTag](other: RDD[U]): RDD[(T, U)] = withScope {
    -    new CartesianRDD(sc, this, other)
    +    val numPartitions = {
    +      val numExecutors = System.getProperty("spark.executor.instances")
    +
    +      if (numExecutors != null) {
    +        numExecutors.toInt
    +      } else {
    +        sc.defaultMinPartitions
    +      }
    +    }
    +    val coalesced = coalesce(numPartitions, shuffle = true)
    +    val coalescedOther = other.coalesce(numPartitions, shuffle = true)
    +    new CartesianRDD(sc, coalesced, coalescedOther)
    --- End diff --
    
    Sorry I think I was vague when I originally brought up `coalesce`.  I had 
intended for it to only be a suggestion to the user, included in the docs, as 
you note.  I think its really hard to guess how to do the coalescing.  In fact, 
I just realized there is a downside to coalescing that I hadn't thought of 
earlier -- the more you coalesce, then it becomes more likely that you *cannot* 
store all of `rdd2.iterator` in memory.


---
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