foxtail463 commented on code in PR #64032:
URL: https://github.com/apache/doris/pull/64032#discussion_r3433454735


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java:
##########
@@ -1908,6 +1908,29 @@ public long getRowCountForPartitionIndex(long 
partitionId, long indexId, boolean
         return index.getRowCount() == -1 ? 0 : index.getRowCount();
     }
 
+    /**
+     * Returns row count for selected partitions on the given index. If some 
partition row counts
+     * are not reported, estimate them from the base row count.
+     */
+    public double getRowCountForSelectedPartitions(Collection<Long> 
selectedPartitionIds,
+            long indexId, double baseRowCount) {
+        double unknownPartitionCount = 0;
+        double selectedPartitionRowCount = 0;
+        for (long partitionId : selectedPartitionIds) {
+            long partitionRowCount = getRowCountForPartitionIndex(partitionId, 
indexId, true);
+            if (partitionRowCount == UNKNOWN_ROW_COUNT) {
+                unknownPartitionCount++;
+            } else {
+                selectedPartitionRowCount += partitionRowCount;
+            }
+        }
+        if (unknownPartitionCount > 0) {
+            selectedPartitionRowCount += Math.max(unknownPartitionCount,
+                    baseRowCount * unknownPartitionCount / getPartitionNum());
+        }
+        return selectedPartitionRowCount;

Review Comment:
           if (unknownPartitionCount > 0) {
               double knownSelectedPartitionCount = selectedPartitionIds.size() 
- unknownPartitionCount;
               double remainingPartitionCount = getPartitionNum() - 
knownSelectedPartitionCount;
               double remainingRowCount = Math.max(0, baseRowCount - 
selectedPartitionRowCount);
               selectedPartitionRowCount += remainingRowCount * 
unknownPartitionCount / remainingPartitionCount;
           }



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