Github user davies commented on a diff in the pull request: https://github.com/apache/spark/pull/11578#discussion_r57547718 --- Diff: core/src/main/scala/org/apache/spark/util/random/RandomSampler.scala --- @@ -107,21 +114,21 @@ class BernoulliCellSampler[T](lb: Double, ub: Double, complement: Boolean = fals override def setSeed(seed: Long): Unit = rng.setSeed(seed) + override def sample(): Int = { + if (ub - lb <= 0.0) { + if (complement) 1 else 0 + } else { + val x = rng.nextDouble() + val n = if ((x >= lb) && (x < ub)) 1 else 0 + if (complement) 1 - n else n + } + } + override def sample(items: Iterator[T]): Iterator[T] = { if (ub - lb <= 0.0) { if (complement) items else Iterator.empty --- End diff -- I think we don't need to optimize this corner case, it's fine to use the default `sample`
--- 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