You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@tajo.apache.org by "Hyoungjun Kim (JIRA)" <ji...@apache.org> on 2014/07/24 10:43:38 UTC
[jira] [Created] (TAJO-976) HashPartitioner doesn't make desired
number of partitions infrequently.
Hyoungjun Kim created TAJO-976:
----------------------------------
Summary: HashPartitioner doesn't make desired number of partitions infrequently.
Key: TAJO-976
URL: https://issues.apache.org/jira/browse/TAJO-976
Project: Tajo
Issue Type: Improvement
Reporter: Hyoungjun Kim
Assignee: Hyoungjun Kim
Priority: Minor
If the number desired partition is a multiples of 31, HashPartitioner doesn't make desired number of partitions. I tested with the following code.
{code}
Random rand = new Random();
String[][] data = new String[1000][];
for (int i = 0; i < 1000; i++) {
data[i] = new String[]{ String.valueOf(rand.nextInt(1000)), String.valueOf(rand.nextInt(1000)), String.valueOf(rand.nextInt(1000))};
}
int[] testNumPartitions = new int[]{31, 62, 124, 32, 63, 125};
for (int index = 0; index < testNumPartitions.length; index++) {
Set<Integer> ids = new TreeSet<Integer>();
for (int i = 0; i < data.length; i++) {
VTuple vtuple = new VTuple(new Datum[]{new TextDatum(data[i][0]), new TextDatum(data[i][1]), new TextDatum(data[i][2])});
int hashValue = vtuple.hashCode();
int partitionId = (hashValue & Integer.MAX_VALUE) % testNumPartitions[index];
ids.add(partitionId);
}
System.out.println("Expected partition num: " + testNumPartitions[index] + ", real partition num:" + ids.size());
}
{code}
{noformat}
Expected partition num: 31, real partition num:10
Expected partition num: 62, real partition num:20
Expected partition num: 124, real partition num:40
Expected partition num: 32, real partition num:32
Expected partition num: 63, real partition num:63
Expected partition num: 125, real partition num:125
{noformat}
--
This message was sent by Atlassian JIRA
(v6.2#6252)