scala的REPL shell的调用
最近突然对spark的spark-shell发生了兴趣
它是如何启动scala的REPL的,并且在此前写入了常用的环境变量的呢?
通过查看spark的源码,找到了SparkILoop.scala
import scala.tools.nsc.interpreter.{JPrintWriter, ILoop}
/**
* A Spark-specific interactive shell.
*/
class SparkILoop(in0: Option[BufferedReader], out: JPrintWriter)
extends ILoop(in0, out) {
def this(in0: BufferedReader, out: JPrintWriter) = this(Some(in0), out)
def this() = this(None, new JPrintWriter(Console.out, true))
def initializeSpark() {
intp.beQuietDuring {
processLine("""
@transient val sc = {
val _sc = org.apache.spark.repl.Main.createSparkContext()
println("Spark context available as sc.")
_sc
}
""")
processLine("""
@transient val sqlContext = {
val _sqlContext = org.apache.spark.repl.Main.createSQLContext()
println("SQL context available as sqlContext.")
_sqlContext
}
""")
processLine("import org.apache.spark.SparkContext._")
processLine("import sqlContext.implicits._")
processLine("import sqlContext.sql")
processLine("import org.apache.spark.sql.functions._")
}
}
...
}
可以看出SparkILoop继承自scala.tools.nsc.interpreter.ILoop
紧接着着看了ILoop的api doc
终于找到了启动ILoop的方法:
import scala.tools.nsc.interpreter.ILoop
import scala.tools.nsc.Settings
val loop = new ILoop
loop.process(new Settings)
scala的REPL shell的调用的更多相关文章
- shell脚本调用spark-sql
为了更方便的查询并产生报表, 需要使用shell脚本调用spark-sql spark/bin/spark-sql --master spark://host:7077 -f ${SQL_FILE} ...
- shell脚本调用C语言之字符串切分之strtok函数
今天上午在写一个需求,要求的比较急,要求当天完成,我大致分析了一下,可以采用从shell脚本中插入一连串的日期,通过调用proc生成的可执行文件,将日期传入后台数据库,在数据库中进行计算.需要切分日期 ...
- shell脚本调用C语言之字符串切分函数——strtok
今天上午在写一个需求,要求的比较急,要求当天完成,我大致分析了一下,可以采用从shell脚本中插入一连串的日期,通过调用proc生成的可执行文件,将日期传入后台数据库,在数据库中进行计算.需要切分日期 ...
- shell中调用R语言并传入参数的两种步骤
shell中调用R语言并传入参数的两种方法 第一种: Rscript myscript.R R脚本的输出 第二种: R CMD BATCH myscript.R # Check the output ...
- shell中调用jenkins API批量运行历史任务
shell中调用jenkins API批量运行jenkins带参数的任务: #!/bin/sh #startdate=20150127 startdate=20150201 while [ " ...
- shell 获得调用的python脚本的print值和错误log
1. shell 获得调用的python脚本的print值 python test.py > out.log 2.shell 获得调用的python脚本的错误log python test.py ...
- Shell脚本调用ftp上传文件
Shell脚本调用ftp上传文件 1.脚本如下 ftp -n<<! open x.x.x.x ###x.x.x.x为ftp地址 user username password ###user ...
- Shell脚本调用SQL文格式
Shell脚本调用SQL文格式 1. 定义需要执行的SQL文,以及需要输出文件 OUTFILE=\${DATADIR}/\${FILENAME} SQLFILE=\${DATADIR}/check_t ...
- Miniconda 安装 & Pip module 安装 & Shell 脚本调用 Miniconda 虚拟环境手册(实战项目应用)
(实战项目应用) 1. 下载Miniconda 两个安装方式: 方式1:wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Min ...
随机推荐
- C# 结构体保存自定义文件 实例部分代码(转)
http://www.cnblogs.com/jxsoft/archive/2011/08/26/2154705.html
- 使用Genymotion作Android开发模拟器:安装Genymotion、部署Genymotion Vitrue Device、安装Genymotion eclipse插件
偶然听说Genymotion Android模拟器非常强大,到网上了解一番后,决定从AVD又慢又卡中解脱出来,折腾了半天终于部署好了,体验了一下,果然启动快,运行流畅,现在总结一下经验教训,供大家参考 ...
- Getting Started with OWIN and Katana(Console 代替iis 制作 web服务的简单方案)
Open Web Interface for .NET (OWIN) defines an abstraction between .NET web servers and web applicati ...
- Hadoop MapReduce概念学习系列之mr的Shuffle(二十二)
Shuffle是非常非常非常重要.搞mr,必须熟烂于心. 因为,分区,分组,排序,,,都是在Shuffle里完成.
- wavecom短信猫常用AT命令
wavecom短信猫常用AT命令 一.一般命令 1. AT+CGMI 给出模块厂商的标识. 2. AT+CGMM 获得模块标识.这个命令用来得到支持的频带 (GSM 900,DCS 1800 或PCS ...
- maven快速入门
一.maven maven可以说是管理项目的优秀工具,管理jar包 二.mave安装 1.先安装jdk(本文不详细讲) 2.安装maven ①.maven下载 http://maven.apach ...
- datagridview控件--导出Excel
dataGridView控件可以说很方便的显示了数据,而且对于修改和删除数据也很方便,我在前面的一篇博客中写到了如何去绑定数据到该控件上dataGridView控件--绑定数据方法,今天我将如何将数据 ...
- 作为平台的Windows PowerShell(一)
除了作为一种脚本语言外,Windows PowerShell被多种应用程序使用.这是因为Windows PowerShell引擎可以被托管在一个应用程序内部.这篇博文和下一篇博文将会处理在C#应用程序 ...
- Http协议网络对时工具
2009-09-17 11:52:31 专业的网络对时软件大多採用NTP协议来获取专业时间server时间对时,也有採用SNTP协议的,本来也想做个SNTP或NTP协议的对时工具自己用,尽管我手上也有 ...
- 模拟京东商城登陆HttpRequest
利用Winform HttpRequest 模拟登陆京东商城 目前只获取订单信息,可以获取图片等其他信息 using System; using System.Collections.Generic; ...