[
https://issues.apache.org/jira/browse/SPARK-9746?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14662523#comment-14662523
]
Sean Owen commented on SPARK-9746:
----------------------------------
It does not count the number of distinct keys, nor does it count distinct
values for the key, so I don't think that's accurate. It counts the number of
times each key appears. I suppose there are many ways of saying this; here it
says it counts the number of elements that include each key, which seems like a
reasonable description of the behavior.
> 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]