levy5307 commented on a change in pull request #592:
URL: https://github.com/apache/incubator-pegasus/pull/592#discussion_r489128072
##########
File path: src/server/hotspot_partition_calculator.cpp
##########
@@ -34,67 +35,98 @@ DSN_DEFINE_int64("pegasus.collector",
"eliminate outdated historical "
"data");
-void hotspot_partition_calculator::data_aggregate(const std::vector<row_data>
&partitions)
+void hotspot_partition_calculator::data_aggregate(const std::vector<row_data>
&partition_stats)
{
- while (_partition_stat_histories.size() > FLAGS_max_hotspot_store_size -
1) {
- _partition_stat_histories.pop();
+ while (_partitions_stat_histories.size() >= FLAGS_max_hotspot_store_size) {
+ _partitions_stat_histories.pop_front();
}
- std::vector<hotspot_partition_data> temp(partitions.size());
- // TODO refactor the data structure
- for (int i = 0; i < partitions.size(); i++) {
- temp[i] = std::move(hotspot_partition_data(partitions[i]));
+ std::vector<hotspot_partition_stat> temp;
+ for (const auto &partition_stat : partition_stats) {
+ temp.emplace_back(hotspot_partition_stat(partition_stat));
}
- _partition_stat_histories.emplace(temp);
+ _partitions_stat_histories.emplace_back(temp);
}
void hotspot_partition_calculator::init_perf_counter(int partition_count)
{
- std::string counter_name;
- std::string counter_desc;
+ std::string read_counter_name, write_counter_name;
+ std::string read_counter_desc, write_counter_desc;
for (int i = 0; i < partition_count; i++) {
- string partition_desc = _app_name + '.' + std::to_string(i);
- counter_name = fmt::format("app.stat.hotspots@{}", partition_desc);
- counter_desc = fmt::format("statistic the hotspots of app {}",
partition_desc);
- _hot_points[i].init_app_counter(
- "app.pegasus", counter_name.c_str(), COUNTER_TYPE_NUMBER,
counter_desc.c_str());
+ string read_partition_desc = _app_name + '.' + "read." +
std::to_string(i);
Review comment:
I think you can encapsulate these code in a function.
```
void func_name(partition_qps_type qps_type)
{
write_counter_name = fmt::format("app.stat.hotspots@{}",
write_partition_desc);
write_counter_desc = fmt::format("statistic the hotspots of app {}",
write_partition_desc);
_hot_points[i].emplace_back(std::make_unique<dsn::perf_counter_wrapper>());
_hot_points[i][qps_type]->init_app_counter("app.pegasus",
write_counter_name.c_str(),
COUNTER_TYPE_NUMBER,
write_counter_desc.c_str());
}
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]