aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/histogram/hdr/histogram_iter.cpp
blob: d251fd5dd9b95b370f690e9434a5716fc4aa8be1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
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;
    }

}