public int getPartition(K key, V value,
                          int numReduceTasks) {
    return (key.hashCode() & Integer.MAX_VALUE) % numReduceTasks;
  }
public int getPartition ( K key , V value , int numReduceTasks ) { return ( key . hashCode ( ) & Integer . MAX_VALUE ) % numReduceTasks ; }
Use {@link Object#hashCode()} to partition.