MAC ver.
cd ~/.../spark-1.6.0-bin-hadoop2.6./bin/spark-shell
Windows ver.
cd ~\...\spark-1.6.0-bin-hadoop2.6.\bin\spark-shell
Spark-shell
// relative path is based on spark directory
/** each line in this text file is a new element of a single RDD */
val text = sc.textFile("README.md")
/** count the number of elements in this RDD */
text.count()
/** count the number of elements which contain keyword "Spark" */
text.filter(line => line.contains("Spark")).count()
/** find first element in this RDD */
text.first()
/** list top 10 elements in this RDD */
text.take(10)
/** list all of elements in this RDD */
text.collect()- click "Terminal" on the bottom side
sbt package- now you have a .jar in your project\target\scala-2.10\YOURPROJECT_2.10-1.0.jar
cd SPARK_DIRECTORY- MAC:
./bin/spark_submit --name "test" --master local /.../YOURPROJECT_2.10-1.0.jar - WIN:
.\bin\spark-submit --name "test" --master local \...\YOURPROJECT_2.10-1.0.jar
java.lang.IllegalArgumentException: System memory 259522560 must be at least 4.718592E8. Please use a larger heap size.
- "Run" -> "Edit Configuration" -> "Application"
- Main class: YOUR_MAIN_OBJECT
- VM options: -Xmx512m
ERROR Shell: Failed to locate the winutils binary in the hadoop binary path
java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries.
- https://github.com/NCTUee104/hadoop-common-2.2.0-bin
System.setProperty("hadoop.home.dir", "\...\hadoop-common-2.2.0-bin-master")in Main function