Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
rabunkosar-dd committed Jan 15, 2025
1 parent 99d3f5c commit f6fc1bc
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 25 deletions.
37 changes: 18 additions & 19 deletions src/config/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ Status SetRocksdbCompression(Server *srv, const rocksdb::CompressionType compres
for (size_t i = compression_start_level; i < KVROCKS_MAX_LSM_LEVEL; i++) {
compression_per_level_builder.emplace_back(compression_option);
}
const std::string compression_per_level = util::StringJoin(
compression_per_level_builder, [](const auto &s) -> decltype(auto) { return s; }, ":");
const std::string compression_per_level =
util::StringJoin(compression_per_level_builder, [](const auto &s) -> decltype(auto) { return s; }, ":");
return srv->storage->SetOptionForAllColumnFamilies("compression_per_level", compression_per_level);
};

Expand Down Expand Up @@ -241,8 +241,9 @@ Config::Config() {
{"txn-context-enabled", true, new YesNoField(&txn_context_enabled, false)},
{"skip-block-cache-deallocation-on-close", false, new YesNoField(&skip_block_cache_deallocation_on_close, false)},
#ifdef ENABLE_HISTOGRAMS
{"histogram-bucket-boundaries", true, new StringField(&histogram_bucket_boundaries_str_,
"10,20,40,60,80,100,150,250,350,500,750,1000,1500,2000,4000,8000")},
{"histogram-bucket-boundaries", true,
new StringField(&histogram_bucket_boundaries_str_,
"10,20,40,60,80,100,150,250,350,500,750,1000,1500,2000,4000,8000")},
#endif
/* rocksdb options */
{"rocksdb.compression", false,
Expand Down Expand Up @@ -761,22 +762,20 @@ void Config::initFieldCallback() {
#ifdef ENABLE_HISTOGRAMS
{"histogram-bucket-boundaries",
[this]([[maybe_unused]] Server *srv, [[maybe_unused]] const std::string &k, const std::string &v) -> Status {
std::vector<std::string> buckets = util::Split(v, ",");
histogram_bucket_boundaries.clear();
if (buckets.size() < 1) {
return {Status::NotOK, "Please provide at least 1 bucket value for histogram"};
}
std::transform(buckets.begin(), buckets.end(), std::back_inserter(histogram_bucket_boundaries), [](const std::string& val)
{
return std::stod(val);
});
if (histogram_bucket_boundaries.size() != buckets.size()) {
return {Status::NotOK, "All values for the bucket must be double or integer values"};
}
std::vector<std::string> buckets = util::Split(v, ",");
histogram_bucket_boundaries.clear();
if (buckets.size() < 1) {
return {Status::NotOK, "Please provide at least 1 bucket value for histogram"};
}
std::transform(buckets.begin(), buckets.end(), std::back_inserter(histogram_bucket_boundaries),
[](const std::string &val) { return std::stod(val); });
if (histogram_bucket_boundaries.size() != buckets.size()) {
return {Status::NotOK, "All values for the bucket must be double or integer values"};
}

if (!std::is_sorted(histogram_bucket_boundaries.begin(), histogram_bucket_boundaries.end())) {
return {Status::NotOK, "The values for the histogram must be sorted"};
}
if (!std::is_sorted(histogram_bucket_boundaries.begin(), histogram_bucket_boundaries.end())) {
return {Status::NotOK, "The values for the histogram must be sorted"};
}
return Status::OK();
}},
#endif
Expand Down
1 change: 0 additions & 1 deletion src/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ struct Config {
std::string histogram_bucket_boundaries_str_;
#endif


void initFieldValidator();
void initFieldCallback();
Status parseConfigFromPair(const std::pair<std::string, std::string> &input, int line_number);
Expand Down
2 changes: 1 addition & 1 deletion src/server/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Server::Server(engine::Storage *storage, Config *config)
stats.commands_stats[iter.first].latency = 0;

#ifdef ENABLE_HISTOGRAMS
//NB: Extra index for the last bucket (Inf)
// NB: Extra index for the last bucket (Inf)
for (std::size_t i{0}; i <= stats.bucket_boundaries.size(); ++i) {
auto bucket_ptr = std::shared_ptr<std::atomic<uint64_t>>(new std::atomic<uint64_t>(0));

Expand Down
4 changes: 1 addition & 3 deletions src/stats/stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@
#include "fmt/format.h"
#include "time_util.h"


#ifdef ENABLE_HISTOGRAMS
Stats::Stats(Config *config)
: config_(config) {
Stats::Stats(Config *config) : config_(config) {
for (int i = 0; i < STATS_METRIC_COUNT; i++) {
InstMetric im;
im.last_sample_time_ms = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/stats/stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <vector>
#ifdef ENABLE_HISTOGRAMS
#include <algorithm>

#include "config/config.h"
#endif

Expand Down Expand Up @@ -90,7 +91,6 @@ class Stats {
std::atomic<uint64_t> psync_ok_count = {0};
std::map<std::string, CommandStat> commands_stats;


#ifdef ENABLE_HISTOGRAMS
explicit Stats(Config *config);
#else
Expand Down

0 comments on commit f6fc1bc

Please sign in to comment.