[ 
https://issues.apache.org/jira/browse/SPARK-9746?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14679279#comment-14679279
 ] 

Sean Owen commented on SPARK-9746:
----------------------------------

No, it doesn't:

{code}
scala> val rdd = sc.parallelize(Array(("foo", "bar"), ("foo", "bing"), ("buzz", 
"bizz")))
rdd: org.apache.spark.rdd.RDD[(String, String)] = ParallelCollectionRDD[0] at 
parallelize at <console>:15

scala> rdd.countByKey()
res0: scala.collection.Map[String,Long] = Map(buzz -> 1, foo -> 2)
{code}

My guess is your key class is not a string, but some custom class that maybe 
does not implement the notion of equality you expect?

> PairRDDFunctions.countByKey: values/counts always 1
> ---------------------------------------------------
>
>                 Key: SPARK-9746
>                 URL: https://issues.apache.org/jira/browse/SPARK-9746
>             Project: Spark
>          Issue Type: Bug
>          Components: Spark Core
>    Affects Versions: 1.4.0
>            Reporter: Andreas
>
> org.apache.spark.rdd.PairRDDFunctionscountByKey(): Map[K, Long] = 
> self.withScope {
>     self.mapValues(_ => 1L).reduceByKey(_ + _).collect().toMap
>   }
> obviously always returns count 1 for each key.
> If I understand the docs correctly I would expect this implementation:
> self.mapValues(_.size).reduceByKey(_ + _).collect().toMap



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to