。wordCounts.dstream()saveAsTextFiles(QUOT;本地文件系统路径"," TXT");不写入文件 [英] wordCounts.dstream().saveAsTextFiles("LOCAL FILE SYSTEM PATH", "txt"); does not write to file
本文介绍了。wordCounts.dstream()saveAsTextFiles(QUOT;本地文件系统路径"," TXT");不写入文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想写JavaPairRDD到本地系统文件。低于code:
I am trying to write JavaPairRDD into file in local system. Code below:
JavaPairDStream<String, Integer> wordCounts = words.mapToPair(
new PairFunction<String, String, Integer>() {
@Override
public Tuple2<String, Integer> call(String s) {
return new Tuple2<String, Integer>(s, 1);
}
}).reduceByKey(new Function2<Integer, Integer, Integer>() {
@Override
public Integer call(Integer i1, Integer i2) {
return i1 + i2;
}
});
wordCounts.dstream().saveAsTextFiles("/home/laxmikant/Desktop/teppppp", "txt");
我想保存记录或文件中的单词计数。但它不能在本地文件(而不是HDFS)保存。
I am trying to save the logs or the wordcount in file. But it is not able to save in a local file (NOT HDFS).
我也尝试使用HDFS上保存
I also tried to save on HDFS using
saveAsHadoopFiles("hdfs://10.42.0.1:54310/stream","txt")
以上行不写入文件。谁能告诉解决?
计算器上不工作的各种解决方案。
The above line does not write to file. Can anybody tell the solution? Various solutions on stackoverflow dont work.
推荐答案
试着写一个绝对路径输出:
Try to write output as an absolute path:
saveAsTextFiles("file:///home/laxmikant/Desktop/teppppp", "txt");
这篇关于。wordCounts.dstream()saveAsTextFiles(QUOT;本地文件系统路径&QUOT;,&QUOT; TXT&QUOT;);不写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文