public final class TopNScoredItemAccumulator extends Object implements ScoredItemAccumulator
Constructor and Description |
---|
TopNScoredItemAccumulator(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.
|
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 TopNScoredItemAccumulator(int n)
n
- The number of IDs to retain.public boolean isEmpty()
ScoredItemAccumulator
isEmpty
in interface ScoredItemAccumulator
true
if the accumulator has no items.public int size()
ScoredItemAccumulator
size
in interface ScoredItemAccumulator
public void put(long item, double score)
ScoredItemAccumulator
put
in interface ScoredItemAccumulator
item
- The item to add to the accumulator.score
- The item's score.public List<ScoredId> finish()
ScoredItemAccumulator
After this method is called, the accumulator is ready for another accumulation.
finish
in interface ScoredItemAccumulator
public MutableSparseVector finishVector()
ScoredItemAccumulator
After this method is called, the accumulator is ready for another accumulation.
finishVector
in interface ScoredItemAccumulator
public LongSet finishSet()
ScoredItemAccumulator
finishSet
in interface ScoredItemAccumulator