Class LongsSketchSortedView
- java.lang.Object
-
- org.apache.datasketches.quantilescommon.LongsSketchSortedView
-
- All Implemented Interfaces:
LongsSortedView
,SortedView
public final class LongsSketchSortedView extends Object implements LongsSortedView
The SortedView of the KllLongsSketch.- Author:
- Lee Rhodes, Zac Blanco
-
-
Constructor Summary
Constructors Constructor Description LongsSketchSortedView(long[] quantiles, long[] cumWeights, QuantilesLongsAPI sk)
Construct from elements, also used in testing.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long[]
getCumulativeWeights()
Returns the array of cumulative weights from the sketch.long
getMaxItem()
Returns the maximum item of the stream.long
getMinItem()
Returns the minimum item of the stream.long
getN()
Returns the total number of items presented to the sourcing sketch.int
getNumRetained()
Gets the number of quantiles retained by this sorted view.long
getQuantile(double rank, QuantileSearchCriteria searchCrit)
Gets the approximate quantile of the given normalized rank and the given search criterion.long[]
getQuantiles()
Returns an array of all retained quantiles by the sketch.double
getRank(long quantile, QuantileSearchCriteria searchCrit)
Gets the normalized rank corresponding to the given a quantile.boolean
isEmpty()
Returns true if this sorted view is empty.LongsSortedViewIterator
iterator()
Returns an iterator for this Sorted View.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.datasketches.quantilescommon.LongsSortedView
getCDF, getPMF
-
-
-
-
Constructor Detail
-
LongsSketchSortedView
public LongsSketchSortedView(long[] quantiles, long[] cumWeights, QuantilesLongsAPI sk)
Construct from elements, also used in testing.- Parameters:
quantiles
- sorted array of quantilescumWeights
- sorted, monotonically increasing cumulative weights.sk
- the underlying quantile sketch.
-
-
Method Detail
-
getCumulativeWeights
public long[] getCumulativeWeights()
Description copied from interface:SortedView
Returns the array of cumulative weights from the sketch. Also known as the natural ranks, which are the Natural Numbers on the interval [1, N].- Specified by:
getCumulativeWeights
in interfaceSortedView
- Returns:
- the array of cumulative weights (or natural ranks).
-
getMaxItem
public long getMaxItem()
Description copied from interface:LongsSortedView
Returns the maximum item of the stream. This may be distinct from the largest item retained by the sketch algorithm.- Specified by:
getMaxItem
in interfaceLongsSortedView
- Returns:
- the maximum item of the stream
-
getMinItem
public long getMinItem()
Description copied from interface:LongsSortedView
Returns the minimum item of the stream. This may be distinct from the smallest item retained by the sketch algorithm.- Specified by:
getMinItem
in interfaceLongsSortedView
- Returns:
- the minimum item of the stream
-
getN
public long getN()
Description copied from interface:SortedView
Returns the total number of items presented to the sourcing sketch.- Specified by:
getN
in interfaceSortedView
- Returns:
- the total number of items presented to the sourcing sketch.
-
getNumRetained
public int getNumRetained()
Description copied from interface:SortedView
Gets the number of quantiles retained by this sorted view. This may be slightly different from the function with the same name when called from the originating sketch.- Specified by:
getNumRetained
in interfaceSortedView
- Returns:
- the number of quantiles retained by this sorted view
-
getQuantile
public long getQuantile(double rank, QuantileSearchCriteria searchCrit)
Description copied from interface:LongsSortedView
Gets the approximate quantile of the given normalized rank and the given search criterion.- Specified by:
getQuantile
in interfaceLongsSortedView
- Parameters:
rank
- the given normalized rank, a double in the range [0.0, 1.0].searchCrit
- If INCLUSIVE, the given rank includes all quantiles ≤ the quantile directly corresponding to the given rank. If EXCLUSIVE, he given rank includes all quantiles < the quantile directly corresponding to the given rank.- Returns:
- the approximate quantile given the normalized rank.
- See Also:
QuantileSearchCriteria
-
getQuantiles
public long[] getQuantiles()
Description copied from interface:LongsSortedView
Returns an array of all retained quantiles by the sketch.- Specified by:
getQuantiles
in interfaceLongsSortedView
- Returns:
- an array of all retained quantiles by the sketch.
-
getRank
public double getRank(long quantile, QuantileSearchCriteria searchCrit)
Description copied from interface:LongsSortedView
Gets the normalized rank corresponding to the given a quantile.- Specified by:
getRank
in interfaceLongsSortedView
- Parameters:
quantile
- the given quantilesearchCrit
- if INCLUSIVE the given quantile is included into the rank.- Returns:
- the normalized rank corresponding to the given quantile.
- See Also:
QuantileSearchCriteria
-
isEmpty
public boolean isEmpty()
Description copied from interface:SortedView
Returns true if this sorted view is empty.- Specified by:
isEmpty
in interfaceSortedView
- Returns:
- true if this sorted view is empty.
-
iterator
public LongsSortedViewIterator iterator()
Description copied from interface:SortedView
Returns an iterator for this Sorted View.- Specified by:
iterator
in interfaceLongsSortedView
- Specified by:
iterator
in interfaceSortedView
- Returns:
- an iterator for this Sorted View.
-
-