Skip to content

Instantly share code, notes, and snippets.

@cerisier
Last active April 10, 2016 14:32
Show Gist options
  • Save cerisier/fad76a73b8a3f59cc69b2660619da82d to your computer and use it in GitHub Desktop.
Save cerisier/fad76a73b8a3f59cc69b2660619da82d to your computer and use it in GitHub Desktop.
/**
* Return a new RDD containing only the elements that satisfy a predicate.
*/
def filter(f: T => Boolean): RDD[T] = withScope {
val cleanF = sc.clean(f)
new MapPartitionsRDD[T, T](
this,
(context, pid, iter) => iter.filter(cleanF),
preservesPartitioning = true)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment