HADOOP-11327. BloomFilter#not() omits the last bit, resulting in an incorrect filter. Contributed by Eric Payne

This commit is contained in:
Jason Lowe 2015-01-21 19:04:29 +00:00
parent 42715547f0
commit 07b0806036
3 changed files with 15 additions and 1 deletions

View File

@ -731,6 +731,9 @@ Release 2.7.0 - UNRELEASED
HADOOP-10668. TestZKFailoverControllerStress#testExpireBackAndForth HADOOP-10668. TestZKFailoverControllerStress#testExpireBackAndForth
occasionally fails. (Ming Ma via cnauroth) 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 Release 2.6.0 - 2014-11-18
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -157,7 +157,7 @@ public class BloomFilter extends Filter {
@Override @Override
public void not() { public void not() {
bits.flip(0, vectorSize - 1); bits.flip(0, vectorSize);
} }
@Override @Override

View File

@ -23,6 +23,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.util.AbstractCollection; import java.util.AbstractCollection;
import java.util.BitSet;
import java.util.Iterator; import java.util.Iterator;
import org.apache.hadoop.util.bloom.BloomFilterCommonTester.BloomFilterTestStrategy; import org.apache.hadoop.util.bloom.BloomFilterCommonTester.BloomFilterTestStrategy;
@ -237,4 +238,14 @@ public class TestBloomFilters {
BloomFilterTestStrategy.FILTER_AND_STRATEGY, BloomFilterTestStrategy.FILTER_AND_STRATEGY,
BloomFilterTestStrategy.FILTER_XOR_STRATEGY)).test(); 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));
}
} }