acelyc111 commented on code in PR #1920:
URL: 
https://github.com/apache/incubator-pegasus/pull/1920#discussion_r1503567952


##########
src/shell/commands/table_management.cpp:
##########
@@ -532,10 +532,9 @@ bool app_stat(command_executor *e, shell_context *sc, 
arguments args)
         return true;
     }
 
-    rows.resize(rows.size() + 1);
-    row_data &sum = rows.back();
-    sum.row_name = "(total:" + std::to_string(rows.size() - 1) + ")";
-    for (int i = 0; i < rows.size() - 1; ++i) {
+    rows.emplace_back("(total:" + std::to_string(rows.size() - 1) + ")");

Review Comment:
   ```suggestion
       rows.emplace_back(fmt::format("(total:{})", rows.size() - 1));
   ```



##########
src/shell/commands/data_operations.cpp:
##########
@@ -2352,20 +2442,18 @@ bool count_data(command_executor *e, shell_context *sc, 
arguments args)
             return false;
         }
 
-        // get estimate key number
         std::vector<row_data> rows;
-        std::string app_name = sc->pg_client->get_app_name();
-        // TODO(wangdan): no need to use get_app_stat since only 
rdb_estimate_num_keys is needed.
-        // Would be refactored later.
-        // if (!get_app_stat(sc, app_name, rows)) {
-        //    fprintf(stderr, "ERROR: query app stat from server failed");
-        //    return true;
-        // }
-
-        rows.resize(rows.size() + 1);
-        row_data &sum = rows.back();
-        sum.row_name = "(total:" + std::to_string(rows.size() - 1) + ")";
-        for (int i = 0; i < rows.size() - 1; ++i) {
+        const std::string table_name(sc->pg_client->get_app_name());
+        CHECK(!table_name.empty(), "table_name must be non-empty, see 
data_operations()");
+
+        if (!get_rdb_estimated_keys_stats(sc, table_name, rows)) {
+            fprintf(stderr, "ERROR: get rdb_estimated_keys stats failed");
+            return true;
+        }
+
+        rows.emplace_back("(total:" + std::to_string(rows.size() - 1) + ")");

Review Comment:
   ```suggestion
           rows.emplace_back(fmt::format("(total:{})", rows.size() - 1));
   ```



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