[
https://issues.apache.org/jira/browse/S4-30?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13174158#comment-13174158
]
Quoc Nguyen commented on S4-30:
-------------------------------
Matthieu,
This is what I do reproduce the bug:
1) Clone the latest S4 in github (https://github.com/s4/s4.git)
2) Build it.
3) Create a Java project in Eclipse.
4) Add external Jar (s4-core) file.
5) Create a test class (NegativeHasherReproduction)
6) Use the above keys and hash them which shows the result.
This is a code snipet that illustrates the bug:
package com.negative.hasher;
import org.apache.s4.dispatcher.partitioner.DefaultHasher;
/**
* @author Quoc Nguyen
*
*/
public class NegativeHasherReproduction
{
public static void main(String[] args)
{
String[] keys = new String[] {"118+18233", "118+17360", "118+17258",
"118+18147", "118+18121"};
DefaultHasher hasher = new DefaultHasher();
final int PARTITIONCOUNT = 5;
for (String key: keys)
{
// This line of code is taken exactly from DefaultPartitioner
int partition = (int)hasher.hash(key) % PARTITIONCOUNT;
System.out.println(partition);
// Results below:
/*
-4
-1
-1
-4
-1
*/
}
}
}
> DefaultHasher hashes keys to negative number
> --------------------------------------------
>
> Key: S4-30
> URL: https://issues.apache.org/jira/browse/S4-30
> Project: Apache S4
> Issue Type: Bug
> Affects Versions: 0.4
> Environment: All - Windows and Linux
> Reporter: Quoc Nguyen
> Priority: Blocker
>
> DefaultHasher uses HashAlgorithm hashAlgorithm = HashAlgorithm.FNV1_64_HASH;
> which hashes key strings such as 118+18233, 118+17360, 118+17258, 118+18147
> and 118+18121 and many more to negative values which the DefaultPartitioner
> (int partitionId = (int) (hasher.hash(stringValue) % partitionCount);) tries
> to partition the key to incorrect partition.
> Workaround:
> None - stream has those keys, they will get dropped because the partitioner
> cannot correctly partition.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira