Explain first() operation

Viewing 1 reply thread
  • Author
    Posts
    • #5081
      DataFlair Team
      Moderator

      Explain first() operation

    • #5084
      DataFlair Team
      Moderator

      > It is an action.
      > It returns the first element of the RDD.

      Example :

      val rdd1 = sc.textFile("/home/hdadmin/wc-data.txt")
      rdd1.count
      rdd1.first

      Output :
      Long: 20
      String : DataFlair is the leading technology training provider

      for more Actions on RDD refer: Transformation and Action

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