SOLR-1284: implement new DISI.advance

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@794714 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2009-07-16 15:17:39 +00:00
parent b5620d8614
commit 3c02e971ea
2 changed files with 49 additions and 0 deletions

View File

@ -107,6 +107,34 @@ public class FunctionQuery extends Query {
vals = func.getValues(reader);
}
@Override
public int docID() {
return doc;
}
@Override
// instead of matching all docs, we could also embed a query.
// the score could either ignore the subscore, or boost it.
// Containment: floatline(foo:myTerm, "myFloatField", 1.0, 0.0f)
// Boost: foo:myTerm^floatline("myFloatField",1.0,0.0f)
public int nextDoc() throws IOException {
for(;;) {
++doc;
if (doc>=maxDoc) {
return doc=NO_MORE_DOCS;
}
if (hasDeletions && reader.isDeleted(doc)) continue;
return doc;
}
}
@Override
public int advance(int target) throws IOException {
// this will work even if target==NO_MORE_DOCS
doc=target-1;
return nextDoc();
}
// instead of matching all docs, we could also embed a query.
// the score could either ignore the subscore, or boost it.
// Containment: floatline(foo:myTerm, "myFloatField", 1.0, 0.0f)

View File

@ -78,6 +78,27 @@ class ValueSourceScorer extends Scorer {
return true;
}
@Override
public int docID() {
return doc;
}
@Override
public int nextDoc() throws IOException {
for(;;) {
doc++;
if (doc >= maxDoc) return doc=NO_MORE_DOCS;
if (matches(doc)) return doc;
}
}
@Override
public int advance(int target) throws IOException {
// also works fine when target==NO_MORE_DOCS
doc = target-1;
return nextDoc();
}
public int doc() {
return doc;
}