官术网_书友最值得收藏!

Processing the text files

Using SparkContext, it is possible to load a text file in RDD using the textFile method. Additionally, the wholeTextFile method can read the contents of a directory to RDD. The following examples show you how a file, based on the local filesystem (file://) or HDFS (hdfs://), can be read to a Spark RDD. These examples show you that the data will be divided into six partitions for increased performance. The first two examples are the same as they both load a file from the Linux filesystem, whereas the last one resides in HDFS:

sc.textFile("/data/spark/tweets.txt",6)
sc.textFile("file:///data/spark/tweets.txt",6)
sc.textFile("hdfs://server1:4014/data/spark/tweets.txt",6)
主站蜘蛛池模板: 麟游县| 牡丹江市| 沁阳市| 营山县| 大新县| 日土县| 临朐县| 康保县| 渝中区| 浦城县| 波密县| 临汾市| 百色市| 张家口市| 乐业县| 尚志市| 天全县| 隆子县| 大庆市| 木兰县| 瑞昌市| 陆丰市| 明星| 侯马市| 井冈山市| 西乡县| 周至县| 贺兰县| 中牟县| 玉林市| 安徽省| 视频| 井研县| 泸州市| 茂名市| 富裕县| 晋中市| 白水县| 三台县| 扎鲁特旗| 鄂尔多斯市|