java.lang.Object
org.elasticsearch.compute.data.sort.LongTopNSet
- All Implemented Interfaces:
Closeable,AutoCloseable,org.elasticsearch.core.Releasable
Aggregates the top N collected values, and keeps them sorted.
Collection is O(1) for values out of the current top N. For values better than the worst value, it's O(log(n)).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclose()booleancollect(long value) Adds the value to the top N, as long as it is "better" than the worst value, or the top isn't full yet.intgetCount()intgetLimit()getOrder()The order of the sort.longReturns the worst value in the top.voidReduces the limit of the top N by 1.
-
Constructor Details
-
LongTopNSet
-
-
Method Details
-
collect
public boolean collect(long value) Adds the value to the top N, as long as it is "better" than the worst value, or the top isn't full yet. -
reduceLimitByOne
public void reduceLimitByOne()Reduces the limit of the top N by 1.This method is specifically used to count for the null value, and ignore the extra element here without extra cost.
-
getWorstValue
public long getWorstValue()Returns the worst value in the top.The worst is the greatest value for
SortOrder.ASC, and the lowest value forSortOrder.DESC. -
getOrder
The order of the sort. -
getLimit
public int getLimit() -
getCount
public int getCount() -
close
public final void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceorg.elasticsearch.core.Releasable
-