我刚刚开始使用 spark,我正在尝试在本地模式下的示例......我注意到在创建 RDD 的一些示例中,使用了文件的相对路径,而在其他示例中,路径以“file:///”开头”。第二个选项对我根本不起作用 - “输入路径不存在”
任何人都可以解释使用文件路径和在它前面放置“file:///”之间的区别吗?
我在本地模式下运行的 Mac 上使用 Spark 2.2
from pyspark import SparkConf, SparkContext
conf = SparkConf().setMaster("local").setAppName("test")
sc = SparkContext(conf = conf)
#This will work providing the relative path
lines = sc.textFile("code/test.csv")
#This will not work
lines = sc.textFile("file:///code/test.csv")
sc.textFile("code/test.csv")
手段test.csv在/<hive.metastore.warehouse.dir>/code/test.csv
HDFS上。
sc.textFile("hdfs:///<hive.metastore.warehouse.dir>/code/test.csv")
等于上面。
sc.textFile("file:///code/test.csv")
手段test.csv在/code/test.csv
本地文件系统上。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句