星火:如何使用SparkContext.textFile本地文件系统 [英] Spark: how to use SparkContext.textFile for local file system

查看:1196
本文介绍了星火:如何使用SparkContext.textFile本地文件系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用Apache星火启动(Scala中,但语言是无关紧要的)。我使用的独立模式,我会要处理从本地文件系统的文本文件(所以没有像分布HDFS)。

I'm just getting started using Apache Spark (in Scala, but the language is irrelevant). I'm using standalone mode and I'll want to process a text file from a local file system (so nothing distributed like HDFS).

按照文本文件方法从 SparkContext 的文件,它将

According to the documentation of the textFile method from SparkContext, it will

阅读从HDFS一个文本文件,本地文件系统(所有可用
  的节点),或任何Hadoop的支持的文件系统的URI,并返回它作为一个
  RDD字符串。

Read a text file from HDFS, a local file system (available on all nodes), or any Hadoop-supported file system URI, and return it as an RDD of Strings.

什么是不清楚对我来说,如果整个文本文件可以只被复制到所有节点,或者如果输入数据应该已经被分配,例如如果使用4个节点和1000线的CSV文件,必须在每个节点上250行。

What is unclear for me is if the whole text file can just be copied to all the nodes, or if the input data should already be partitioned, e.g. if using 4 nodes and a csv file with 1000 lines, have 250 lines on each node.

我怀疑每个节点应该有整个文件,但我不知道。

I suspect each node should have the whole file but I'm not sure.

推荐答案

每个节点应该包括整个文件。在这种情况下,本地文件系统将会从HDFS逻辑没有区别,在尊重该文件。

Each node should contain a whole file. In this case local file system will be logically indistinguishable from the HDFS, in respect to this file.

这篇关于星火:如何使用SparkContext.textFile本地文件系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆