I think what's desired here is for input to be unpersisted automatically as
soon as result is materialized. I don't think there's currently a way to do
this, but the usual workaround is to force result to be materialized
immediately and then unpersist input:

input.cache()val count = input.countval result = input.filter(...)
result.cache().foreach(x => {}) // materialize resultinput.unpersist()
// safe because `result` is materialized                  // and is
the only RDD that depends on `input`return result


Ankur <http://www.ankurdave.com/>

Reply via email to