0

有人可以这么好心并告诉我如何在以下代码中调整 hdfs URI,以便它们与我的本地 spark'cluster' 一起工作吗?

var lines = sparkContext.TextFile(@"hdfs://path/to/input.txt");  
// some more code
wordCounts.SaveAsTextFile(@"hdfs://path/to/wordcount.txt");  
4

1 回答 1

0

您可以只定义路径位置配置参数将在 sparkcontext 上设置,因此不需要像下面那样添加 hdfs 应该可以在纱线模式下运行应用程序

var lines = sparkContext.TextFile("/path/to/input.txt");  
// some more code
wordCounts.SaveAsTextFile("/path/to/wordcount.txt");  

或者您可以明确定义 hdfs 位置,如下所示

val lines =  sparkContext.textFile("hdfs://namenode:port/path/to/input.txt")

您还可以定义可选的分区数

var lines = sparkContext.TextFile("/path/to/input.txt",[number of partitions]);  
于 2017-04-15T20:46:04.923 回答