dump icon indicating copy to clipboard operation
dump copied to clipboard

Question for tutorial : serialization-exceptions-and-memory-leaks-no-ws.md

Open VadymBoikov opened this issue 9 years ago • 3 comments

In your tutorial for somewhere between quiz 5 and quiz 6:

I'm playing with your examples in shell, and cant figure out why does the following work?

scala> def addOne(i: Int): Int = i + 1
addOne: (i: Int)Int

scala> sc.makeRDD(1 to 100).map(addOne).reduce(_ + _)
res24: Int = 5150

deffOne is still a method - and it should not be serialized. (btw, it was defined in the shell )

VadymBoikov avatar May 03 '16 16:05 VadymBoikov

@VadymBoikov Are you doing this inside spark-shell or sbt console?

These shells do weird things implicitly, they could be wrapping your method in a hidden anonymous serialisable class.

samthebest avatar May 03 '16 17:05 samthebest

I'm doing it inside spark-shell

Is there a way to detect if my method was wrapped imlicitly?

VadymBoikov avatar May 03 '16 17:05 VadymBoikov

@VadymBoikov If you make it throw an exception it shows some weirdness which implies it is. I did the following in a regular shell:

scala> def foo(i: Int): Int = ???
foo: (i: Int)Int


scala> foo(10)
scala.NotImplementedError: an implementation is missing
  at scala.Predef$.$qmark$qmark$qmark(Predef.scala:225)
  at .foo(<console>:10)
  ... 33 elided

samthebest avatar May 03 '16 18:05 samthebest