Class LongsSketchSortedView
java.lang.Object
org.apache.datasketches.quantilescommon.LongsSketchSortedView
- All Implemented Interfaces:
LongsSortedView, SortedView
The SortedView of the KllLongsSketch.
- Author:
- Lee Rhodes, Zac Blanco
-
Constructor Summary
ConstructorsConstructorDescriptionLongsSketchSortedView(long[] quantiles, long[] cumWeights, QuantilesLongsAPI sk) Construct from elements, also used in testing. -
Method Summary
Modifier and TypeMethodDescriptionlong[]Returns the array of cumulative weights from the sketch.longReturns the maximum item of the stream.longReturns the minimum item of the stream.longgetN()Returns the total number of items presented to the sourcing sketch.intGets the number of quantiles retained by this sorted view.longgetQuantile(double rank, QuantileSearchCriteria searchCrit) Gets the approximate quantile of the given normalized rank and the given search criterion.long[]Returns an array of all retained quantiles by the sketch.doublegetRank(long quantile, QuantileSearchCriteria searchCrit) Gets the normalized rank corresponding to the given a quantile.booleanisEmpty()Returns true if this sorted view is empty.iterator()Returns an iterator for this Sorted View.Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface LongsSortedView
getCDF, getPMF
-
Constructor Details
-
LongsSketchSortedView
Construct from elements, also used in testing.- Parameters:
quantiles- sorted array of quantilescumWeights- sorted, monotonically increasing cumulative weights.sk- the underlying quantile sketch.
-
-
Method Details
-
getCumulativeWeights
public long[] getCumulativeWeights()Description copied from interface:SortedViewReturns 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:
getCumulativeWeightsin interfaceSortedView- Returns:
- the array of cumulative weights (or natural ranks).
-
getMaxItem
public long getMaxItem()Description copied from interface:LongsSortedViewReturns the maximum item of the stream. This may be distinct from the largest item retained by the sketch algorithm.- Specified by:
getMaxItemin interfaceLongsSortedView- Returns:
- the maximum item of the stream
-
getMinItem
public long getMinItem()Description copied from interface:LongsSortedViewReturns the minimum item of the stream. This may be distinct from the smallest item retained by the sketch algorithm.- Specified by:
getMinItemin interfaceLongsSortedView- Returns:
- the minimum item of the stream
-
getN
public long getN()Description copied from interface:SortedViewReturns the total number of items presented to the sourcing sketch.- Specified by:
getNin interfaceSortedView- Returns:
- the total number of items presented to the sourcing sketch.
-
getNumRetained
public int getNumRetained()Description copied from interface:SortedViewGets 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:
getNumRetainedin interfaceSortedView- Returns:
- the number of quantiles retained by this sorted view
-
getQuantile
Description copied from interface:LongsSortedViewGets the approximate quantile of the given normalized rank and the given search criterion.- Specified by:
getQuantilein 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:
-
getQuantiles
public long[] getQuantiles()Description copied from interface:LongsSortedViewReturns an array of all retained quantiles by the sketch.- Specified by:
getQuantilesin interfaceLongsSortedView- Returns:
- an array of all retained quantiles by the sketch.
-
getRank
Description copied from interface:LongsSortedViewGets the normalized rank corresponding to the given a quantile.- Specified by:
getRankin 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:
-
isEmpty
public boolean isEmpty()Description copied from interface:SortedViewReturns true if this sorted view is empty.- Specified by:
isEmptyin interfaceSortedView- Returns:
- true if this sorted view is empty.
-
iterator
Description copied from interface:SortedViewReturns an iterator for this Sorted View.- Specified by:
iteratorin interfaceLongsSortedView- Specified by:
iteratorin interfaceSortedView- Returns:
- an iterator for this Sorted View.
-