hbase-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jonathan Ellis (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HBASE-1136) HashFunction inadvertently destroys some randomness
Date Tue, 20 Jan 2009 00:54:59 GMT

    [ https://issues.apache.org/jira/browse/HBASE-1136?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12665298#action_12665298
] 

Jonathan Ellis commented on HBASE-1136:
---------------------------------------

oh, I see what is going on.  it's a bad test.

    Key key = new StringKey("toto");
    Key k2 = new StringKey("lulu");
    Key k3 = new StringKey("mama");
    bf.add(key);
    bf.add(k2);
    bf.add(k3);
    assertTrue(bf.membershipTest(key));
    assertTrue(bf.membershipTest(new StringKey("graknyl")));

graknyl was never added.  it's relying on the implementation details of the old (broken) HashFunction.

do you want me to just rip stuff like that out?

> HashFunction inadvertently destroys some randomness
> ---------------------------------------------------
>
>                 Key: HBASE-1136
>                 URL: https://issues.apache.org/jira/browse/HBASE-1136
>             Project: Hadoop HBase
>          Issue Type: Bug
>            Reporter: Jonathan Ellis
>             Fix For: 0.20.0
>
>         Attachments: hash.patch
>
>
> the code
>       for (int i = 0, initval = 0; i < nbHash; i++) {
>         initval = result[i] = Math.abs(hashFunction.hash(b, initval) % maxValue);
>       }
> restricts initval for the next hash to the [0, maxValue) range of the hash indexes returned.
 This is suboptimal, particularly for larger nbHash and smaller maxValue.  Instead, use:
>       for (int i = 0, initval = 0; i < nbHash; i++) {
>         initval = hashFunction.hash(b, initval);
>         result[i] = Math.abs(initval) % maxValue;
>       }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message