danny0405 commented on code in PR #13365:
URL: https://github.com/apache/hudi/pull/13365#discussion_r2111559799


##########
hudi-common/src/main/java/org/apache/hudi/common/bloom/HoodieDynamicBoundedBloomFilter.java:
##########
@@ -125,5 +126,42 @@ private void 
extractAndSetInternalBloomFilter(DataInputStream dis) throws IOExce
     internalDynamicBloomFilter = new InternalDynamicBloomFilter();
     internalDynamicBloomFilter.readFields(dis);
   }
+
+  @Override
+  public void or(BloomFilter other) {
+    if (other != null) {
+      ValidationUtils.checkArgument(other instanceof 
HoodieDynamicBoundedBloomFilter,
+          "HoodieDynamicBoundedBloomFilter can only perform OR operations with 
other HoodieDynamicBoundedBloomFilter.");
+      HoodieDynamicBoundedBloomFilter otherFilter = 
(HoodieDynamicBoundedBloomFilter) other;
+      int sourceMatrixLength = this.getMatrixLength();
+      int targetMatrixLength = otherFilter.getMatrixLength();
+      if (targetMatrixLength > sourceMatrixLength) {
+        this.rescaleFromTarget(targetMatrixLength);
+      } else {
+        otherFilter.rescaleFromTarget(sourceMatrixLength);
+      }
+      
this.internalDynamicBloomFilter.or(otherFilter.internalDynamicBloomFilter);
+    }
+  }
+
+  /**
+   * rescale the internal dynamic bloom filter by length
+   * @param targetMatrixLength
+   * @return
+   */
+  private HoodieDynamicBoundedBloomFilter rescaleFromTarget(int 
targetMatrixLength) {
+    int initMatrixLength = this.internalDynamicBloomFilter.getMatrixLength();
+    int needAddRowNum = targetMatrixLength - initMatrixLength;
+    if (needAddRowNum > 0) {
+      for (int i = 0; i < needAddRowNum; i++) {
+        this.internalDynamicBloomFilter.addRow();

Review Comment:
   Not sure if we can rebuild the filter in one shot instead of invoking the 
`addRow` multiple times?



-- 
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