Github user davies commented on a diff in the pull request: https://github.com/apache/spark/pull/11578#discussion_r56201279 --- Diff: core/src/main/scala/org/apache/spark/util/random/RandomSampler.scala --- @@ -274,11 +333,76 @@ class GapSamplingIterator[T: ClassTag]( } private[spark] -class GapSamplingReplacementIterator[T: ClassTag]( - var data: Iterator[T], +class GapSampling( f: Double, rng: Random = RandomSampler.newDefaultRNG, - epsilon: Double = RandomSampler.rngEpsilon) extends Iterator[T] { + epsilon: Double = RandomSampler.rngEpsilon) extends Serializable { + + require(f > 0.0 && f < 1.0, s"Sampling fraction ($f) must reside on open interval (0, 1)") + require(epsilon > 0.0, s"epsilon ($epsilon) must be > 0") + + private val lnq = math.log1p(-f) + + /** Return true if the next item should be sampled. Otherwise, return false. */ + def sample(): Boolean = { --- End diff -- Should this return int (to be consistent with others)?
--- 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