Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
GroovySparkWordcount.groovy
@Grab('org.apache.spark:spark-core_2.10:1.5.2')
import org.apache.spark.SparkConf
import org.apache.spark.api.java.JavaSparkContext
def conf = new SparkConf().setMaster("local[2]").setAppName("WordCount")
println conf
def ctx = new JavaSparkContext(conf)
def file = ctx.textFile("/Users/tog/Work/incubator-zeppelin/README.md").cache()
def filterClosure = {s -> s.contains('spark')}
filterClosureDehydrated = filterClosure.dehydrate()
println "Count of spark: " + file.filter(filterClosureDehydrated).count()
//-verbose:class
//def cl1 = this.class.getClassLoader()
//def cl2 = Thread.currentThread().getContextClassLoader()
//cl1.getLoadedClasses().each{println "${it.name} ${it.getProtectionDomain().getCodeSource().getLocation()}"}
//cl2.getLoadedClasses().each{println "${it.name} ${it.getProtectionDomain().getCodeSource().getLocation()}"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.