Yep, But RDD/DStream would hardly fit the Monad contract (discussed several time, and still under discussions here and there ;)) For instance, look at the signature of flatMap in both traits.
Albeit, an RDD that can generates other RDD (flatMap) is rather somethi.g like a DStream or '''''CRDD'''' (@see dev list :P) My.2c Andy --sent from crappy phone Le 19 déc. 2013 07:09, "Ashish Rangole" <arang...@gmail.com> a écrit : > I wonder if it will help to have a generic Monad container that wraps > either RDD or DStream and provides > map, flatmap, foreach and filter methods. > > case class DataMonad[A](data: A) { > def map[B]( f : A => B ) : DataMonad[B] = { > DataMonad( f( data ) ) > } > > def flatMap[B]( f : A => DataMonad[B] ) : DataMonad[B] = { > f( data ) > } > > def foreach ... > def withFilter ... > : > : > etc, something like that > } > > On Wed, Dec 18, 2013 at 10:42 PM, Reynold Xin <r...@apache.org> wrote: > >> >> On Wed, Dec 18, 2013 at 12:17 PM, Nathan Kronenfeld < >> nkronenf...@oculusinfo.com> wrote: >> >>> >>> >>> Since many of the functions exist in parallel between the two, I guess I >>> would expect something like: >>> >>> trait BasicRDDFunctions { >>> def map... >>> def reduce... >>> def filter... >>> def foreach... >>> } >>> >>> class RDD extends BasicRDDFunctions... >>> class DStream extends BasicRDDFunctions... >>> >> >> I like this idea. We should discuss more about it on the dev list. It >> would require refactoring some APIs, but does lead to better unification. >> > >