多远将引发RDD缓存走? [英] How far will Spark RDD cache go?

查看:331
本文介绍了多远将引发RDD缓存走?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有三个的 RDD 的要求转化功能的 RDD1集的:

Say I have three RDD transformation function called on rdd1:

def rdd2 = rdd1.f1
def rdd3 = rdd2.f2
def rdd4 = rdd3.f3

现在我想缓存的 rdd4 的,所以我打电话的 rdd4.cache()

Now I want to cache the rdd4, so I call rdd4.cache()

我的问题:

只会从操作的结果的 rdd4 的缓存或将在每次的 RDD 的上面的 rdd4 的缓存?说我要同时缓存 rdd3 的和的 rdd4 的,我需要分别缓存它们?

Will only the result from the action on rdd4 be cached or will every RDD above rdd4 be cached? Say I want to cache both rdd3 and rdd4, do I need to cache them separately?

推荐答案

缓存的整体思路是,火花不保持在内存中的结果,除非你告诉它。因此,如果你在链缓存最后RDD它仅保留一个在存储器的结果。所以,是的,你需要分别缓存它们,但要记住,你只需要一个缓存RDD如果你要使用它不止一次,例如:

The whole idea of cache is that spark is not keeping the results in memory unless you tell it to. So if you cache the last RDD in the chain it only keeps the results of that one in memory. So, yes, you do need to cache them separately, but keep in mind you only need to cache an RDD if you are going to use it more than once, for example:

rdd4.cache()
val v1 = rdd4.lookup("key1")
val v2 = rdd4.lookup("key2")

如果你不调用在这种情况下rdd4将重新计算每次调用查找(或者需要评估的其他功能)高速缓存。你可能想阅读纸上RDD的是pretty容易理解和解释了背后他们做了某些方面的选择想法如何RDD的工作。

If you do not call cache in this case rdd4 will be recalculated for every call to lookup (or any other function that requires evaluation). You might want to read the paper on RDD's it is pretty easy to understand and explains the ideas behind certain choices they made regarding how RDD's work.

这篇关于多远将引发RDD缓存走?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆