Enhance RDDs with methods for generating multiplexed RDDs
Enhance RDDs with methods for generating multiplexed RDDs
T
the element type of the RDD
// enable multiplexing methodsimport io.radanalytics.silex.rdd.multiplex.implicits._
// A boolean predicate on data elementsval pred: Int=>Boolean = ....
// pos will contain data elements for which 'pred' was true.// neg will contain elements for which 'pred' was false.val (pos, neg) = data.flatMuxPartitions((data: Iterator[Int]) => {
val pT = scala.collection.mutable.ArrayBuffer.empty[Int]
val pF = scala.collection.mutable.ArrayBuffer.empty[Int]
data.foreach { e => (if (pred(e)) pT else pF) += e }
(pT, pF)
})
Enhance RDDs with methods for generating multiplexed RDDs
the element type of the RDD