EmmyMiao87 commented on code in PR #8861:
URL: https://github.com/apache/doris/pull/8861#discussion_r914511593


##########
fe/fe-core/src/main/java/org/apache/doris/statistics/TableStats.java:
##########
@@ -59,51 +56,190 @@ public class TableStats {
 
     private long rowCount = -1;
     private long dataSize = -1;
-    private Map<String, ColumnStats> nameToColumnStats = 
Maps.newConcurrentMap();
+    private final Map<String, PartitionStats> nameToPartitionStats = 
Maps.newConcurrentMap();
+    private final Map<String, ColumnStats> nameToColumnStats = 
Maps.newConcurrentMap();
+
+    public long getRowCount() {
+        if  (rowCount == -1) {
+            return nameToPartitionStats.values().stream()
+                    .filter(partitionStats -> partitionStats.getRowCount() != 
-1)
+                    .mapToLong(PartitionStats::getRowCount).sum();
+        }
+        return rowCount;
+    }
+
+    public void setRowCount(long rowCount) {
+        this.rowCount = rowCount;
+    }
+
+    public long getDataSize() {
+        if (dataSize == -1) {
+            return nameToPartitionStats.values().stream()
+                    .filter(partitionStats -> partitionStats.getDataSize() != 
-1)
+                    .mapToLong(PartitionStats::getDataSize).sum();
+        }
+        return dataSize;
+    }
+
+    public Map<String, PartitionStats> getNameToPartitionStats() {
+        return nameToPartitionStats;
+    }
+
+    public Map<String, ColumnStats> getNameToColumnStats() {
+        if (nameToColumnStats.isEmpty()) {

Review Comment:
   It seems that you need to update the column stats at the same time as 
updating the partition stats, otherwise after setting the column stats once, 
the column stats will not be updated.



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to