This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.collection.mutable.ListBuffer | |
case class Student(rollNum: Int, name: String) | |
trait Students { | |
val students = ListBuffer(Student(1, "Ayush"), Student(2, "deepankar")) | |
def fetchStudents: ListBuffer[Student] = students |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version := "0.1" | |
scalaVersion := "2.12.6" | |
libraryDependencies ++= Seq("com.typesafe.akka" %% "akka-http" % "10.0.11", | |
"org.json4s" %% "json4s-native" % "3.2.11", | |
"org.scalatest" %% "scalatest" % "3.0.1" % Test, | |
"org.mockito" % "mockito-core" % "2.11.0" % Test, | |
"com.typesafe.akka" %% "akka-http-testkit" % "10.1.1") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import akka.actor.ActorSystem | |
import akka.http.scaladsl.Http | |
import akka.http.scaladsl.model._ | |
import akka.http.scaladsl.server.Directives._ | |
import akka.stream.ActorMaterializer | |
import scala.concurrent.ExecutionContextExecutor | |
//the usual config code required for an Akka Http server, mixing in our JsonHelper trait too | |
object Routes extends App with JsonHelper { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.json4s.{DefaultFormats, Formats, JNothing, JValue} | |
import org.json4s.native.JsonMethods.{parse => jParser} | |
import org.json4s.native.Serialization | |
import org.json4s.native.Serialization.{write => jWrite} | |
trait JsonHelper extends { | |
val EMPTY_STRING = "" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.json4s.{DefaultFormats, Formats, JNothing, JValue} | |
import org.json4s.native.JsonMethods.{parse => jParser} | |
import org.json4s.native.Serialization | |
import org.json4s.native.Serialization.{write => jWrite} | |
trait JsonHelper extends { | |
val EMPTY_STRING = "" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.json4s.{DefaultFormats, Formats, JNothing, JValue} | |
import org.json4s.native.JsonMethods.{parse => jParser} | |
import org.json4s.native.Serialization | |
import org.json4s.native.Serialization.{write => jWrite} | |
trait JsonHelper extends { | |
val EMPTY_STRING = "" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.collection.mutable.ListBuffer | |
class Students { | |
val students = ListBuffer(Student(1, "Ayush"), Student(2, "deepankar")) | |
def fetchStudents: ListBuffer[Student] = students | |
def addStudent(student: Student): ListBuffer[Student] = { | |
student +: students |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name := "BlogContent" | |
version := "0.1" | |
scalaVersion := "2.12.6" | |
libraryDependencies += "com.typesafe.akka" %% "akka-http" % "10.0.11" | |
libraryDependencies += "org.json4s" %% "json4s-native" % "3.2.11" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.collection.mutable.ListBuffer | |
class Students { | |
val students = ListBuffer(Student(1, "Ayush"), Student(2, "deepankar")) | |
def fetchStudents: ListBuffer[Student] = students | |
def addStudent(student: Student): ListBuffer[Student] = { | |
student +: students |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///////question 2 | |
val x = sc.parallelize(List(1,1,2,3,4).distinct) | |
x: org.apache.spark.rdd.RDD[Int] = ParallelCollectionRDD[0] at parallelize at <console>:24 | |
scala> x.collect | |
res0: Array[Int] = Array(1, 2, 3, 4) | |
scala> val y = sc.parallelize(List(1,2,3,4)) | |
y: org.apache.spark.rdd.RDD[Int] = ParallelCollectionRDD[1] at parallelize at <console>:24 |