我对RDD在Spark中的范围感到困惑。在
Whether an RDD is cached or not is part of the mutable state of the RDD object. If you call rdd.cache it will be marked for caching from then on. It does not matter what scope you access it from.
因此,如果我定义了一个函数,其中创建了一个新的rdd,例如(python代码)
# there is an rdd called "otherRdd" outside the function
def myFun(args):
...
newRdd = otherRdd.map(some_function)
newRdd.persist()
...
newRdd
是否存在于全局命名空间中?或者它只在myFun
的环境中可见?在
如果它只在myFun
的环境中可见,那么在myFun
完成执行之后,它将自动unpersist
newRdd
?在
是的,当RDD被垃圾回收时,它是未持久化的。所以在myFun之外,newRdd是未持久化的(假设您没有返回它也没有派生rdd),您还可以检查这个answer。在
相关问题 更多 >
编程相关推荐