Class TotalOrderPartitioner<K,V>
java.lang.Object
org.apache.hadoop.mapreduce.Partitioner<K,V>
org.apache.hadoop.mapreduce.lib.partition.TotalOrderPartitioner<K,V>
- All Implemented Interfaces:
Configurable
- Direct Known Subclasses:
TotalOrderPartitioner
@Public
@Stable
public class TotalOrderPartitioner<K,V>
extends Partitioner<K,V>
implements Configurable
Partitioner effecting a total order by reading split points from
an externally generated source.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetConf()Return the configuration used by this object.intgetPartition(K key, V value, int numPartitions) Get the partition number for a given key (hence record) given the total number of partitions i.e. number of reduce-tasks for the job.static StringGet the path to the SequenceFile storing the sorted partition keyset.voidsetConf(Configuration conf) Read in the partition file and build indexing data structures.static voidsetPartitionFile(Configuration conf, Path p) Set the path to the SequenceFile storing the sorted partition keyset.
-
Field Details
-
DEFAULT_PATH
- See Also:
-
PARTITIONER_PATH
- See Also:
-
MAX_TRIE_DEPTH
- See Also:
-
NATURAL_ORDER
- See Also:
-
-
Constructor Details
-
TotalOrderPartitioner
public TotalOrderPartitioner()
-
-
Method Details
-
setConf
Read in the partition file and build indexing data structures. If the keytype isBinaryComparableandtotal.order.partitioner.natural.orderis not false, a trie of the firsttotal.order.partitioner.max.trie.depth(2) + 1 bytes will be built. Otherwise, keys will be located using a binary search of the partition keyset using theRawComparatordefined for this job. The input file must be sorted with the same comparator and containJobContextImpl.getNumReduceTasks()- 1 keys.- Specified by:
setConfin interfaceConfigurable- Parameters:
conf- configuration to be used
-
getConf
Description copied from interface:ConfigurableReturn the configuration used by this object.- Specified by:
getConfin interfaceConfigurable- Returns:
- Configuration
-
getPartition
Description copied from class:PartitionerGet the partition number for a given key (hence record) given the total number of partitions i.e. number of reduce-tasks for the job.Typically a hash function on a all or a subset of the key.
- Specified by:
getPartitionin classPartitioner<K,V> - Parameters:
key- the key to be partioned.value- the entry value.numPartitions- the total number of partitions.- Returns:
- the partition number for the
key.
-
setPartitionFile
Set the path to the SequenceFile storing the sorted partition keyset. It must be the case that forRreduces, there areR-1keys in the SequenceFile. -
getPartitionFile
Get the path to the SequenceFile storing the sorted partition keyset.- See Also:
-