englefly commented on code in PR #69322:
URL: https://github.com/apache/doris/pull/69322#discussion_r4358752457


##########
fe/fe-core/src/main/java/org/apache/doris/statistics/hbo/InputTableStatisticsInfo.java:
##########
@@ -17,25 +17,91 @@
 
 package org.apache.doris.statistics.hbo;
 
+import org.apache.doris.nereids.trees.plans.physical.PhysicalOlapScan;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 import java.util.Optional;
 
 /**
  * Describes plan statistics which are derived from history based optimizer.
  */
 public class InputTableStatisticsInfo {
-    private final Optional<String> hash;
     private final Optional<List<PlanStatistics>> inputTableStatistics;
 
-    public InputTableStatisticsInfo(Optional<String> hash, 
Optional<List<PlanStatistics>> inputTableStatistics) {
-        this.hash = Objects.requireNonNull(hash, "hash is null");
+    public InputTableStatisticsInfo(Optional<List<PlanStatistics>> 
inputTableStatistics) {
         this.inputTableStatistics = 
Objects.requireNonNull(inputTableStatistics,
                 "inputTableStatistics is null");
     }
 
-    public Optional<String> getHash() {
-        return hash;
+    /**
+     * Fold the input table statistics of another node which shares the 
fingerprint of this one: two
+     * runtime nodes can carry one fingerprint (the two scans of a self join, 
for instance), and the
+     * provider stores one entry per fingerprint.
+     *
+     * <p>The two nodes read the same table population, so an entry of the 
same scan (the same table, the
+     * same index and the same partitions) is one population however many 
nodes read it: folding two of
+     * them keeps the larger measurement instead of adding the two up. Summing 
them would describe a table
+     * which holds the rows of both scans at once, and the drift comparison - 
which sums the rows of every
+     * recorded scan of a table - would then judge the next query of a single 
scan stale by construction.
+     * Two different scans are both kept, because they describe two 
populations.
+     */
+    public InputTableStatisticsInfo merge(InputTableStatisticsInfo other) {
+        if (inputTableStatistics.isEmpty()) {
+            return other;
+        }
+        if (other.inputTableStatistics.isEmpty()) {
+            return this;
+        }
+        Map<String, PlanStatistics> merged = new LinkedHashMap<>();
+        for (PlanStatistics statistics : inputTableStatistics.get()) {
+            merged.merge(identityOf(statistics), statistics, 
InputTableStatisticsInfo::largerRows);

Review Comment:
   learned hbo 要重做, 不在这个pr里修改



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