Skip to content

Commit 60be09e

Browse files
committed
remove importance sampler
1 parent 9ee9992 commit 60be09e

File tree

2 files changed

+1
-27
lines changed

2 files changed

+1
-27
lines changed

core/src/main/scala/org/apache/spark/Partitioner.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@ package org.apache.spark
1919

2020
import java.io.{IOException, ObjectInputStream, ObjectOutputStream}
2121

22-
import org.apache.spark.util.random.{XORShiftRandom, SamplingUtils}
23-
2422
import scala.collection.mutable.ArrayBuffer
2523
import scala.reflect.{ClassTag, classTag}
2624
import scala.util.hashing.byteswap32
2725

2826
import org.apache.spark.rdd.RDD
2927
import org.apache.spark.serializer.JavaSerializer
3028
import org.apache.spark.util.{CollectionsUtils, Utils}
29+
import org.apache.spark.util.random.{XORShiftRandom, SamplingUtils}
3130

3231
/**
3332
* An object that defines how the elements in a key-value pair RDD are partitioned by key.

core/src/main/scala/org/apache/spark/util/random/RandomSampler.scala

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -106,28 +106,3 @@ class PoissonSampler[T](mean: Double) extends RandomSampler[T, T] {
106106

107107
override def clone = new PoissonSampler[T](mean)
108108
}
109-
110-
/**
111-
* :: DeveloperApi ::
112-
* A sampler selects items based on their importance scores defined in the keys.
113-
*
114-
* The importance score should be within range `[0, 1]`. Items with scores less than or equal to 0
115-
* would never get selected, while items with scores greater than or equal to 1 would always get
116-
* selected.
117-
*
118-
* @param ratio sampling probability
119-
* @tparam T item type
120-
*/
121-
@DeveloperApi
122-
class ImportanceSampler[T](ratio: Double) extends RandomSampler[(Double, T), (Double, T)] {
123-
124-
private[random] var rng: Random = new XORShiftRandom
125-
126-
override def setSeed(seed: Long) = rng.setSeed(seed)
127-
128-
override def sample(items: Iterator[(Double, T)]): Iterator[(Double, T)] = {
129-
items.filter(item => rng.nextDouble() < ratio)
130-
}
131-
132-
override def clone = new ImportanceSampler[T](ratio)
133-
}

0 commit comments

Comments
 (0)