Class HashPartitioner

  • All Implemented Interfaces:

    public final class HashPartitioner
    extends java.lang.Object
    implements Partitioner<java.lang.Integer>
    An implementation of Partitioner which hashes output data from a source task according to the key of elements. The data will be hashed by their key, and applied "modulo" operation by the number of partitions.
    • Constructor Summary

      Constructor Description
      HashPartitioner​(int numOfPartitions, KeyExtractor keyExtractor)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Integer partition​(java.lang.Object element)
      Divides the output data from a task into multiple blocks.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HashPartitioner

        public HashPartitioner​(int numOfPartitions,
                               KeyExtractor keyExtractor)
        numOfPartitions - the number of partitions.
        keyExtractor - the key extractor that extracts keys from elements.
    • Method Detail

      • partition

        public java.lang.Integer partition​(java.lang.Object element)
        Description copied from interface: Partitioner
        Divides the output data from a task into multiple blocks.
        Specified by:
        partition in interface Partitioner<java.lang.Integer>
        element - the output element from a source task.
        the key of the partition in the block to write the element.