Skip to content

Instantly share code, notes, and snippets.

View deepankar14693's full-sized avatar
🎯
Focusing

deepankar14693

🎯
Focusing
View GitHub Profile
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
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")
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 {
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 = ""
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 = ""
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 = ""
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
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"
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
@deepankar14693
deepankar14693 / gist:e93f2ea30264fdec812e639e14097c15
Created February 22, 2018 04:48
spark-assignment not complete
///////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