Apache9 commented on code in PR #7782:
URL: https://github.com/apache/hbase/pull/7782#discussion_r3036942185


##########
hbase-server/src/main/java/org/apache/hadoop/hbase/util/BloomFilterUtil.java:
##########
@@ -278,4 +279,31 @@ public static byte[] getBloomFilterParam(BloomType 
bloomFilterType, Configuratio
     }
     return bloomParam;
   }
+
+  /**
+   * Generate the two hash values needed for Bloom filter index generation. 
Bloom filters require a
+   * (hash1, hash2) pair to derive multiple probe locations.
+   * <ul>
+   * <li>If the hash implementation provides a 64-bit hash, we split the 
64-bit value into two
+   * 32-bit hashes to avoid extra hashing cost.</li>
+   * <li>Otherwise, fall back to classic double hashing by rehashing with 
hash1 as the seed.</li>
+   * </ul>
+   * @param hash the hash function
+   * @param key  the hash key
+   * @return a pair of hash values (hash1, hash2)
+   */
+  public static Pair<Integer, Integer> getHashPair(Hash hash, HashKey<?> key) {

Review Comment:
   Let's just return long here, and let upper layer do some shift magic to get 
the two ints? I believe hashing is compute sensitive, so let's try to avoid 
unnecessary boxing/unboxing operations.



##########
hbase-server/src/main/java/org/apache/hadoop/hbase/util/BloomFilterUtil.java:
##########
@@ -278,4 +279,31 @@ public static byte[] getBloomFilterParam(BloomType 
bloomFilterType, Configuratio
     }
     return bloomParam;
   }
+
+  /**
+   * Generate the two hash values needed for Bloom filter index generation. 
Bloom filters require a
+   * (hash1, hash2) pair to derive multiple probe locations.
+   * <ul>
+   * <li>If the hash implementation provides a 64-bit hash, we split the 
64-bit value into two
+   * 32-bit hashes to avoid extra hashing cost.</li>
+   * <li>Otherwise, fall back to classic double hashing by rehashing with 
hash1 as the seed.</li>
+   * </ul>
+   * @param hash the hash function
+   * @param key  the hash key
+   * @return a pair of hash values (hash1, hash2)
+   */
+  public static Pair<Integer, Integer> getHashPair(Hash hash, HashKey<?> key) {
+    if (hash instanceof Hash64) {

Review Comment:
   Is it possible to avoid instanceof here? Let Hash instance returns if it 
supports 64 bits hash result?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to