How does HashPartitioner work?

后端 未结 3 1858
面向向阳花
面向向阳花 2020-11-22 14:56

I read up on the documentation of HashPartitioner. Unfortunately nothing much was explained except for the API calls. I am under the assumption that HashPartitioner

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 15:36

    RDD is distributed this means it is split on some number of parts. Each of this partitions is potentially on different machine. Hash partitioner with argument numPartitions chooses on what partition to place pair (key, value) in following way:

    1. Creates exactly numPartitions partitions.
    2. Places (key, value) in partition with number Hash(key) % numPartitions

提交回复
热议问题