public class TopNBuffer extends Object implements Serializable
Constructor and Description |
---|
TopNBuffer(Comparator<RowData> sortKeyComparator,
java.util.function.Supplier<Collection<RowData>> valueSupplier) |
Modifier and Type | Method and Description |
---|---|
boolean |
checkSortKeyInBufferRange(RowData sortKey,
long topNum)
Checks whether the record should be put into the buffer.
|
boolean |
containsKey(RowData key)
Returns
true if the buffer contains a mapping for the specified key. |
Set<Map.Entry<RowData,Collection<RowData>>> |
entrySet()
Returns a
Set view of the mappings contained in the buffer. |
Collection<RowData> |
get(RowData sortKey)
Gets the record list from the buffer under the sortKey.
|
int |
getCurrentTopNum()
Gets number of total records.
|
RowData |
getElement(int rank)
Gets record which rank is given value.
|
Comparator<RowData> |
getSortKeyComparator()
Gets sort key comparator used by buffer.
|
RowData |
lastElement()
Returns the last record of the last Entry in the buffer.
|
Map.Entry<RowData,Collection<RowData>> |
lastEntry()
Returns the last Entry in the buffer.
|
int |
put(RowData sortKey,
RowData value)
Appends a record into the buffer.
|
void |
putAll(RowData sortKey,
Collection<RowData> values)
Puts a record list into the buffer under the sortKey.
|
void |
remove(RowData sortKey,
RowData value) |
void |
removeAll(RowData sortKey)
Removes all record list from the buffer under the sortKey.
|
RowData |
removeLast()
Removes the last record of the last Entry in the buffer.
|
public TopNBuffer(Comparator<RowData> sortKeyComparator, java.util.function.Supplier<Collection<RowData>> valueSupplier)
public int put(RowData sortKey, RowData value)
sortKey
- sort key with which the specified value is to be associatedvalue
- record which is to be appendedpublic void putAll(RowData sortKey, Collection<RowData> values)
sortKey
- sort key with which the specified values are to be associatedvalues
- record lists to be associated with the specified keypublic Collection<RowData> get(RowData sortKey)
sortKey
- key to getpublic void removeAll(RowData sortKey)
sortKey
- key to removepublic RowData removeLast()
public RowData lastElement()
public RowData getElement(int rank)
rank
- rank value to searchpublic Set<Map.Entry<RowData,Collection<RowData>>> entrySet()
Set
view of the mappings contained in the buffer.public Map.Entry<RowData,Collection<RowData>> lastEntry()
public boolean containsKey(RowData key)
true
if the buffer contains a mapping for the specified key.key
- key whose presence in the buffer is to be testedtrue
if the buffer contains a mapping for the specified keypublic int getCurrentTopNum()
public Comparator<RowData> getSortKeyComparator()
public boolean checkSortKeyInBufferRange(RowData sortKey, long topNum)
sortKey
- sortKey to testtopNum
- buffer to addCopyright © 2014–2023 The Apache Software Foundation. All rights reserved.