xy720 commented on a change in pull request #7030:
URL: https://github.com/apache/incubator-doris/pull/7030#discussion_r747345408



##########
File path: be/src/runtime/query_statistics.h
##########
@@ -27,25 +27,49 @@ namespace doris {
 
 class QueryStatisticsRecvr;
 
+class NodeStatistics {
+public:
+    NodeStatistics() : peak_memory_bytes(0) {};
+
+    void add_peak_memory(int64_t peak_memory) { this->peak_memory_bytes += 
peak_memory; }
+
+    void merge(const NodeStatistics& other);
+
+    void to_pb(PNodeStatistics* nodeStatistics);
+
+    void from_pb(const PNodeStatistics& nodeStatistics);
+
+private:
+    int64_t peak_memory_bytes;
+};
+
 // This is responsible for collecting query statistics, usually it consists of
 // two parts, one is current fragment or plan's statistics, the other is sub 
fragment
 // or plan's statistics and QueryStatisticsRecvr is responsible for collecting 
it.
 class QueryStatistics {
 public:
     QueryStatistics() : scan_rows(0), scan_bytes(0), cpu_ms(0), 
returned_rows(0) {}
 
-    void merge(const QueryStatistics& other) {
-        scan_rows += other.scan_rows;
-        scan_bytes += other.scan_bytes;
-        cpu_ms += other.cpu_ms;
-    }
+    void merge(const QueryStatistics& other);
 
     void add_scan_rows(int64_t scan_rows) { this->scan_rows += scan_rows; }
 
     void add_scan_bytes(int64_t scan_bytes) { this->scan_bytes += scan_bytes; }
 
     void add_cpu_ms(int64_t cpu_ms) { this->cpu_ms += cpu_ms; }
 
+    NodeStatistics* add_nodes_statistics(int64_t node_id) {
+        NodeStatistics* nodeStatistics = nullptr;
+        auto iter = nodes_statistics_map.find(node_id);
+        if (iter == nodes_statistics_map.end()) {
+            nodeStatistics = new NodeStatistics;

Review comment:
       done. Now the clearNodeStatistics() cleans up all newly allocated memory.




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