【发布时间】:2016-10-12 01:54:31
【问题描述】:
在这里,我粘贴了我在 spark 上运行的 python 代码,以便对数据执行一些分析。我能够在少量数据集上运行以下程序。但是当进入大型数据集时,它会说“第 1 阶段包含一个非常大的任务(17693 KB)。建议的最大任务大小为 100 KB”。
import os
import sys
import unicodedata
from operator import add
try:
from pyspark import SparkConf
from pyspark import SparkContext
except ImportError as e:
print ("Error importing Spark Modules", e)
sys.exit(1)
def tokenize(text):
resultDict = {}
text = unicodedata.normalize('NFKD', text).encode('ascii','ignore')
str1= text[1]
str2= text[0]
arrText= text.split(str1)
ss1 = arrText[0].split("/")
docID = ss1[0].strip()
docName = ss[1].strip()
resultDict[docID+"_"+docName] = 1
return resultDict.iteritems()
sc=SparkContext('local')
textfile = sc.textFile("path to my data")
fileContent = textfile.flatMap(tokenize)
rdd = sc.parallelize(fileContent.collect())
rdd= rdd.map(lambda x: (x[0], x[1])).reduceByKey(add)
print rdd.collect()
#reduceByKey(lambda a,b: a+b)
rdd.coalesce(1).saveAsTextFile("path to result")
我在这里发布更多警告:在此之后作业没有运行。有人可以帮我解决这个问题吗?
16/06/10 19:19:58 WARN TaskSetManager: Stage 1 contains a task of very large size (17693 KB). The maximum recommended task size is 100 KB.
16/06/10 19:19:58 INFO TaskSetManager: Starting task 0.0 in stage 1.0 (TID 5314, localhost, partition 0,PROCESS_LOCAL, 18118332 bytes)
16/06/10 19:19:58 INFO Executor: Running task 0.0 in stage 1.0 (TID 5314)
16/06/10 19:43:00 INFO BlockManagerInfo: Removed broadcast_1_piece0 on localhost:43480 in memory (size: 3.9 KB, free: 511.1 MB)
16/06/10 19:43:00 INFO ContextCleaner: Cleaned accumulator 2
【问题讨论】:
-
这个警告基本上是说你的一个转换函数太大了。既然你说在这之后工作不会继续,我会寻找一些增加内存占用的 inf 循环。
-
你的意思是说我们需要在编译时使用标志--executor-memory来增加内存。
标签: python apache-spark