scala - Why doesn't keys() and values() work on (String,String) one-pair RDD, while sortByKey() works -
i create rdd using readme.md file in spark directory. type of newrdd
(string,string)
val lines = sc.textfile("readme.md") val newrdd = lines.map(x => (x.split(" ")(0),x))
so, when try runnewrdd.values()
or newrdd.keys()
, error:
error: org.apache.spark.rdd.rdd[string] not take parameters newrdd.values()
or.keys()
resp.
what can understand error maybe string
data type cannot key (and think wrong). if that's case, why newrdd.sortbykey()
work ?
note: trying values()
, keys()
transformations because they're listed valid transformations one-pair rdds
edit: using apache spark version 1.5.2 in scala
it doesn't work values
(or keys
) receives no parameters , because of has called without parentheses:
val rdd = sc.parallelize(seq(("foo", "bar"))) rdd.keys.first // string = foo rdd.values.first // string = bar
Comments
Post a Comment