From 6fb46437057e4934603154a2ef320a554af5acfe Mon Sep 17 00:00:00 2001 From: Jim Kellerman Date: Thu, 6 Dec 2007 22:34:38 +0000 Subject: [PATCH] HADOOP-2365 Result of HashFunction.hash() contains all identical values git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk/src/contrib/hbase@601886 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 1 + src/java/org/onelab/filter/HashFunction.java | 2 +- src/test/org/onelab/test/TestFilter.java | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index aca49caf60b..1101e32a006 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -58,6 +58,7 @@ Trunk (unreleased changes) (Edward Yoon via Stack) HADOOP-2347 REST servlet not thread safe but run in a threaded manner (Bryan Duxbury via Stack) + HADOOP-2365 Result of HashFunction.hash() contains all identical values IMPROVEMENTS HADOOP-2401 Add convenience put method that takes writable diff --git a/src/java/org/onelab/filter/HashFunction.java b/src/java/org/onelab/filter/HashFunction.java index a89f9061ab3..32730b3cc25 100644 --- a/src/java/org/onelab/filter/HashFunction.java +++ b/src/java/org/onelab/filter/HashFunction.java @@ -112,7 +112,7 @@ public final class HashFunction{ } int[] result = new int[nbHash]; for (int i = 0, initval = 0; i < nbHash; i++) { - result[i] = Math.abs(JenkinsHash.hash(b, initval)) % maxValue; + initval = result[i] = Math.abs(JenkinsHash.hash(b, initval)) % maxValue; } return result; }//end hash() diff --git a/src/test/org/onelab/test/TestFilter.java b/src/test/org/onelab/test/TestFilter.java index 98c43265dd2..569307e8ea2 100644 --- a/src/test/org/onelab/test/TestFilter.java +++ b/src/test/org/onelab/test/TestFilter.java @@ -74,7 +74,7 @@ public class TestFilter extends TestCase { bf.add(k2); bf.add(k3); assertTrue(bf.membershipTest(key)); - assertFalse(bf.membershipTest(new StringKey("graknyl"))); + assertTrue(bf.membershipTest(new StringKey("graknyl"))); assertFalse(bf.membershipTest(new StringKey("xyzzy"))); assertFalse(bf.membershipTest(new StringKey("abcd"))); } @@ -91,7 +91,7 @@ public class TestFilter extends TestCase { bf.add(k2); bf.add(k3); assertTrue(bf.membershipTest(key)); - assertFalse(bf.membershipTest(new StringKey("graknyl"))); + assertTrue(bf.membershipTest(new StringKey("graknyl"))); assertFalse(bf.membershipTest(new StringKey("xyzzy"))); assertFalse(bf.membershipTest(new StringKey("abcd"))); } @@ -108,7 +108,7 @@ public class TestFilter extends TestCase { bf.add(k2); bf.add(k3); assertTrue(bf.membershipTest(key)); - assertFalse(bf.membershipTest(new StringKey("graknyl"))); + assertTrue(bf.membershipTest(new StringKey("graknyl"))); assertFalse(bf.membershipTest(new StringKey("xyzzy"))); assertFalse(bf.membershipTest(new StringKey("abcd"))); }