public final class TopNScoredIdAccumulator extends Object implements ScoredIdAccumulator
Accumulate the top N scored IDs. IDs are sorted by their associated scores.
| Constructor and Description |
|---|
TopNScoredIdAccumulator(int n)
Create a new accumulator to accumulate the top n IDs.
|
| Modifier and Type | Method and Description |
|---|---|
List<ScoredId> |
finish()
Accumulate the scores into a sorted scored list and reset the accumulator.
|
LongList |
finishList()
Accumulate the scored items into a list.
|
Long2DoubleMap |
finishMap()
Accumulate the scores into a map and reset the accumulator.
|
LongSet |
finishSet()
Accumulate the scored items into a set.
|
MutableSparseVector |
finishVector()
Accumulate the scores into a mutable sparse vector and reset the accumulator.
|
boolean |
isEmpty()
Query whether the accumulator is empty.
|
void |
put(long item,
double score)
Put a new item in the accumulator.
|
int |
size()
Get the number of items in the accumulator.
|
public TopNScoredIdAccumulator(int n)
Create a new accumulator to accumulate the top n IDs.
n - The number of IDs to retain.public boolean isEmpty()
ScoredIdAccumulatorQuery whether the accumulator is empty.
isEmpty in interface ScoredIdAccumulatortrue if the accumulator has no items.public int size()
ScoredIdAccumulatorGet the number of items in the accumulator.
size in interface ScoredIdAccumulatorpublic void put(long item,
double score)
ScoredIdAccumulatorPut a new item in the accumulator. Putting the same item twice does not replace the previous entry - it adds a new entry with the same ID.
put in interface ScoredIdAccumulatoritem - The item to add to the accumulator.score - The item’s score.public List<ScoredId> finish()
ScoredIdAccumulatorAccumulate the scores into a sorted scored list and reset the accumulator. Items are sorted in decreasing order of score.
After this method is called, the accumulator is ready for another accumulation.
finish in interface ScoredIdAccumulatorpublic MutableSparseVector finishVector()
ScoredIdAccumulatorAccumulate the scores into a mutable sparse vector and reset the accumulator.
After this method is called, the accumulator is ready for another accumulation.
finishVector in interface ScoredIdAccumulatorpublic Long2DoubleMap finishMap()
ScoredIdAccumulatorAccumulate the scores into a map and reset the accumulator.
After this method is called, the accumulator is ready for another accumulation.
finishMap in interface ScoredIdAccumulatorpublic LongSet finishSet()
ScoredIdAccumulatorAccumulate the scored items into a set.
finishSet in interface ScoredIdAccumulatorpublic LongList finishList()
ScoredIdAccumulatorAccumulate the scored items into a list.
finishList in interface ScoredIdAccumulator