Skip to content

Instantly share code, notes, and snippets.

Created August 26, 2012 08:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3475992 to your computer and use it in GitHub Desktop.
Save anonymous/3475992 to your computer and use it in GitHub Desktop.
Data Intensive Text Processing with MapReduce #3 figure3.8.x Partitioner
package info.moaikids.mapred.partitioner;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;
public class Figure38xPartitioner extends Partitioner<Text, IntWritable> {
@Override
public int getPartition(Text key, IntWritable value, int numPartitions) {
String[] params = key.toString().split(" ");
return (params[0].hashCode() & Integer.MAX_VALUE) % numPartitions;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment