0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

spark-shellでimportとか変数設定とかをファイル読み込みで事前にやっておくには

Posted at

出来上がったアプリ、ツールなどは、
spark-submitで使えばよいが、spark-shellで対話的に
デバッグ、確認したいが、いちいち、importとか変数設定とかするのが面倒な場合は、ファイルに設定して、読み込む

prepare.scala
import org.apache.spark._
import org.apache.spark.rdd._

import com.rikima.ml.Query

val input = "/opt/hoge/data.tsv"
val model = "/opt/hoge/model.json"

def process(queries: RDD[Query]) : RDD[Int] = {
 ....
}

spark-shellの起動

shell.sh
# !/bin/sh

jars="hoge.jar"
for jar in $(ls ./extjars/*.jar)  ; do
   jars=$jars,$jar
done
spark-shell --jars $jars -i ./prepare.scala 

これで、spark-shell起動後に、input, model変数が使えたり、process functionを使える。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?