hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aajis...@apache.org
Subject hadoop git commit: HADOOP-13202. Avoid possible overflow in org.apache.hadoop.util.bloom.BloomFilter#getNBytes. Contributed by Kai Sasaki.
Date Mon, 18 Jul 2016 18:49:09 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk 76be82bc0 -> c2bcffb34


HADOOP-13202. Avoid possible overflow in org.apache.hadoop.util.bloom.BloomFilter#getNBytes.
Contributed by Kai Sasaki.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/c2bcffb3
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/c2bcffb3
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/c2bcffb3

Branch: refs/heads/trunk
Commit: c2bcffb34ebe4399b523a44f69d23761648bd0c4
Parents: 76be82b
Author: Akira Ajisaka <aajisaka@apache.org>
Authored: Mon Jul 18 11:42:56 2016 -0700
Committer: Akira Ajisaka <aajisaka@apache.org>
Committed: Mon Jul 18 11:48:23 2016 -0700

----------------------------------------------------------------------
 .../java/org/apache/hadoop/util/bloom/BloomFilter.java  |  2 +-
 .../org/apache/hadoop/util/bloom/TestBloomFilters.java  | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/c2bcffb3/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 f8b9519..82d18b8 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
@@ -234,6 +234,6 @@ public class BloomFilter extends Filter {
   
   /* @return number of bytes needed to hold bit vector */
   private int getNBytes() {
-    return (vectorSize + 7) / 8;
+    return (int)(((long)vectorSize + 7) / 8);
   }
 }//end class

http://git-wip-us.apache.org/repos/asf/hadoop/blob/c2bcffb3/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 6ff854d..8552565 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
@@ -240,6 +240,18 @@ public class TestBloomFilters {
   }
 
   @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
   public void testNot() {
     BloomFilter bf = new BloomFilter(8, 1, Hash.JENKINS_HASH);
     bf.bits = BitSet.valueOf(new byte[] { (byte) 0x95 });


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message