score:1
foreach is, as ryan pointed out, solely for side-effects. it returns unit and not the list itself. ergo no chaining.
now what you are actually doing is the following:
val output = ranks.collect()
val realoutput: unit = output.foreach(tup => println(tup._1 + " has page rank: " + tup._2))
realoutput.saveastextfile(...)
saveastextfile
is not a member of unit
and you get your error message
you should be doing:
ranks.foreach(tup => println(tup._1 + " has page rank: " + tup._2))
ranks.saveastextfile(...)
or
ranks.saveastextfile(...)
ranks.collect().foreach(tup => println(tup._1 + " has page rank: " + tup._2))
Source: stackoverflow.com
Related Query
- error: value saveAsTextFile is not a member of Unit
- Scala Compilation Error : Value += is not member of Int
- Eclipse Scala Worksheet error value is not a member of object
- Error value flatMap is not a member of Product with Serializable in for with Future[Option]
- ERROR : value += is not a member of Long Scala
- value saveAsTextFile is not a member of org.apache.spark.streaming.dstream.DStream[(String, Long)]
- value - is not a member of type parameter T | Scala Error
- scala.collections.javaconverters._ Error : value map is not a member of java.util.Set
- Scala: value next is not a member of T compilation error
- scala self-type: value is not a member error
- error: value saveAsTextFile is not a member of scala.collection.Map[String,Long]
- Error in forEach Spark Scala : value select is not a member of org.apache.spark.sql.Row
- Scala Scala.js importing JavaScript module gives error 'method value is not a member of'
- error: value show is not a member of Unit CaseFileDFTemp.show()
- Error not found for object and value in Scala Unit Testing
- ScalaARM error - value filter is not a member of ManagedResource
- how to solve this error value toDS is not a member of org.apache.spark.rdd.RDD?
- value toInt is not a member of Array[String] error
- ubuntu scala ide - spark - toDF Method error value toDF is not a member of org.apache.spark.rdd.RDD[String]
- value session is not a member of Unit
- Play error: value and is not a member of play.api.libs.json
- Scala Java Error: value filter is not a member of java.util.Map. Works outside of class
- Object is not a value error in scala
- Scala-Cats Validated: value mapN is not a member of ValidatedNel tuple
- Error: value seq is not a member of object slick.dbio.DBIO
- Error in running Spark in Intellij : "object apache is not a member of package org"
- value reduceByKey is not a member of org.apache.spark.rdd.RDD
- value isBlank is not a member of String
- Scala error: value sort is not a member of List
- scala value toInt is not a member of Any
More Query from same tag
- Is it correct to return IndexesSeq instead of Array if an immutable array is needed in Scala?
- Comments convention "// $example on:" and "// $example off:" in Scala and Java
- How do I mitigate memory leaks when recursively calling a function inside a Future[T]?
- How to construct a case class for this json input and convert it to an object?
- Failure on `system` definition
- How scale a Elasticbeanstalk application worker on based on messages from SQS?
- Reduce by key in an array of arrays in Scala
- Is there a more concise way to remove a top level JSON property using Argonaut?
- AsyncTask.doInBackground - abstract method not implemented error in Android Scala project
- How to disable Scala warning "The outer reference in this type test cannot be checked at run time"
- Executing Scala via TextMate
- Elegant Handling of Scala Future[Either]]
- How to create a dynamic expression in the filter?
- Get the Unicode when an emoji is provided as input using scala
- Making json files in Scala
- How to rate limit function call in a loop in Scala
- Can Slick Delete/Update DB Query return Negative Integer Values as the result
- Implicit conversions in the context of a (case) class constructor
- Is it possible to have a Map[String,Any] with the name and the values of named parameters in Scala?
- Spark scala:-Getting error the way i am trying to use if statement within reduceByKey
- Compiler do not recognize function overloading because types are erased. How to overcome this?
- foo: { $gt: "A", $lt: "Z"}; How do I write this in the scala driver?
- Updating column value in loop in spark
- Websocket - Sink.actorRefWithAck and Source.queue - only one request TO server gets processed?
- casting UTC unixtime to timestamp in the same timezone
- Get default case class arguments via Shapeless
- Creating a TestActorRef results in NullPointerException
- Make an Actor send a poisonpill to itself when using pipe pattern
- How can I debug why a sys.process command from scala is failing with bad exit code (3) when it works from the command line?
- List contains Object => Object