scala - How to convert Option[RDD] into RDD -
this question has answer here:
- scala map#get , return of some() 1 answer
i storing rdd mutable hashmap using key below.
var datasets = new hashmap[string, rdd[t]]() val feedrdd: rdd[t] = ... datasets.put("somekey", feedrdd) now trying fetch same rdd hashmap , returning option[rdd[t]] below
val feedrddnew = datasets.get("somekey") and giving error this.
expression of type option[rdd[t]] doesn't confirm expected type rdd[t]
basically want store rdd hashmap can fetch hashmap needed. thoughts on this? please let me know if wrong or alternate way. thanks!
val feedrddnew = datasets.get("somekey") this getter returns option[t] t type stored in map.
so, either none, or some(t)
so can do
val theactualvalue = feedrddnew.get or, can use
datasets("somekey") which doesnt return option (it throws if key not found)
Comments
Post a Comment