Partitioning is the process of determining which reducer instance will receive which intermediate keys and values. Each mapper must determine for all of its output (key, value) pairs which reducer will receive them. It is necessary that for any key, regardless of which mapper instance generated it, the destination partition is the same Problem: How does hadoop make it? Use a hash function? what is the default function?
相关问题
- facebook error invalid key hash for some devices
- Spark on Yarn Container Failure
- Change first key of multi-dimensional Hash in perl
- enableHiveSupport throws error in java spark code
- spark select and add columns with alias
相关文章
- Java写文件至HDFS失败
- mapreduce count example
- Bcrypt vs Hash in laravel
- What is the fastest way to map group names of nump
- Finding out whether there exist two identical subs
- Oracle STANDARD_HASH not available in PLSQL?
- Could you give me any clue Why 'Cannot call me
- Looking for a fast hash-function
The default partitioner in Hadoop is the
HashPartitioner
which has a method calledgetPartition
. It takeskey.hashCode() & Integer.MAX_VALUE
and finds the modulus using the number of reduce tasks.For example, if there are 10 reduce tasks,
getPartition
will return values 0 through 9 for all keys.Here is the code:
To create a custom partitioner, you would extend
Partitioner
, create a methodgetPartition
, then set your partitioner in the driver code (job.setPartitionerClass(CustomPartitioner.class);
). This is particularly helpful if doing secondary sort operations, for example.