Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Run Sandbox and connect to it from SSH
- ssh root@127.0.0.1 -p 2222
- # Launch Spark-Shell
- spark-shell --master yarn-client --driver-memory 512m --executor-memory 512m
- # Mutable values
- var a: Int = 5
- a = a + 1
- println(a)
- # Immutable values
- val b: Int = 7
- b = b + 1 //Error
- println(b)
- # Type Inference
- var c = 9
- println(c.getClass)
- val d = 9.9
- println(d.getClass)
- val e = "Hello"
- println(e.getClass)
- # Functions
- def cube(x: Int): Int = {
- val x2 = x * x * x
- x2
- }
- cube(3)
- def cube(x: Int) = x*x*x
- cube(4)
- # Anonymous Functions
- val sqr: Int => Int = x => x * x
- sqr(2)
- val thrice: Int => Int = _ * 3
- thrice(15)
- # Collections
- val strs = Array("This", "is", "happening")
- strs.map(_.reverse)
- strs.reduce(_+" "+_)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement