For #2, RDD is immutable.
> On Jan 18, 2016, at 8:10 PM, charles li <charles.up...@gmail.com> wrote: > > > hi, great thanks to david and ted, I know that the content of RDD can be > returned to driver using 'collect' method. > > but my question is: > > > 1. cause we can write any code we like in the function put into 'foreach', so > what happened when we actually write a 'return' sentence in the foreach > function? > 2. as the photo shows bellow, the content of RDD doesn't change after foreach > function, why? > 3. I feel a little confused about the 'foreach' method, it should be an > 'action', right? cause it return nothing. or is there any best practice of > the 'foreach' funtion? or can some one put your code snippet when using > 'foreach' method in your application, that would be awesome. > > > great thanks again > > > > > >> On Tue, Jan 19, 2016 at 11:44 AM, Ted Yu <yuzhih...@gmail.com> wrote: >> Here is signature for foreach: >> def foreach(f: T => Unit): Unit = withScope { >> >> I don't think you can return element in the way shown in the snippet. >> >>> On Mon, Jan 18, 2016 at 7:34 PM, charles li <charles.up...@gmail.com> wrote: >>> code snippet >>> >>> <屏幕快照 2016-01-19 上午11.32.05.png> >>> >>> the 'print' actually print info on the worker node, but I feel confused >>> where the 'return' value >>> goes to. for I get nothing on the driver node. >>> -- >>> -------------------------------------- >>> a spark lover, a quant, a developer and a good man. >>> >>> http://github.com/litaotao > > > > -- > -------------------------------------- > a spark lover, a quant, a developer and a good man. > > http://github.com/litaotao