Methods Summary |
---|
private void | addToList(org.apache.lucene.search.spans.NearSpansUnordered$SpansCell cell)
if (last != null) { // add next to end of list
last.next = cell;
} else
first = cell;
last = cell;
cell.next = null;
|
private boolean | atMatch()
return (min().doc() == max.doc())
&& ((max.end() - min().start() - totalLength) <= slop);
|
public int | doc() return min().doc();
|
public int | end() return max.end();
|
private void | firstToLast()
last.next = first; // move first to end of list
last = first;
first = first.next;
last.next = null;
|
private void | initList(boolean next)
for (int i = 0; more && i < ordered.size(); i++) {
SpansCell cell = (SpansCell)ordered.get(i);
if (next)
more = cell.next(); // move to first entry
if (more) {
addToList(cell); // add to list
}
}
|
private void | listToQueue()
queue.clear(); // rebuild queue
for (SpansCell cell = first; cell != null; cell = cell.next) {
queue.put(cell); // add to queue from list
}
|
private org.apache.lucene.search.spans.NearSpansUnordered$SpansCell | min() return (SpansCell)queue.top();
|
public boolean | next()
if (firstTime) {
initList(true);
listToQueue(); // initialize queue
firstTime = false;
} else if (more) {
if (min().next()) { // trigger further scanning
queue.adjustTop(); // maintain queue
} else {
more = false;
}
}
while (more) {
boolean queueStale = false;
if (min().doc() != max.doc()) { // maintain list
queueToList();
queueStale = true;
}
// skip to doc w/ all clauses
while (more && first.doc() < last.doc()) {
more = first.skipTo(last.doc()); // skip first upto last
firstToLast(); // and move it to the end
queueStale = true;
}
if (!more) return false;
// found doc w/ all clauses
if (queueStale) { // maintain the queue
listToQueue();
queueStale = false;
}
if (atMatch()) {
return true;
}
more = min().next();
if (more) {
queue.adjustTop(); // maintain queue
}
}
return false; // no more matches
|
private void | queueToList()
last = first = null;
while (queue.top() != null) {
addToList((SpansCell)queue.pop());
}
|
public boolean | skipTo(int target)
if (firstTime) { // initialize
initList(false);
for (SpansCell cell = first; more && cell!=null; cell=cell.next) {
more = cell.skipTo(target); // skip all
}
if (more) {
listToQueue();
}
firstTime = false;
} else { // normal case
while (more && min().doc() < target) { // skip as needed
if (min().skipTo(target)) {
queue.adjustTop();
} else {
more = false;
}
}
}
return more && (atMatch() || next());
|
public int | start() return min().start();
|
public java.lang.String | toString()
return getClass().getName() + "("+query.toString()+")@"+
(firstTime?"START":(more?(doc()+":"+start()+"-"+end()):"END"));
|