2020final class FixedCapacityExponentialHistogram implements ExponentialHistogram {
2121
2222 // These arrays represent both the positive and the negative buckets.
23- // They store all buckets for the negative range first, in ascending index order,
24- // followed by all buckets for the positive range, also in ascending index order.
23+ // To avoid confusion, we refer to positions within the array as "slots" instead of indices in this file
24+ // When we use term "index", we mean the exponential histogram bucket index.
25+ // They store all buckets for the negative range first, with the bucket indices in ascending order,
26+ // followed by all buckets for the positive range, also with their indices in ascending order.
2527 // This means we store the buckets ordered by their boundaries in ascending order (from -INF to +INF).
2628 private final long [] bucketIndices ;
2729 private final long [] bucketCounts ;
@@ -197,35 +199,35 @@ public long valueCount() {
197199
198200 private class BucketArrayIterator implements CopyableBucketIterator {
199201
200- int current ;
202+ int currentSlot ;
201203 final int limit ;
202204
203- private BucketArrayIterator (int start , int limit ) {
204- this .current = start ;
205+ private BucketArrayIterator (int startSlot , int limit ) {
206+ this .currentSlot = startSlot ;
205207 this .limit = limit ;
206208 }
207209
208210 @ Override
209211 public boolean hasNext () {
210- return current < limit ;
212+ return currentSlot < limit ;
211213 }
212214
213215 @ Override
214216 public long peekCount () {
215217 ensureEndNotReached ();
216- return bucketCounts [current ];
218+ return bucketCounts [currentSlot ];
217219 }
218220
219221 @ Override
220222 public long peekIndex () {
221223 ensureEndNotReached ();
222- return bucketIndices [current ];
224+ return bucketIndices [currentSlot ];
223225 }
224226
225227 @ Override
226228 public void advance () {
227229 ensureEndNotReached ();
228- current ++;
230+ currentSlot ++;
229231 }
230232
231233 @ Override
@@ -235,7 +237,7 @@ public int scale() {
235237
236238 @ Override
237239 public CopyableBucketIterator copy () {
238- return new BucketArrayIterator (current , limit );
240+ return new BucketArrayIterator (currentSlot , limit );
239241 }
240242
241243 private void ensureEndNotReached () {
0 commit comments