#NoPayJan Offer - Access all CloudxLab Courses for free between 1st to 31st Jan

  Enroll Now >>

Apache Spark - Transformations - map & filter

INSTRUCTIONS
  • Map Transformation code in Scala

    val arr = 1 to 10000
    val nums = sc.parallelize(arr)
    def multiplyByTwo(x:Int):Int = x*2
    multiplyByTwo(5)
    

    [Out]: 10

    var dbls = nums.map(multiplyByTwo);
    dbls.take(5)
    

    [Out]: [2, 4, 6, 8, 10]

  • Transformations - filter() code in Scala

    var arr = 1 to 1000
    var nums = sc.parallelize(arr)
    def isEven(x:Int):Boolean = x%2 == 0
    
    var evens = nums.filter(isEven)
    evens.take(3)
    

No hints are availble for this assesment

Answer is not availble for this assesment

Loading comments...