org.apache.lucene.util
Class ScorerDocQueue
public class ScorerDocQueue
A ScorerDocQueue maintains a partial ordering of its Scorers such that the
least Scorer can always be found in constant time. Put()'s and pop()'s
require log(size) time. The ordering is by Scorer.doc().
ScorerDocQueue(int maxSize) - Create a ScorerDocQueue with a maximum size.
|
void | adjustTop() - Should be called when the scorer at top changes doc() value.
|
void | clear() - Removes all entries from the ScorerDocQueue.
|
boolean | insert(Scorer scorer) - Adds a Scorer to the ScorerDocQueue in log(size) time if either
the ScorerDocQueue is not full, or not lessThan(scorer, top()).
|
Scorer | pop() - Removes and returns the least scorer of the ScorerDocQueue in log(size)
time.
|
void | put(Scorer scorer) - Adds a Scorer to a ScorerDocQueue in log(size) time.
|
int | size() - Returns the number of scorers currently stored in the ScorerDocQueue.
|
Scorer | top() - Returns the least Scorer of the ScorerDocQueue in constant time.
|
int | topDoc() - Returns document number of the least Scorer of the ScorerDocQueue
in constant time.
|
boolean | topNextAndAdjustElsePop()
|
float | topScore()
|
boolean | topSkipToAndAdjustElsePop(int target)
|
ScorerDocQueue
public ScorerDocQueue(int maxSize)
Create a ScorerDocQueue with a maximum size.
adjustTop
public final void adjustTop()
Should be called when the scorer at top changes doc() value.
Still log(n) worst case, but it's at least twice as fast to
{ pq.top().change(); pq.adjustTop(); }
instead of
{ o = pq.pop(); o.change(); pq.push(o); }
clear
public final void clear()
Removes all entries from the ScorerDocQueue.
insert
public boolean insert(Scorer scorer)
Adds a Scorer to the ScorerDocQueue in log(size) time if either
the ScorerDocQueue is not full, or not lessThan(scorer, top()).
- true if scorer is added, false otherwise.
pop
public final Scorer pop()
Removes and returns the least scorer of the ScorerDocQueue in log(size)
time.
Should not be used when the queue is empty.
put
public final void put(Scorer scorer)
Adds a Scorer to a ScorerDocQueue in log(size) time.
If one tries to add more Scorers than maxSize
a RuntimeException (ArrayIndexOutOfBound) is thrown.
size
public final int size()
Returns the number of scorers currently stored in the ScorerDocQueue.
top
public final Scorer top()
Returns the least Scorer of the ScorerDocQueue in constant time.
Should not be used when the queue is empty.
topDoc
public final int topDoc()
Returns document number of the least Scorer of the ScorerDocQueue
in constant time.
Should not be used when the queue is empty.
topNextAndAdjustElsePop
public final boolean topNextAndAdjustElsePop()
throws IOException
topScore
public final float topScore()
throws IOException
topSkipToAndAdjustElsePop
public final boolean topSkipToAndAdjustElsePop(int target)
throws IOException
Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.