public class SortedViewIterator extends Object
Prototype example of the recommended iteration loop:
SortedViewIterator itr = sketch.getSortedView().iterator();
while (itr.next()) {
long weight = itr.getWeight();
...
}
Modifier and Type | Field and Description |
---|---|
protected long[] |
cumWeights |
protected int |
index |
protected long |
totalN |
Modifier and Type | Method and Description |
---|---|
long |
getN()
Gets the total count of all items presented to the sketch.
|
long |
getNaturalRank()
Gets the natural rank at the current index.
|
long |
getNaturalRank(QuantileSearchCriteria searchCrit)
Gets the natural rank at the current index (or previous index) based on the chosen search criterion.
|
double |
getNormalizedRank()
Gets the normalized rank at the current index.
|
double |
getNormalizedRank(QuantileSearchCriteria searchCrit)
Gets the normalized rank at the current index (or previous index)
based on the chosen search criterion.
|
long |
getWeight()
Gets the weight contribution of the item at the current index.
|
boolean |
next()
Advances the index and checks if it is valid.
|
protected final long[] cumWeights
protected long totalN
protected int index
public long getNaturalRank()
Don't call this before calling next() for the first time or after getting false from next().
public long getNaturalRank(QuantileSearchCriteria searchCrit)
getN()
) is the total number of items fed to the sketch.
Don't call this before calling next() for the first time or after getting false from next().
searchCrit
- if INCLUSIVE, includes the weight of the item at the current index in the computation of
the natural rank.
Otherwise, it will return the natural rank of the previous index.public long getN()
public double getNormalizedRank()
Don't call this before calling next() for the first time or after getting false from next().
public double getNormalizedRank(QuantileSearchCriteria searchCrit)
getN()
)
and is a fraction in the range (0,1.0].
Don't call this before calling next() for the first time or after getting false from next().
searchCrit
- if INCLUSIVE, includes the normalized rank at the current index.
Otherwise, returns the normalized rank of the previous index.public long getWeight()
Don't call this before calling next() for the first time or after getting false from next().
public boolean next()
Copyright © 2015–2024 The Apache Software Foundation. All rights reserved.