Skip to content

Instantly share code, notes, and snippets.

@noiano
Created February 3, 2011 17:14
Show Gist options
  • Save noiano/809793 to your computer and use it in GitHub Desktop.
Save noiano/809793 to your computer and use it in GitHub Desktop.
public class TermPartitioner extends Partitioner<PairOfStringInt, PairOfWritables<Text, ArrayListOfIntsWritable>> {
public int getPartition(PairOfStringInt key, PairOfWritables<Text, ArrayListOfIntsWritable> value, int numPartitions) {
return (key.getLeftElement().hashCode() & Integer.MAX_VALUE) % numPartitions;
}
}
@QwertyManiac
Copy link

Your partitioner should be:

return (key.getLeftElement().hashCode() & Integer.MAX_VALUE) % numPartitions;

For it to work with https://gist.github.com/809803

@noiano
Copy link
Author

noiano commented Feb 4, 2011

Thank you for you hint but strangely the mapper produce the same output like before :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment