Created
July 25, 2016 06:45
-
-
Save solidpple/3cb23371796c2a2347e5748910de21a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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