Github user dusenberrymw commented on a diff in the pull request: https://github.com/apache/spark/pull/8112#discussion_r40273307 --- Diff: core/src/main/scala/org/apache/spark/util/random/StratifiedSamplingUtils.scala --- @@ -216,6 +216,35 @@ private[spark] object StratifiedSamplingUtils extends Logging { } /** + * Return the per partition sampling function used for partitioning a dataset without + * replacement. + * + * The sampling function has a unique seed per partition. + */ + def getBernoulliCellSamplingFunction[K, V](rdd: RDD[(K, V)], + lb: Map[K, Double], + ub: Map[K, Double], + seed: Long, + complement: Boolean = false): (Int, Iterator[(K, V)]) => Iterator[(K, V)] = { + (idx: Int, iter: Iterator[(K, V)]) => { + val rng = new RandomDataGenerator() + rng.reSeed(seed + idx) + + if (complement) { + iter.filter { t => --- End diff -- `t` is fine to use here, but it may be more readable to use `case (k, v)`.
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org