HashPartitioner (Hadoop 1.2.1 API) (original) (raw)
org.apache.hadoop.mapred.lib
Class HashPartitioner<K2,V2>
java.lang.Object
org.apache.hadoop.mapred.lib.HashPartitioner<K2,V2>
All Implemented Interfaces:
JobConfigurable, Partitioner<K2,V2>
public class HashPartitioner<K2,V2>
extends Object
implements Partitioner<K2,V2>
Partition keys by their Object.hashCode().
Constructor Summary |
---|
HashPartitioner() |
Method Summary | |
---|---|
void | configure(JobConf job) Initializes a new instance from a JobConf. |
int | [getPartition](../../../../../org/apache/hadoop/mapred/lib/HashPartitioner.html#getPartition%28K2, V2, int%29)(K2 key,V2 value, int numReduceTasks) Use Object.hashCode() to partition. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
HashPartitioner
public HashPartitioner()
Method Detail |
---|
configure
public void configure(JobConf job)
Description copied from interface: [JobConfigurable](../../../../../org/apache/hadoop/mapred/JobConfigurable.html#configure%28org.apache.hadoop.mapred.JobConf%29)
Initializes a new instance from a JobConf.
Specified by:
[configure](../../../../../org/apache/hadoop/mapred/JobConfigurable.html#configure%28org.apache.hadoop.mapred.JobConf%29)
in interface [JobConfigurable](../../../../../org/apache/hadoop/mapred/JobConfigurable.html "interface in org.apache.hadoop.mapred")
Parameters:
job
- the configuration
getPartition
public int getPartition(K2 key, V2 value, int numReduceTasks)
Use Object.hashCode() to partition.
Specified by:
[getPartition](../../../../../org/apache/hadoop/mapred/Partitioner.html#getPartition%28K2, V2, int%29)
in interface [Partitioner](../../../../../org/apache/hadoop/mapred/Partitioner.html "interface in org.apache.hadoop.mapred")<[K2](../../../../../org/apache/hadoop/mapred/lib/HashPartitioner.html "type parameter in HashPartitioner"),[V2](../../../../../org/apache/hadoop/mapred/lib/HashPartitioner.html "type parameter in HashPartitioner")>
Parameters:
key
- the key to be paritioned.
value
- the entry value.
numReduceTasks
- the total number of partitions.
Returns:
the partition number for the key
.
Copyright © 2009 The Apache Software Foundation