Explain sum(), max(), min() operation in Apache Spark.

Free Online Certification Courses – Learn Today. Lead Tomorrow. Forums Apache Spark Explain sum(), max(), min() operation in Apache Spark.

Viewing 1 reply thread
  • Author
    Posts
    • #5066
      DataFlair TeamDataFlair Team
      Spectator

      Explain sum(), max(), min() operation in Apache Spark.

    • #5067
      DataFlair TeamDataFlair Team
      Spectator

      sum() :

      > It adds up the value in an RDD.
      > It is an package org.apache.spark.rdd.DoubleRDDFunctions.
      > Its return type is Double

      Example:

      val rdd1 = sc.parallelize(1 to 20)
      rdd1.sum


      Output:

      Double = 210.0


      max() :

      > It returns a max value from RDD element defined by implicit ordering (element order)
      > It is an package org.apache.spark.rdd

      Example:

      val rdd1 = sc.parallelize(List(1,5,9,0,23,56,99,87))
      rdd1.max


      Output:

      Int = 99

      min() :

      > It returns a min value from RDD element defined by implicit ordering (element order)
      > It is an package org.apache.spark.rdd

      Example:

      val rdd1 = sc.parallelize(List(1,5,9,0,23,56,99,87))
      rdd1.min


      Output:

      Int = 0

      For more operations on RDD read Spark RDD Operations.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.