| Both sides previous revision
Previous revision
|
|
spark:using-scala [2026/09/16 12:57] straka |
spark:using-scala [2026/09/16 13:00] (current) straka |
| - replace the ''spark-template'' by your project name in the first line (i.e., ''name := "my-best-project"'') | - replace the ''spark-template'' by your project name in the first line (i.e., ''name := "my-best-project"'') |
| - run ''sbt --server package'' to create JAR | - run ''sbt --server package'' to create JAR |
| The resulting JAR can be found in ''target'' subdirectory, named after your project. | The resulting JAR can be found in ''target/out'' subdirectory, named after your project. |
| |
| ==== Usage Examples ==== | ==== Usage Examples ==== |
| |
| scalaVersion := "2.13.18" | scalaVersion := "2.13.18" |
| | |
| libraryDependencies += "org.apache.spark" %% "spark-core" % "4.2.0" | libraryDependencies += "org.apache.spark" %% "spark-core" % "4.2.0" % "provided" |
| | |
| | Compile / packageBin / artifactPath := { |
| | val jarFile = baseDirectory.value / "target" / "out" / s"${name.value}-${version.value}.jar" |
| | fileConverter.value.toVirtualFile(jarFile.toPath) |
| | } |
| </file> | </file> |
| |
| |
| * run ''word_count'' application inside existing Spark cluster (i.e., inside ''spark-sbatch'' or ''spark-srun''), or start local Spark cluster using as many threads as there are cores if there is none: | * run ''word_count'' application inside existing Spark cluster (i.e., inside ''spark-sbatch'' or ''spark-srun''), or start local Spark cluster using as many threads as there are cores if there is none: |
| <file>spark-submit target/scala-2.13/word_count_2.13-1.0.jar /net/projects/spark-example-data/wiki-cs outdir</file> | <file>spark-submit target/out/word_count-1.0.jar /net/projects/spark-example-data/wiki-cs outdir</file> |
| * run ''word_count'' application with local Spark cluster using one thread: | * run ''word_count'' application with local Spark cluster using one thread: |
| <file>MASTER=local spark-submit target/scala-2.13/word_count_2.13-1.0.jar /net/projects/spark-example-data/wiki-cs outdir</file> | <file>MASTER=local spark-submit target/out/word_count-1.0.jar /net/projects/spark-example-data/wiki-cs outdir</file> |
| * start Spark cluster (10 machines, 2GB RAM each) on Slurm and run ''word_count'' application: | * start Spark cluster (10 machines, 2GB RAM each) on Slurm and run ''word_count'' application: |
| <file>spark-sbatch 10 2G spark-submit target/scala-2.13/word_count_2.13-1.0.jar /net/projects/spark-example-data/wiki-cs outdir</file> | <file>spark-sbatch 10 2G spark-submit target/out/word_count-1.0.jar /net/projects/spark-example-data/wiki-cs outdir</file> |
| |