empiredan commented on code in PR #1882:
URL: 
https://github.com/apache/incubator-pegasus/pull/1882#discussion_r1472685944


##########
src/shell/commands/table_management.cpp:
##########
@@ -173,6 +173,63 @@ bool query_app(command_executor *e, shell_context *sc, 
arguments args)
     return true;
 }
 
+namespace {
+
+dsn::metric_filters sst_stat_filters(int32_t table_id)
+{
+    dsn::metric_filters filters;
+    filters.with_metric_fields = {dsn::kMetricNameField, 
dsn::kMetricSingleValueField};
+    filters.entity_types = {"replica"};
+    filters.entity_attrs = {"table_id", std::to_string(table_id)};
+    filters.entity_metrics = {"rdb_total_sst_files", "rdb_total_sst_size_mb"};
+    return filters;
+}
+
+dsn::error_s parse_sst_stat(const std::string &json_string,
+                            std::map<int32_t, double> &count_map,
+                            std::map<int32_t, double> &disk_map)
+{
+    dsn::error_s err;
+
+    rapidjson::Document doc;
+    rapidjson::ParseResult result = doc.Parse(json_string.c_str());
+    if (dsn_unlikely(result.IsError())) {
+        return dsn::error_s::make(dsn::ERR_INVALID_DATA, "invalid json 
string");
+    }
+
+    const auto &entities = 
doc.FindMember(dsn::kMetricEntitiesField.c_str())->value;

Review Comment:
   Yeah, it's safe to access by `FindMember()`, however this is not graceful; 
and while response structure is changed, the code has to be updated.
   
   I've turned to define a special struct for this PR, and would add other 
structs if necessary for later PRs.



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