mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-28 12:17:02 +00:00
Instead of lengthy blurbs, switch to single-line, machine-readable standardized (https://spdx.dev) license identifiers. The Linux kernel switched long ago, so there is strong precedent. Three cases are handled: AGPL-only, Apache-only, and dual licensed. For the latter case, I chose (AGPL-3.0-or-later and Apache-2.0), reasoning that our changes are extensive enough to apply our license. The changes we applied mechanically with a script, except to licenses/README.md. Closes #9937
38 lines
1.1 KiB
C++
38 lines
1.1 KiB
C++
/*
|
|
* Copyright (C) 2020-present ScyllaDB
|
|
*
|
|
* Modified by ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <seastar/core/metrics_types.hh>
|
|
#include "seastarx.hh"
|
|
#include "estimated_histogram.hh"
|
|
|
|
|
|
template<uint64_t Min, uint64_t Max, size_t Precision>
|
|
seastar::metrics::histogram to_metrics_histogram(const utils::approx_exponential_histogram<Min, Max, Precision>& hist) {
|
|
seastar::metrics::histogram res;
|
|
res.buckets.resize(hist.size() - 1);
|
|
uint64_t cummulative_count = 0;
|
|
res.sample_sum = 0;
|
|
|
|
for (size_t i = 0; i < hist.NUM_BUCKETS - 1; i++) {
|
|
auto& v = res.buckets[i];
|
|
v.upper_bound = hist.get_bucket_lower_limit(i + 1);
|
|
cummulative_count += hist.get(i);
|
|
v.count = cummulative_count;
|
|
res.sample_sum += hist.get(i) * v.upper_bound;
|
|
}
|
|
// The count serves as the infinite bucket
|
|
res.sample_count = cummulative_count + hist.get(hist.NUM_BUCKETS - 1);
|
|
res.sample_sum += hist.get(hist.NUM_BUCKETS - 1) * hist.get_bucket_lower_limit(hist.NUM_BUCKETS - 1);
|
|
return res;
|
|
}
|