Spark是否会自动缓存某些结果? [英] Does spark automatically cache some results?
本文介绍了Spark是否会自动缓存某些结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我执行了两次操作,第二次花费很少的时间运行,因此我怀疑spark自动缓存了一些结果.但是我确实找到了任何来源.
I run an action two times, and the second time takes very little time to run, so I suspect that spark automatically cache some results. But I did find any source.
我正在使用Spark1.4.
Im using Spark1.4.
doc = sc.textFile('...')
doc_wc = doc.flatMap(lambda x: re.split('\W', x))\
.filter(lambda x: x != '') \
.map(lambda word: (word, 1)) \
.reduceByKey(lambda x,y: x+y)
%%time
doc_wc.take(5) # first time
# CPU times: user 10.7 ms, sys: 425 µs, total: 11.1 ms
# Wall time: 4.39 s
%%time
doc_wc.take(5) # second time
# CPU times: user 6.13 ms, sys: 276 µs, total: 6.41 ms
# Wall time: 151 ms
推荐答案
查看全文