dongxiaoman commented on a change in pull request #7243:
URL: https://github.com/apache/pinot/pull/7243#discussion_r686932957



##########
File path: 
pinot-broker/src/main/java/org/apache/pinot/broker/routing/segmentpruner/PartitionSegmentPruner.java
##########
@@ -278,5 +287,37 @@ private boolean isPartitionMatch(FilterQueryTree 
filterQueryTree, PartitionInfo
       _partitionFunction = partitionFunction;
       _partitions = partitions;
     }
+    @Override
+    public boolean equals(Object o) {
+      if (this == o) return true;
+      if (o == null || getClass() != o.getClass()) return false;
+      PartitionInfo that = (PartitionInfo) o;
+      return Objects.equals(_partitionFunction, that._partitionFunction) &&
+        Objects.equals(_partitions, that._partitions);
+    }
+
+    @Override
+    public int hashCode() {
+      return Objects.hash(_partitionFunction, _partitions);
+    }
+  }
+
+  /**
+   * This class is created to speed up partition number calls. Sometimes with 
lots of segments (like 40k+)
+   * Computing partition values may be CPU intensive, caching the computation 
result may help
+   */
+  private static class CachedPartitionFunction {
+    final Map<PartitionFunction, Map<String, Integer>> cache = new HashMap<>();
+
+    public int getPartition(PartitionFunction func, String value) {

Review comment:
       Updated the comment; the `value` here is the SQL expression's value, 
e.g., the `a42dc` in the filter `WHERE account_key = 'a42dc'`
   And I have switched to use Map instead because the map is created for each 
query

##########
File path: 
pinot-broker/src/main/java/org/apache/pinot/broker/routing/segmentpruner/PartitionSegmentPruner.java
##########
@@ -278,5 +287,37 @@ private boolean isPartitionMatch(FilterQueryTree 
filterQueryTree, PartitionInfo
       _partitionFunction = partitionFunction;
       _partitions = partitions;
     }
+    @Override
+    public boolean equals(Object o) {
+      if (this == o) return true;
+      if (o == null || getClass() != o.getClass()) return false;
+      PartitionInfo that = (PartitionInfo) o;
+      return Objects.equals(_partitionFunction, that._partitionFunction) &&
+        Objects.equals(_partitions, that._partitions);
+    }
+
+    @Override
+    public int hashCode() {
+      return Objects.hash(_partitionFunction, _partitions);
+    }
+  }
+
+  /**
+   * This class is created to speed up partition number calls. Sometimes with 
lots of segments (like 40k+)
+   * Computing partition values may be CPU intensive, caching the computation 
result may help
+   */
+  private static class CachedPartitionFunction {
+    final Map<PartitionFunction, Map<String, Integer>> cache = new HashMap<>();

Review comment:
       Added Java doc




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to