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

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

commit bedc586036e9554beb63c39ac47d2f024039fbf5
Author: Michael Smith <[email protected]>
AuthorDate: Mon Jun 17 17:13:54 2024 -0700

    IMPALA-13166: Cache hashCode
    
    Precomputes the hashCode when populating fullyQualifiedRawPath_ to
    minimize hashCode recomputations.
    
    Speeds up PlannerTest#testManyExpressionPerformance by a small amount
    (<5%) in local testing.
    
    Change-Id: Ia4141be3e5e4e1ba8bac0b3fc3631e0e71e33ec0
    Reviewed-on: http://gerrit.cloudera.org:8080/21532
    Reviewed-by: Michael Smith <[email protected]>
    Tested-by: Michael Smith <[email protected]>
---
 fe/src/main/java/org/apache/impala/analysis/Path.java | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/fe/src/main/java/org/apache/impala/analysis/Path.java 
b/fe/src/main/java/org/apache/impala/analysis/Path.java
index 2ae4a4fac..d1623013c 100644
--- a/fe/src/main/java/org/apache/impala/analysis/Path.java
+++ b/fe/src/main/java/org/apache/impala/analysis/Path.java
@@ -174,6 +174,9 @@ public class Path {
   // Its inputs are all private final fields, so value can't change after init.
   private List<String> fullyQualifiedRawPath_ = null;
 
+  // Object hashCode, based on fullyQualifiedRawPath_.
+  int hashCode_ = 0;
+
   /**
    * Constructs a Path rooted at the given rootDesc.
    */
@@ -481,6 +484,7 @@ public class Path {
   public List<String> getFullyQualifiedRawPath() {
     if (fullyQualifiedRawPath_ == null) {
       fullyQualifiedRawPath_ = getFullyQualifiedRawPath(true);
+      hashCode_ = fullyQualifiedRawPath_.hashCode();
     }
     return fullyQualifiedRawPath_;
   }
@@ -493,7 +497,11 @@ public class Path {
 
   @Override
   public int hashCode() {
-    return getFullyQualifiedRawPath().hashCode();
+    if (fullyQualifiedRawPath_ == null) {
+      // Populate hashCode_
+      getFullyQualifiedRawPath();
+    }
+    return hashCode_;
   }
 
   /**

Reply via email to