递归值x $ 5需要类型 [英] recursive value x$5 needs type
本文介绍了递归值x $ 5需要类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在此行出现错误
val Array(outputDirectory,Utils.IntParam(numTweetsToCollect),Utils.IntParam(intervalSecs),Utils.IntParam(partitionsEachInterval))=Utils.parseCommandLineWithTwitterCredentials(args)
- 递归值x $ 7需要输入
- 递归值x $ 1需要输入
此错误的含义是什么,请指导我如何解决此错误.
object收集{私人var numTweetsCollected = 0L私人var partNum = 0私人var gson =新的Gson()def main(args:Array [String]){//处理程序参数并设置属性如果(args.length< 3){System.err.println(用法:" + this.getClass.getSimpleName +< outputDirectory>< numTweetsToCollect>< intervalInSeconds>< partitionsEachInterval>)System.exit(1)}val Array(outputDirectory,Utils.IntParam(numTweetsToCollect),Utils.IntParam(intervalSecs),Utils.IntParam(partitionsEachInterval))=Utils.parseCommandLineWithTwitterCredentials(args)val outputDir =新文件(outputDirectory.toString)如果(outputDir.exists()){System.err.println(错误-%s已存在:删除或指定另一个目录" .format(输出目录))System.exit(1)}outputDir.mkdirs()println(正在初始化流Spark上下文...")val conf = new SparkConf().setAppName(this.getClass.getSimpleName)val sc = new SparkContext(conf)val ssc = new StreamingContext(sc,Seconds(intervalSecs))val tweetStream = TwitterUtils.createStream(ssc,Utils.getAuth).map(gson.toJson(_))tweetStream.foreachRDD((rdd,time)=> {val count = rdd.count()if(count> 0){val outputRDD = rdd.repartition(partitionsEachInterval)outputRDD.saveAsTextFile(outputDirectory +"/tweets_" + time.milliseconds.toString)numTweetsCollected + =计数如果(numTweetsCollected> numTweetsToCollect){System.exit(0)}}})ssc.start()ssc.awaitTermination()}}
解决方案
尝试从模式匹配的值中删除 Utils.IntParam(..
).提取值,然后分别解析.>
i am getting error at this line
val Array(outputDirectory, Utils.IntParam(numTweetsToCollect), Utils.IntParam(intervalSecs), Utils.IntParam(partitionsEachInterval)) =
Utils.parseCommandLineWithTwitterCredentials(args)
- recursive value x$7 needs type
- recursive value x$1 needs type
what does this error meaning, please guide me how to resolve this error.
object Collect {
private var numTweetsCollected = 0L
private var partNum = 0
private var gson = new Gson()
def main(args: Array[String]) {
// Process program arguments and set properties
if (args.length < 3) {
System.err.println("Usage: " + this.getClass.getSimpleName +
"<outputDirectory> <numTweetsToCollect> <intervalInSeconds> <partitionsEachInterval>")
System.exit(1)
}
val Array(outputDirectory, Utils.IntParam(numTweetsToCollect), Utils.IntParam(intervalSecs), Utils.IntParam(partitionsEachInterval)) =
Utils.parseCommandLineWithTwitterCredentials(args)
val outputDir = new File(outputDirectory.toString)
if (outputDir.exists()) {
System.err.println("ERROR - %s already exists: delete or specify another directory".format(
outputDirectory))
System.exit(1)
}
outputDir.mkdirs()
println("Initializing Streaming Spark Context...")
val conf = new SparkConf().setAppName(this.getClass.getSimpleName)
val sc = new SparkContext(conf)
val ssc = new StreamingContext(sc, Seconds(intervalSecs))
val tweetStream = TwitterUtils.createStream(ssc, Utils.getAuth)
.map(gson.toJson(_))
tweetStream.foreachRDD((rdd, time) => {
val count = rdd.count()
if (count > 0) {
val outputRDD = rdd.repartition(partitionsEachInterval)
outputRDD.saveAsTextFile(outputDirectory + "/tweets_" + time.milliseconds.toString)
numTweetsCollected += count
if (numTweetsCollected > numTweetsToCollect) {
System.exit(0)
}
}
})
ssc.start()
ssc.awaitTermination()
}
}
解决方案
Try removing the Utils.IntParam(..
from your pattern matched values. Extract the values, then parse them separately.
这篇关于递归值x $ 5需要类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文