aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/histogram/hdr/histogram_iter.cpp
diff options
context:
space:
mode:
authorAidar Samerkhanov <aidarsamer@yandex-team.ru>2022-02-09 18:18:45 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 15:58:17 +0300
commite65c50047c24f91dcd6454edcd9b0e4bf9a2ae2a (patch)
tree379a6851244b5c9ff9c3d7994c26126b9b712942 /library/cpp/histogram/hdr/histogram_iter.cpp
parent542b4cb3a3bbb51b5a1cdedd117ee52a1e8f2032 (diff)
downloadydb-e65c50047c24f91dcd6454edcd9b0e4bf9a2ae2a.tar.gz
KIKIMR-13365. Add workload commands to ydb cli.
KIKIMR-13365. Add workload command to YDB cli. ref:d1b633b524f135ff2d0f23ee7534c1f67268be75
Diffstat (limited to 'library/cpp/histogram/hdr/histogram_iter.cpp')
-rw-r--r--library/cpp/histogram/hdr/histogram_iter.cpp146
1 files changed, 146 insertions, 0 deletions
diff --git a/library/cpp/histogram/hdr/histogram_iter.cpp b/library/cpp/histogram/hdr/histogram_iter.cpp
new file mode 100644
index 0000000000..d251fd5dd9
--- /dev/null
+++ b/library/cpp/histogram/hdr/histogram_iter.cpp
@@ -0,0 +1,146 @@
+#include "histogram_iter.h"
+
+#include <contrib/libs/hdr_histogram/src/hdr_histogram.h>
+
+namespace NHdr {
+ // TBaseHistogramIterator -----------------------------------------------------
+ TBaseHistogramIterator::TBaseHistogramIterator()
+ : Iter_(new hdr_iter)
+ {
+ }
+
+ TBaseHistogramIterator::~TBaseHistogramIterator() {
+ }
+
+ bool TBaseHistogramIterator::Next() {
+ return hdr_iter_next(Iter_.Get());
+ }
+
+ i32 TBaseHistogramIterator::GetCountsIndex() const {
+ return Iter_->counts_index;
+ }
+
+ i32 TBaseHistogramIterator::GetTotalCount() const {
+ return Iter_->total_count;
+ }
+
+ i64 TBaseHistogramIterator::GetCount() const {
+ return Iter_->count;
+ }
+
+ i64 TBaseHistogramIterator::GetCumulativeCount() const {
+ return Iter_->cumulative_count;
+ }
+
+ i64 TBaseHistogramIterator::GetValue() const {
+ return Iter_->value;
+ }
+
+ i64 TBaseHistogramIterator::GetHighestEquivalentValue() const {
+ return Iter_->highest_equivalent_value;
+ }
+
+ i64 TBaseHistogramIterator::GetLowestEquivalentValue() const {
+ return Iter_->lowest_equivalent_value;
+ }
+
+ i64 TBaseHistogramIterator::GetMedianEquivalentValue() const {
+ return Iter_->median_equivalent_value;
+ }
+
+ i64 TBaseHistogramIterator::GetValueIteratedFrom() const {
+ return Iter_->value_iterated_from;
+ }
+
+ i64 TBaseHistogramIterator::GetValueIteratedTo() const {
+ return Iter_->value_iterated_to;
+ }
+
+ // TAllValuesIterator ---------------------------------------------------------
+
+ TAllValuesIterator::TAllValuesIterator(const THistogram& histogram) {
+ hdr_iter_init(Iter_.Get(), histogram.GetHdrHistogramImpl());
+ }
+
+ // TRecordedValuesIterator ----------------------------------------------------
+
+ TRecordedValuesIterator::TRecordedValuesIterator(const THistogram& histogram) {
+ hdr_iter_recorded_init(Iter_.Get(), histogram.GetHdrHistogramImpl());
+ }
+
+ i64 TRecordedValuesIterator::GetCountAddedInThisIterationStep() const {
+ return Iter_->specifics.recorded.count_added_in_this_iteration_step;
+ }
+
+ // TPercentileIterator --------------------------------------------------------
+
+ TPercentileIterator::TPercentileIterator(
+ const THistogram& histogram, ui32 ticksPerHalfDistance) {
+ hdr_iter_percentile_init(
+ Iter_.Get(), histogram.GetHdrHistogramImpl(),
+ ticksPerHalfDistance);
+ }
+
+ i32 TPercentileIterator::GetTicketsPerHalfDistance() const {
+ return Iter_->specifics.percentiles.ticks_per_half_distance;
+ }
+
+ double TPercentileIterator::GetPercentileToIterateTo() const {
+ return Iter_->specifics.percentiles.percentile_to_iterate_to;
+ }
+
+ double TPercentileIterator::GetPercentile() const {
+ return Iter_->specifics.percentiles.percentile;
+ }
+
+ // TLinearIterator ------------------------------------------------------------
+
+ TLinearIterator::TLinearIterator(
+ const THistogram& histogram, i64 valueUnitsPerBucket) {
+ hdr_iter_linear_init(
+ Iter_.Get(), histogram.GetHdrHistogramImpl(), valueUnitsPerBucket);
+ }
+
+ i64 TLinearIterator::GetValueUnitsPerBucket() const {
+ return Iter_->specifics.linear.value_units_per_bucket;
+ }
+
+ i64 TLinearIterator::GetCountAddedInThisIterationStep() const {
+ return Iter_->specifics.linear.count_added_in_this_iteration_step;
+ }
+
+ i64 TLinearIterator::GetNextValueReportingLevel() const {
+ return Iter_->specifics.linear.next_value_reporting_level;
+ }
+
+ i64 TLinearIterator::GetNextValueReportingLevelLowestEquivalent() const {
+ return Iter_->specifics.linear.next_value_reporting_level_lowest_equivalent;
+ }
+
+ // TLogarithmicIterator -------------------------------------------------------
+
+ TLogarithmicIterator::TLogarithmicIterator(
+ const THistogram& histogram, i64 valueUnitsInFirstBucket,
+ double logBase) {
+ hdr_iter_log_init(
+ Iter_.Get(), histogram.GetHdrHistogramImpl(),
+ valueUnitsInFirstBucket, logBase);
+ }
+
+ double TLogarithmicIterator::GetLogBase() const {
+ return Iter_->specifics.log.log_base;
+ }
+
+ i64 TLogarithmicIterator::GetCountAddedInThisIterationStep() const {
+ return Iter_->specifics.log.count_added_in_this_iteration_step;
+ }
+
+ i64 TLogarithmicIterator::GetNextValueReportingLevel() const {
+ return Iter_->specifics.log.next_value_reporting_level;
+ }
+
+ i64 TLogarithmicIterator::GetNextValueReportingLevelLowestEquivalent() const {
+ return Iter_->specifics.log.next_value_reporting_level_lowest_equivalent;
+ }
+
+}