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

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)
主站蜘蛛池模板: 邵阳市| 诸城市| 于田县| 民勤县| 渝北区| 鄱阳县| 探索| 古丈县| 兴城市| 扶沟县| 乌审旗| 台州市| 齐齐哈尔市| 迭部县| 连山| 富阳市| 华容县| 宜兰市| 新龙县| 若羌县| 读书| 大洼县| 内江市| 安泽县| 黔西| 射阳县| 余干县| 柏乡县| 英吉沙县| 卓资县| 牟定县| 墨竹工卡县| 元江| 康定县| 牙克石市| 集安市| 二连浩特市| 仁布县| 东平县| 铁岭市| 碌曲县|