tanishq-chugh commented on code in PR #5754:
URL: https://github.com/apache/hive/pull/5754#discussion_r2048375395


##########
storage-api/src/java/org/apache/hive/common/util/BloomKFilter.java:
##########
@@ -26,6 +26,7 @@
 import java.io.OutputStream;
 import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
+import java.util.BitSet;

Review Comment:
   This has been addressed in 
[3ab7cae](https://github.com/apache/hive/pull/5754/commits/3ab7cae52496ca25ffd75e5af80e9bf4fe214ebd)



##########
storage-api/src/java/org/apache/hive/common/util/BloomKFilter.java:
##########
@@ -59,32 +60,44 @@ private static void checkArgument(boolean expression, 
String message) {
     }
   }
 
-  public BloomKFilter(long maxNumEntries) {
+  private BloomKFilter(int k, long m, int totalBlockCount, long[] arr) {
+    this.k = k;
+    this.m = m;
+    this.bitSet = BitSet.build(arr);
+    this.totalBlockCount = totalBlockCount;
+  }
+
+  public static BloomKFilter build(long maxNumEntries) {
     checkArgument(maxNumEntries > 0, "expectedEntries should be > 0");
     long numBits = optimalNumOfBits(maxNumEntries, DEFAULT_FPP);
-    this.k = optimalNumOfHashFunctions(maxNumEntries, numBits);
+    int k = optimalNumOfHashFunctions(maxNumEntries, numBits);
     long nLongs = (long) Math.ceil((double) numBits / (double) Long.SIZE);
     // additional bits to pad long array to block size
     long padLongs = DEFAULT_BLOCK_SIZE - nLongs % DEFAULT_BLOCK_SIZE;
-    this.m = (nLongs + padLongs) * Long.SIZE;
-    this.bitSet = new BitSet(m);
-    checkArgument((bitSet.data.length % DEFAULT_BLOCK_SIZE) == 0, "bitSet has 
to be block aligned");
-    this.totalBlockCount = bitSet.data.length / DEFAULT_BLOCK_SIZE;
+    long m = (nLongs + padLongs) * Long.SIZE;
+    long[] marr = new long[(int) Math.ceil((double) m / (double) Long.SIZE)];
+    checkArgument((marr.length % DEFAULT_BLOCK_SIZE) == 0, "bitSet has to be 
block aligned");
+    int totalBlockCount = marr.length / DEFAULT_BLOCK_SIZE;
+    return new BloomKFilter(k, m, totalBlockCount, marr);
   }
 
+
   /**
    * A constructor to support rebuilding the BloomFilter from a serialized 
representation.
    * @param bits BloomK sketch data in form of array of longs.
    * @param numFuncs  Number of functions called as K.
    */
   public BloomKFilter(long[] bits, int numFuncs) {
     super();
-    bitSet = new BitSet(bits);
+    bitSet = BitSet.build(bits);
     this.m = bits.length * Long.SIZE;
     this.k = numFuncs;
-    checkArgument((bitSet.data.length % DEFAULT_BLOCK_SIZE) == 0, "bitSet has 
to be block aligned");
     this.totalBlockCount = bitSet.data.length / DEFAULT_BLOCK_SIZE;
   }
+  public static BloomKFilter build(long[] bits, int numFuncs) {
+    checkArgument((bits.length % DEFAULT_BLOCK_SIZE) == 0, "bitSet has to be 
block aligned");
+    return new BloomKFilter(bits,numFuncs);

Review Comment:
   This has been addressed in 
[3ab7cae](https://github.com/apache/hive/pull/5754/commits/3ab7cae52496ca25ffd75e5af80e9bf4fe214ebd)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to