[英]How does spark sc.textFile works?
JavaRDD<String> input = sc.textFile("data.txt");
For the above sample code in Spark, I know it returns distributed list of string.对于 Spark 中的上述示例代码,我知道它返回字符串的分布式列表。 But individual string in that list is a
line
or word
tokens of data.txt?但是该列表中的单个字符串是 data.txt 的
line
或word
标记吗?
A string in your rdd
equals a line in data.txt. rdd
的字符串等于 data.txt 中的一行。
If the data in your data.txt file is some type of csv data, you can use the spark-csv
package that will split the data into columns for you, so you don't have to parse the lines yourself.如果您的 data.txt 文件中的数据是某种类型的 csv 数据,您可以使用
spark-csv
包将数据拆分为列,这样您就不必自己解析行了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.