decouple estimated_histogram from sstables
There is nothing really that fundamentally ties the estimated histogram to sstables. This patch gets rid of the few incidental ties. They are: - the namespace name, which is now moved to utils. Users inside sstables/ now need to add a namespace prefix, while the ones outside have to change it to the right one - sstables::merge, which has a very non-descriptive name to begin with, is changed to a more descriptive name that can live inside utils/ - the disk_types.hh include has to be removed - but it had no reason to be here in the first place. Todo, is to actually move the file outside sstables/. That is done in a separate step for clarity. Signed-off-by: Glauber Costa <glauber@scylladb.com>
This commit is contained in:
@@ -395,14 +395,14 @@ void set_column_family(http_context& ctx, routes& r) {
|
||||
});
|
||||
|
||||
cf::get_estimated_row_size_histogram.set(r, [&ctx] (std::unique_ptr<request> req) {
|
||||
return map_reduce_cf(ctx, req->param["name"], sstables::estimated_histogram(0), [](column_family& cf) {
|
||||
sstables::estimated_histogram res(0);
|
||||
return map_reduce_cf(ctx, req->param["name"], utils::estimated_histogram(0), [](column_family& cf) {
|
||||
utils::estimated_histogram res(0);
|
||||
for (auto i: *cf.get_sstables() ) {
|
||||
res.merge(i->get_stats_metadata().estimated_row_size);
|
||||
}
|
||||
return res;
|
||||
},
|
||||
sstables::merge, utils_json::estimated_histogram());
|
||||
utils::estimated_histogram_merge, utils_json::estimated_histogram());
|
||||
});
|
||||
|
||||
cf::get_estimated_row_count.set(r, [&ctx] (std::unique_ptr<request> req) {
|
||||
@@ -417,14 +417,14 @@ void set_column_family(http_context& ctx, routes& r) {
|
||||
});
|
||||
|
||||
cf::get_estimated_column_count_histogram.set(r, [&ctx] (std::unique_ptr<request> req) {
|
||||
return map_reduce_cf(ctx, req->param["name"], sstables::estimated_histogram(0), [](column_family& cf) {
|
||||
sstables::estimated_histogram res(0);
|
||||
return map_reduce_cf(ctx, req->param["name"], utils::estimated_histogram(0), [](column_family& cf) {
|
||||
utils::estimated_histogram res(0);
|
||||
for (auto i: *cf.get_sstables() ) {
|
||||
res.merge(i->get_stats_metadata().estimated_column_count);
|
||||
}
|
||||
return res;
|
||||
},
|
||||
sstables::merge, utils_json::estimated_histogram());
|
||||
utils::estimated_histogram_merge, utils_json::estimated_histogram());
|
||||
});
|
||||
|
||||
cf::get_all_compression_ratio.set(r, [] (std::unique_ptr<request> req) {
|
||||
@@ -799,10 +799,10 @@ void set_column_family(http_context& ctx, routes& r) {
|
||||
});
|
||||
|
||||
cf::get_sstables_per_read_histogram.set(r, [&ctx] (std::unique_ptr<request> req) {
|
||||
return map_reduce_cf(ctx, req->param["name"], sstables::estimated_histogram(0), [](column_family& cf) {
|
||||
return map_reduce_cf(ctx, req->param["name"], utils::estimated_histogram(0), [](column_family& cf) {
|
||||
return cf.get_stats().estimated_sstable_per_read;
|
||||
},
|
||||
sstables::merge, utils_json::estimated_histogram());
|
||||
utils::estimated_histogram_merge, utils_json::estimated_histogram());
|
||||
});
|
||||
|
||||
cf::get_tombstone_scanned_histogram.set(r, [&ctx] (std::unique_ptr<request> req) {
|
||||
@@ -861,17 +861,17 @@ void set_column_family(http_context& ctx, routes& r) {
|
||||
});
|
||||
|
||||
cf::get_read_latency_estimated_histogram.set(r, [&ctx](std::unique_ptr<request> req) {
|
||||
return map_reduce_cf(ctx, req->param["name"], sstables::estimated_histogram(0), [](column_family& cf) {
|
||||
return map_reduce_cf(ctx, req->param["name"], utils::estimated_histogram(0), [](column_family& cf) {
|
||||
return cf.get_stats().estimated_read;
|
||||
},
|
||||
sstables::merge, utils_json::estimated_histogram());
|
||||
utils::estimated_histogram_merge, utils_json::estimated_histogram());
|
||||
});
|
||||
|
||||
cf::get_write_latency_estimated_histogram.set(r, [&ctx](std::unique_ptr<request> req) {
|
||||
return map_reduce_cf(ctx, req->param["name"], sstables::estimated_histogram(0), [](column_family& cf) {
|
||||
return map_reduce_cf(ctx, req->param["name"], utils::estimated_histogram(0), [](column_family& cf) {
|
||||
return cf.get_stats().estimated_write;
|
||||
},
|
||||
sstables::merge, utils_json::estimated_histogram());
|
||||
utils::estimated_histogram_merge, utils_json::estimated_histogram());
|
||||
});
|
||||
|
||||
cf::set_compaction_strategy_class.set(r, [&ctx](std::unique_ptr<request> req) {
|
||||
|
||||
@@ -52,9 +52,9 @@ static future<json::json_return_type> sum_timed_rate_as_long(distributed<proxy>
|
||||
});
|
||||
}
|
||||
|
||||
static future<json::json_return_type> sum_estimated_histogram(http_context& ctx, sstables::estimated_histogram proxy::stats::*f) {
|
||||
return ctx.sp.map_reduce0([f](const proxy& p) {return p.get_stats().*f;}, sstables::estimated_histogram(),
|
||||
sstables::merge).then([](const sstables::estimated_histogram& val) {
|
||||
static future<json::json_return_type> sum_estimated_histogram(http_context& ctx, utils::estimated_histogram proxy::stats::*f) {
|
||||
return ctx.sp.map_reduce0([f](const proxy& p) {return p.get_stats().*f;}, utils::estimated_histogram(),
|
||||
utils::estimated_histogram_merge).then([](const utils::estimated_histogram& val) {
|
||||
utils_json::estimated_histogram res;
|
||||
res = val;
|
||||
return make_ready_future<json::json_return_type>(res);
|
||||
|
||||
@@ -331,9 +331,9 @@ public:
|
||||
int64_t pending_compactions = 0;
|
||||
utils::timed_rate_moving_average_and_histogram reads{256};
|
||||
utils::timed_rate_moving_average_and_histogram writes{256};
|
||||
sstables::estimated_histogram estimated_read;
|
||||
sstables::estimated_histogram estimated_write;
|
||||
sstables::estimated_histogram estimated_sstable_per_read;
|
||||
utils::estimated_histogram estimated_read;
|
||||
utils::estimated_histogram estimated_write;
|
||||
utils::estimated_histogram estimated_sstable_per_read;
|
||||
utils::timed_rate_moving_average_and_histogram tombstone_scanned;
|
||||
utils::timed_rate_moving_average_and_histogram live_scanned;
|
||||
};
|
||||
|
||||
@@ -75,7 +75,7 @@ static std::vector<db::system_keyspace::range_estimates> estimates_for(const col
|
||||
// Each range defines both bounds.
|
||||
for (auto& range : local_ranges) {
|
||||
int64_t count{0};
|
||||
sstables::estimated_histogram hist{0};
|
||||
utils::estimated_histogram hist{0};
|
||||
unwrapped.clear();
|
||||
if (range.is_wrap_around(dht::ring_position_comparator(*cf.schema()))) {
|
||||
auto uw = range.unwrap();
|
||||
|
||||
@@ -142,9 +142,9 @@ public:
|
||||
utils::timed_rate_moving_average_and_histogram read;
|
||||
utils::timed_rate_moving_average_and_histogram write;
|
||||
utils::timed_rate_moving_average_and_histogram range;
|
||||
sstables::estimated_histogram estimated_read;
|
||||
sstables::estimated_histogram estimated_write;
|
||||
sstables::estimated_histogram estimated_range;
|
||||
utils::estimated_histogram estimated_read;
|
||||
utils::estimated_histogram estimated_write;
|
||||
utils::estimated_histogram estimated_range;
|
||||
uint64_t background_writes = 0; // client no longer waits for the write
|
||||
uint64_t background_write_bytes = 0;
|
||||
uint64_t queued_write_bytes = 0;
|
||||
|
||||
@@ -41,13 +41,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "disk_types.hh"
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <chrono>
|
||||
|
||||
namespace sstables {
|
||||
namespace utils {
|
||||
|
||||
struct estimated_histogram {
|
||||
using clock = std::chrono::steady_clock;
|
||||
@@ -457,7 +456,7 @@ public:
|
||||
#endif
|
||||
};
|
||||
|
||||
inline estimated_histogram merge(estimated_histogram a, const estimated_histogram& b) {
|
||||
inline estimated_histogram estimated_histogram_merge(estimated_histogram a, const estimated_histogram& b) {
|
||||
return a.merge(b);
|
||||
}
|
||||
|
||||
|
||||
@@ -195,9 +195,9 @@ public:
|
||||
}
|
||||
private:
|
||||
// EH of 150 can track a max value of 1697806495183, i.e., > 1.5PB
|
||||
estimated_histogram _estimated_row_size{150};
|
||||
utils::estimated_histogram _estimated_row_size{150};
|
||||
// EH of 114 can track a max value of 2395318855, i.e., > 2B columns
|
||||
estimated_histogram _estimated_column_count{114};
|
||||
utils::estimated_histogram _estimated_column_count{114};
|
||||
db::replay_position _replay_position;
|
||||
uint64_t _min_timestamp = std::numeric_limits<uint64_t>::max();
|
||||
uint64_t _max_timestamp = std::numeric_limits<uint64_t>::min();
|
||||
|
||||
@@ -654,7 +654,7 @@ inline void write(file_writer& out, statistics& s) {
|
||||
}
|
||||
}
|
||||
|
||||
future<> parse(random_access_reader& in, estimated_histogram& eh) {
|
||||
future<> parse(random_access_reader& in, utils::estimated_histogram& eh) {
|
||||
auto len = std::make_unique<uint32_t>();
|
||||
|
||||
auto f = parse(in, *len);
|
||||
@@ -682,7 +682,7 @@ future<> parse(random_access_reader& in, estimated_histogram& eh) {
|
||||
});
|
||||
}
|
||||
|
||||
inline void write(file_writer& out, estimated_histogram& eh) {
|
||||
inline void write(file_writer& out, utils::estimated_histogram& eh) {
|
||||
uint32_t len = 0;
|
||||
check_truncate_and_assign(len, eh.buckets.size());
|
||||
|
||||
|
||||
@@ -192,8 +192,8 @@ struct compaction_metadata : public metadata {
|
||||
};
|
||||
|
||||
struct ka_stats_metadata : public metadata {
|
||||
estimated_histogram estimated_row_size;
|
||||
estimated_histogram estimated_column_count;
|
||||
utils::estimated_histogram estimated_row_size;
|
||||
utils::estimated_histogram estimated_column_count;
|
||||
db::replay_position position;
|
||||
int64_t min_timestamp;
|
||||
int64_t max_timestamp;
|
||||
|
||||
Reference in New Issue
Block a user