Skip to content

Apache Lucene open-source search software

SOLR-1284: implement new DISI.advance

Yonik Seeley3c02e971ea6b
diff --git a/src/java/org/apache/solr/search/function/FunctionQuery.java b/src/java/org/apache/solr/search/function/FunctionQuery.java
index b643ad9fce3..5fd3f506394 100644
--- a/src/java/org/apache/solr/search/function/FunctionQuery.java
+++ b/src/java/org/apache/solr/search/function/FunctionQuery.java
@@ -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)
diff --git a/src/java/org/apache/solr/search/function/ValueSource.java b/src/java/org/apache/solr/search/function/ValueSource.java
index 46f6d96a3f9..75036e018c5 100644
--- a/src/java/org/apache/solr/search/function/ValueSource.java
+++ b/src/java/org/apache/solr/search/function/ValueSource.java
@@ -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;
}