This is an automated email from the ASF dual-hosted git repository.

yihua pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git


The following commit(s) were added to refs/heads/master by this push:
     new 6e5501ac30e [MINOR] Improve the logic when building bloom filter 
KeyRangeLookupTree (#9706)
6e5501ac30e is described below

commit 6e5501ac30e273e84663c81a0aa52b6d6988cc2e
Author: leosanqing <[email protected]>
AuthorDate: Fri Sep 15 02:59:15 2023 +0800

    [MINOR] Improve the logic when building bloom filter KeyRangeLookupTree 
(#9706)
---
 .../hudi/index/bloom/KeyRangeLookupTree.java       | 24 +++++++++++-----------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git 
a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/index/bloom/KeyRangeLookupTree.java
 
b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/index/bloom/KeyRangeLookupTree.java
index 8f27a838f27..64df35ce223 100644
--- 
a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/index/bloom/KeyRangeLookupTree.java
+++ 
b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/index/bloom/KeyRangeLookupTree.java
@@ -81,12 +81,8 @@ class KeyRangeLookupTree implements Serializable {
         root.setRightSubTreeMin(newNode.getMinRecordKey());
         root.setRight(newNode);
       } else {
-        if (root.getRightSubTreeMax().compareTo(newNode.getMaxRecordKey()) < 
0) {
-          root.setRightSubTreeMax(newNode.getMaxRecordKey());
-        }
-        if (root.getRightSubTreeMin().compareTo(newNode.getMinRecordKey()) > 
0) {
-          root.setRightSubTreeMin(newNode.getMinRecordKey());
-        }
+        root.setRightSubTreeMax(max(root.getRightSubTreeMax(), 
newNode.getMaxRecordKey()));
+        root.setRightSubTreeMin(min(root.getRightSubTreeMin(), 
newNode.getMinRecordKey()));
         insert(root.getRight(), newNode);
       }
     } else {
@@ -95,18 +91,22 @@ class KeyRangeLookupTree implements Serializable {
         root.setLeftSubTreeMin(newNode.getMinRecordKey());
         root.setLeft(newNode);
       } else {
-        if (root.getLeftSubTreeMax().compareTo(newNode.getMaxRecordKey()) < 0) 
{
-          root.setLeftSubTreeMax(newNode.getMaxRecordKey());
-        }
-        if (root.getLeftSubTreeMin().compareTo(newNode.getMinRecordKey()) > 0) 
{
-          root.setLeftSubTreeMin(newNode.getMinRecordKey());
-        }
+        root.setLeftSubTreeMax(max(root.getLeftSubTreeMax(), 
newNode.getMaxRecordKey()));
+        root.setLeftSubTreeMin(min(root.getLeftSubTreeMin(), 
newNode.getMinRecordKey()));
         insert(root.getLeft(), newNode);
       }
     }
     return root;
   }
 
+  private static String max(String a, String b) {
+    return (a.compareTo(b) >= 0) ? a : b;
+  }
+
+  private static String min(String a, String b) {
+    return (a.compareTo(b) <= 0) ? a : b;
+  }
+
   /**
    * Fetches all the matching index files where the key could possibly be 
present.
    *

Reply via email to