Skip to content

Instantly share code, notes, and snippets.

@galleon
Last active November 15, 2015 18:33
Show Gist options
  • Save galleon/231dbfcff36f8d4ce6c2 to your computer and use it in GitHub Desktop.
Save galleon/231dbfcff36f8d4ce6c2 to your computer and use it in GitHub Desktop.
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