KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > nutch > mapReduce > DefaultPartitioner


1 /* Copyright (c) 2005 The Nutch Organization. All rights reserved. */
2 /* Use subject to the conditions in http://www.nutch.org/LICENSE.txt. */
3
4 package net.nutch.mapReduce;
5
6 import net.nutch.io.Writable;
7 import net.nutch.io.WritableComparable;
8
9 /** The default {@link Partitioner}. Uses {@link Object#hashCode()} to
10  * partition keys. */

11 public class DefaultPartitioner implements Partitioner {
12
13   /** Use {@link Object#hashCode()} to partition. */
14   public int getPartition(WritableComparable key, int numReduceTasks) {
15     return (key.hashCode() & Integer.MAX_VALUE) % numReduceTasks;
16   }
17
18 }
19
Popular Tags