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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
#pragma once
#include "histogram.h"
struct hdr_iter;
namespace NHdr {
/**
* Used for iterating through histogram values.
*/
class TBaseHistogramIterator {
public:
/**
* Iterate to the next value for the iterator. If there are no more values
* available return false.
*
* @return 'false' if there are no values remaining for this iterator.
*/
bool Next();
/**
* @return Raw index into the counts array.
*/
i32 GetCountsIndex() const;
/**
* @return Snapshot of the length at the time the iterator is created.
*/
i32 GetTotalCount() const;
/**
* @return Value directly from array for the current countsIndex.
*/
i64 GetCount() const;
/**
* @return Sum of all of the counts up to and including the count at
* this index.
*/
i64 GetCumulativeCount() const;
/**
* @return The current value based on countsIndex.
*/
i64 GetValue() const;
/**
* @return The highest value that is equivalent to the current value
* within the histogram's resolution.
*/
i64 GetHighestEquivalentValue() const;
/**
* @return The lowest value that is equivalent to the current value
* within the histogram's resolution.
*/
i64 GetLowestEquivalentValue() const;
/**
* @return The value lies in the middle (rounded up) of the range of
* values equivalent the current value.
*/
i64 GetMedianEquivalentValue() const;
/**
* @return The actual value level that was iterated from by the iterator.
*/
i64 GetValueIteratedFrom() const;
/**
* @return The actual value level that was iterated to by the iterator.
*/
i64 GetValueIteratedTo() const;
protected:
// must not be instantiated directly
TBaseHistogramIterator();
~TBaseHistogramIterator();
protected:
THolder<hdr_iter> Iter_;
};
/**
* Used for iterating through histogram values using the finest granularity
* steps supported by the underlying representation. The iteration steps
* through all possible unit value levels, regardless of whether or not there
* were recorded values for that value level, and terminates when all recorded
* histogram values are exhausted.
*/
class TAllValuesIterator: public TBaseHistogramIterator {
public:
/**
* @param histogram The histogram this iterator will operate on
*/
explicit TAllValuesIterator(const THistogram& histogram);
};
/**
* Used for iterating through all recorded histogram values using the finest
* granularity steps supported by the underlying representation. The iteration
* steps through all non-zero recorded value counts, and terminates when all
* recorded histogram values are exhausted.
*/
class TRecordedValuesIterator: public TBaseHistogramIterator {
public:
/**
* @param histogram The histogram this iterator will operate on
*/
explicit TRecordedValuesIterator(const THistogram& histogram);
/**
* @return The count of recorded values in the histogram that were added
* to the totalCount as a result on this iteration step. Since
* multiple iteration steps may occur with overlapping equivalent
* value ranges, the count may be lower than the count found at
* the value (e.g. multiple linear steps or percentile levels can
* occur within a single equivalent value range).
*/
i64 GetCountAddedInThisIterationStep() const;
};
/**
* Used for iterating through histogram values according to percentile levels.
* The iteration is performed in steps that start at 0% and reduce their
* distance to 100% according to the <i>percentileTicksPerHalfDistance</i>
* parameter, ultimately reaching 100% when all recorded histogram
* values are exhausted.
*/
class TPercentileIterator: public TBaseHistogramIterator {
public:
/**
* @param histogram The histogram this iterator will operate on
* @param ticksPerHalfDistance The number of equal-sized iteration steps
* per half-distance to 100%.
*/
TPercentileIterator(const THistogram& histogram, ui32 ticksPerHalfDistance);
/**
* @return The number of equal-sized iteration steps per half-distance
* to 100%.
*/
i32 GetTicketsPerHalfDistance() const;
double GetPercentileToIterateTo() const;
/**
* @return The percentile of recorded values in the histogram at values
* equal or smaller than valueIteratedTo.
*
*/
double GetPercentile() const;
};
/**
* Used for iterating through histogram values in linear steps. The iteration
* is performed in steps of <i>valueUnitsPerBucket</i> in size, terminating
* when all recorded histogram values are exhausted. Note that each iteration
* "bucket" includes values up to and including the next bucket boundary value.
*/
class TLinearIterator: public TBaseHistogramIterator {
public:
/**
* @param histogram The histogram this iterator will operate on
* @param valueUnitsPerBucket The size (in value units) of each bucket
* iteration.
*/
TLinearIterator(const THistogram& histogram, i64 valueUnitsPerBucket);
/**
* @return The size (in value units) of each bucket iteration.
*/
i64 GetValueUnitsPerBucket() const;
/**
* @return The count of recorded values in the histogram that were added
* to the totalCount as a result on this iteration step. Since
* multiple iteration steps may occur with overlapping equivalent
* value ranges, the count may be lower than the count found at
* the value (e.g. multiple linear steps or percentile levels can
* occur within a single equivalent value range).
*/
i64 GetCountAddedInThisIterationStep() const;
i64 GetNextValueReportingLevel() const;
i64 GetNextValueReportingLevelLowestEquivalent() const;
};
/**
* Used for iterating through histogram values in logarithmically increasing
* levels. The iteration is performed in steps that start at
* <i>valueUnitsInFirstBucket</i> and increase exponentially according to
* <i>logBase</i>, terminating when all recorded histogram values are
* exhausted. Note that each iteration "bucket" includes values up to and
* including the next bucket boundary value.
*/
class TLogarithmicIterator: public TBaseHistogramIterator {
public:
/**
* @param histogram The histogram this iterator will operate on
* @param valueUnitsInFirstBucket the size (in value units) of the first
* value bucket step
* @param logBase the multiplier by which the bucket size is expanded in
* each iteration step.
*/
TLogarithmicIterator(
const THistogram& histogram, i64 valueUnitsInFirstBucket,
double logBase);
/**
* @return The multiplier by which the bucket size is expanded in each
* iteration step.
*/
double GetLogBase() const;
/**
* @return The count of recorded values in the histogram that were added
* to the totalCount as a result on this iteration step. Since
* multiple iteration steps may occur with overlapping equivalent
* value ranges, the count may be lower than the count found at
* the value (e.g. multiple linear steps or percentile levels can
* occur within a single equivalent value range).
*/
i64 GetCountAddedInThisIterationStep() const;
i64 GetNextValueReportingLevel() const;
i64 GetNextValueReportingLevelLowestEquivalent() const;
};
}
|