HADOOP-13202. Avoid possible overflow in org.apache.hadoop.util.bloom.BloomFilter#getNBytes. Contributed by Kai Sasaki.
(cherry picked from commitc2bcffb34e
) (cherry picked from commit09375baad1
)
This commit is contained in:
parent
e3c4989d74
commit
cf79ac5fa9
|
@ -234,6 +234,6 @@ public class BloomFilter extends Filter {
|
||||||
|
|
||||||
/* @return number of bytes needed to hold bit vector */
|
/* @return number of bytes needed to hold bit vector */
|
||||||
private int getNBytes() {
|
private int getNBytes() {
|
||||||
return (vectorSize + 7) / 8;
|
return (int)(((long)vectorSize + 7) / 8);
|
||||||
}
|
}
|
||||||
}//end class
|
}//end class
|
||||||
|
|
|
@ -239,6 +239,18 @@ public class TestBloomFilters {
|
||||||
BloomFilterTestStrategy.FILTER_XOR_STRATEGY)).test();
|
BloomFilterTestStrategy.FILTER_XOR_STRATEGY)).test();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFiltersWithLargeVectorSize() {
|
||||||
|
int hashId = Hash.MURMUR_HASH;
|
||||||
|
Filter filter
|
||||||
|
= new BloomFilter(Integer.MAX_VALUE, hashFunctionNumber, hashId);
|
||||||
|
BloomFilterCommonTester.of(hashId, numInsertions)
|
||||||
|
.withFilterInstance(filter)
|
||||||
|
.withTestCases(ImmutableSet.of(
|
||||||
|
BloomFilterTestStrategy.WRITE_READ_STRATEGY
|
||||||
|
)).test();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNot() {
|
public void testNot() {
|
||||||
BloomFilter bf = new BloomFilter(8, 1, Hash.JENKINS_HASH);
|
BloomFilter bf = new BloomFilter(8, 1, Hash.JENKINS_HASH);
|
||||||
|
|
Loading…
Reference in New Issue