Skip to content

Instantly share code, notes, and snippets.

@solidpple
Created July 25, 2016 06:45
Show Gist options
  • Save solidpple/3cb23371796c2a2347e5748910de21a4 to your computer and use it in GitHub Desktop.
Save solidpple/3cb23371796c2a2347e5748910de21a4 to your computer and use it in GitHub Desktop.
import org.apache.spark.SparkConf
import org.apache.spark.SparkContext
import org.apache.spark.SparkContext._
class SearchFunctions(val query: String) {
def isMatch(s: String): Boolean = {
s.contains(query)
}
def getMatchesFunctionReference(rdd: RDD[String]): RDD[Boolean] = {
rdd.map(isMatch)
}
def getMatchesFieldReference(rdd: RDD[String]): RDD[Array[String]] = {
rdd.map(x => x.split(query))
}
def getMatchesNoReference(rdd: RDD[String]): RDD[Array[String]] = {
val query_ = this.query
rdd.map(x => x.split(query_))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment