Repository: hadoop Updated Branches: refs/heads/trunk 42715547f -> 07b080603
HADOOP-11327. BloomFilter#not() omits the last bit, resulting in an incorrect filter. Contributed by Eric Payne Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/07b08060 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/07b08060 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/07b08060 Branch: refs/heads/trunk Commit: 07b08060369caf34f248745a10bda61fb0a3ef23 Parents: 4271554 Author: Jason Lowe <jl...@apache.org> Authored: Wed Jan 21 19:04:29 2015 +0000 Committer: Jason Lowe <jl...@apache.org> Committed: Wed Jan 21 19:04:29 2015 +0000 ---------------------------------------------------------------------- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../java/org/apache/hadoop/util/bloom/BloomFilter.java | 2 +- .../org/apache/hadoop/util/bloom/TestBloomFilters.java | 11 +++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/07b08060/hadoop-common-project/hadoop-common/CHANGES.txt ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 2951002..c54800f 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -731,6 +731,9 @@ Release 2.7.0 - UNRELEASED HADOOP-10668. TestZKFailoverControllerStress#testExpireBackAndForth occasionally fails. (Ming Ma via cnauroth) + HADOOP-11327. BloomFilter#not() omits the last bit, resulting in an + incorrect filter (Eric Payne via jlowe) + Release 2.6.0 - 2014-11-18 INCOMPATIBLE CHANGES http://git-wip-us.apache.org/repos/asf/hadoop/blob/07b08060/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/bloom/BloomFilter.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/bloom/BloomFilter.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/bloom/BloomFilter.java index e2dea6d..f8b9519 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/bloom/BloomFilter.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/bloom/BloomFilter.java @@ -157,7 +157,7 @@ public class BloomFilter extends Filter { @Override public void not() { - bits.flip(0, vectorSize - 1); + bits.flip(0, vectorSize); } @Override http://git-wip-us.apache.org/repos/asf/hadoop/blob/07b08060/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/bloom/TestBloomFilters.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/bloom/TestBloomFilters.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/bloom/TestBloomFilters.java index 93fa6d5..6ff854d 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/bloom/TestBloomFilters.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/bloom/TestBloomFilters.java @@ -23,6 +23,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.AbstractCollection; +import java.util.BitSet; import java.util.Iterator; import org.apache.hadoop.util.bloom.BloomFilterCommonTester.BloomFilterTestStrategy; @@ -237,4 +238,14 @@ public class TestBloomFilters { BloomFilterTestStrategy.FILTER_AND_STRATEGY, BloomFilterTestStrategy.FILTER_XOR_STRATEGY)).test(); } + + @Test + public void testNot() { + BloomFilter bf = new BloomFilter(8, 1, Hash.JENKINS_HASH); + bf.bits = BitSet.valueOf(new byte[] { (byte) 0x95 }); + BitSet origBitSet = (BitSet) bf.bits.clone(); + bf.not(); + assertFalse("BloomFilter#not should have inverted all bits", + bf.bits.intersects(origBitSet)); + } }