当我运行spark python代码时,如下所示:
import pyspark
conf = (pyspark.SparkConf()
.setMaster("local")
.setAppName("My app")
.set("spark.executor.memory", "512m"))
sc = pyspark.SparkContext(conf = conf) #start the conf
data =sc.textFile('/Users/tsangbosco/Downloads/transactions')
data = data.flatMap(lambda x:x.split()).take(all)
该文件约为20G,我的计算机有8G ram,当我在独立模式下运行程序时,会引发OutOfMemoryError:
^{pr2}$spark无法处理比我的ram大的文件吗?你能告诉我怎么修吗?在
Spark能处理一些案子。但是您使用
take
强制Spark将所有数据提取到一个数组(内存中)。在这种情况下,您应该将它们存储到文件中,就像使用saveAsTextFile
。在如果您对查看某些数据感兴趣,可以使用}。在
sample
或{相关问题 更多 >
编程相关推荐