You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@tajo.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2014/07/25 12:10:39 UTC
[jira] [Commented] (TAJO-976) HashPartitioner doesn't make desired
number of partitions infrequently.
[ https://issues.apache.org/jira/browse/TAJO-976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14074254#comment-14074254 ]
ASF GitHub Bot commented on TAJO-976:
-------------------------------------
GitHub user babokim opened a pull request:
https://github.com/apache/tajo/pull/94
TAJO-976: HashPartitioner doesn't make desired number of partitions infrequently.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/babokim/tajo TAJO-976
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/tajo/pull/94.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #94
----
commit ac6de2cb4128bdf9c1567839b8b1ef8272738510
Author: 김형준 <ba...@babokim-mbp.server.gruter.com>
Date: 2014-07-25T10:07:50Z
TAJO-976: HashPartitioner doesn't make desired number of partitions infrequently.
----
> 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)