我正在尝试将linux可执行文件作为服务
我在下面执行我的程序
java -jar mytestprogram.jar
Run Code Online (Sandbox Code Playgroud)
创建一个持续运行并提供REST请求的进程.但我想把它作为一项服务运行,我可以做
service mytestprogram start
service mytestprogram stop
service mytestprogram status
chkconfig mytestprogram on
Run Code Online (Sandbox Code Playgroud)
等最简单的方法是什么?
要复制我使用的行
Ctrl + D.
是否有类似的方法在IntelliJ IDEA中使用键盘选择/复制当前行?
以下代码:
val sentence = "1 2 3 4".split(" ")
Run Code Online (Sandbox Code Playgroud)
给我:
Array(1, 2, "", 3, "", "", 4)
Run Code Online (Sandbox Code Playgroud)
但我宁愿只想说:
Array(1, 2, 3, 4)
Run Code Online (Sandbox Code Playgroud)
当单词被多个空格分隔时,如何拆分句子?
val REGEX_OPEN_CURLY_BRACE = """\{""".r
val REGEX_CLOSED_CURLY_BRACE = """\}""".r
val REGEX_INLINE_DOUBLE_QUOTES = """\\\"""".r
val REGEX_NEW_LINE = """\\\n""".r
// Replacing { with '{' and } with '}'
str = REGEX_OPEN_CURLY_BRACE.replaceAllIn(str, """'{'""")
str = REGEX_CLOSED_CURLY_BRACE.replaceAllIn(str, """'}'""")
// Escape \" with '\"' and \n with '\n'
str = REGEX_INLINE_DOUBLE_QUOTES.replaceAllIn(str, """'\"'""")
str = REGEX_NEW_LINE.replaceAllIn(str, """'\n'""")
Run Code Online (Sandbox Code Playgroud)
是否有更简单的方法来分组和替换所有这些{,},\",\n?
我已经创建了一个本地 Spark 集群和一个 Spark 会话,如下所示
val sparkConf = new SparkConf(true).setAppName("test").setMaster("local[8]")
val sparkSession = SparkSession.builder().config(sparkConf).getOrCreate()
Run Code Online (Sandbox Code Playgroud)
使用它我还成功创建了虚拟数据帧以在我的测试 scala 应用程序中使用
val dummy: DataFrame = sparkSession.createDataFrame(Seq(
("BABY", "videos", "0.5"),
("APPLIANCES AND STORAGE", "audios", "0.6")
).toDF("dept", "type", "weight")
Run Code Online (Sandbox Code Playgroud)
后来我创建了一个对象 Item,并尝试将其写入 Elastic Search,如下所示
val elasticItemRDD = sparkSession.sparkContext.makeRDD(Seq(Item))
EsSpark.saveToEs(elasticItemRDD, esIndexNType, Map("es.mapping.id" -> "itemid"))
Run Code Online (Sandbox Code Playgroud)
从我的sparkSession访问sparkContext时,这给了我一个空指针异常。我努力了
sparkSession.createDataset(Seq(Item)).rdd
Run Code Online (Sandbox Code Playgroud)
这不会给我这个空指针错误,而是一些其他的 MatchError。我喜欢让我的sparkContext.makeRDD工作,这样我就可以写入ElasticSearch。这个 NullPointerException 的原因可能是什么?我错过了什么吗?
scalaVersion := "2.11.8"
val sparkVersion = "2.2.0"
libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-core" % sparkVersion % "provided",
"org.apache.spark" %% "spark-sql" % sparkVersion % "provided",
"org.apache.spark" % "spark-hive_2.11" % …Run Code Online (Sandbox Code Playgroud) scala ×3
apache-spark ×1
linux ×1
process ×1
rdd ×1
regex ×1
regex-group ×1
replace ×1
service ×1