Created
August 26, 2012 08:04
-
-
Save anonymous/3475992 to your computer and use it in GitHub Desktop.
Data Intensive Text Processing with MapReduce #3 figure3.8.x Partitioner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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