org.apache.spark
Class HashPartitioner

Object
  extended by org.apache.spark.Partitioner
      extended by org.apache.spark.HashPartitioner
All Implemented Interfaces:
java.io.Serializable

public class HashPartitioner
extends Partitioner

A Partitioner that implements hash-based partitioning using Java's Object.hashCode.

Java arrays have hashCodes that are based on the arrays' identities rather than their contents, so attempting to partition an RDD[Array[_} or RDD[(Array[_], _)] using a HashPartitioner will produce an unexpected or incorrect result.

See Also:
Serialized Form

Constructor Summary
HashPartitioner(int partitions)
           
 
Method Summary
 boolean equals(Object other)
           
 int getPartition(Object key)
           
 int hashCode()
           
 int numPartitions()
           
 
Methods inherited from class org.apache.spark.Partitioner
defaultPartitioner
 
Methods inherited from class Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashPartitioner

public HashPartitioner(int partitions)
Method Detail

numPartitions

public int numPartitions()
Specified by:
numPartitions in class Partitioner

getPartition

public int getPartition(Object key)
Specified by:
getPartition in class Partitioner

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object