lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpou...@apache.org
Subject svn commit: r1719081 [4/4] - in /lucene/dev/trunk: lucene/ lucene/core/src/java/org/apache/lucene/index/ lucene/core/src/java/org/apache/lucene/search/ lucene/core/src/java/org/apache/lucene/search/spans/ lucene/core/src/test/org/apache/lucene/search/ ...
Date Thu, 10 Dec 2015 13:43:51 GMT
Modified: lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/search/TestDocValuesRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/search/TestDocValuesRangeQuery.java?rev=1719081&r1=1719080&r2=1719081&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/search/TestDocValuesRangeQuery.java
(original)
+++ lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/search/TestDocValuesRangeQuery.java
Thu Dec 10 13:43:50 2015
@@ -265,12 +265,12 @@ public class TestDocValuesRangeQuery ext
     Query q1 = DocValuesRangeQuery.newLongRange("dv1", 0L, 100L, random().nextBoolean(),
random().nextBoolean());
     Weight w = searcher.createNormalizedWeight(q1, true);
     Scorer s = w.scorer(ctx);
-    assertNotNull(s.asTwoPhaseIterator());
+    assertNotNull(s.twoPhaseIterator());
 
     Query q2 = DocValuesRangeQuery.newBytesRefRange("dv2", toSortableBytes(0L), toSortableBytes(100L),
random().nextBoolean(), random().nextBoolean());
     w = searcher.createNormalizedWeight(q2, true);
     s = w.scorer(ctx);
-    assertNotNull(s.asTwoPhaseIterator());
+    assertNotNull(s.twoPhaseIterator());
 
     reader.close();
     dir.close();

Modified: lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/composite/CompositeVerifyQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/composite/CompositeVerifyQuery.java?rev=1719081&r1=1719080&r2=1719081&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/composite/CompositeVerifyQuery.java
(original)
+++ lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/composite/CompositeVerifyQuery.java
Thu Dec 10 13:43:50 2015
@@ -103,7 +103,7 @@ public class CompositeVerifyQuery extend
 
         final FunctionValues predFuncValues = predicateValueSource.getValues(valueSourceContext,
context);
 
-        final TwoPhaseIterator twoPhaseIterator = new TwoPhaseIterator(indexQueryScorer)
{
+        final TwoPhaseIterator twoPhaseIterator = new TwoPhaseIterator(indexQueryScorer.iterator())
{
           @Override
           public boolean matches() throws IOException {
             return predFuncValues.boolVal(indexQueryScorer.docID());

Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/AssertingScorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/AssertingScorer.java?rev=1719081&r1=1719080&r2=1719081&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/AssertingScorer.java
(original)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/AssertingScorer.java
Thu Dec 10 13:43:50 2015
@@ -57,7 +57,7 @@ public class AssertingScorer extends Sco
     // we cannot assert that state == ITERATING because of CachingScorerWrapper
     switch (docID()) {
     case -1:
-    case NO_MORE_DOCS:
+    case DocIdSetIterator.NO_MORE_DOCS:
       return false;
     default:
       return state != IteratorState.APPROXIMATING; // Matches must be confirmed before calling
freq() or score()
@@ -95,47 +95,63 @@ public class AssertingScorer extends Sco
   }
 
   @Override
-  public int nextDoc() throws IOException {
-    assert state != IteratorState.FINISHED : "nextDoc() called after NO_MORE_DOCS";
-    int nextDoc = in.nextDoc();
-    assert nextDoc > doc : "backwards nextDoc from " + doc + " to " + nextDoc + " " +
in;
-    if (nextDoc == DocIdSetIterator.NO_MORE_DOCS) {
-      state = IteratorState.FINISHED;
-    } else {
-      state = IteratorState.ITERATING;
-    }
-    assert in.docID() == nextDoc;
-    return doc = nextDoc;
+  public String toString() {
+    return "AssertingScorer(" + in + ")";
   }
 
   @Override
-  public int advance(int target) throws IOException {
-    assert state != IteratorState.FINISHED : "advance() called after NO_MORE_DOCS";
-    assert target > doc : "target must be > docID(), got " + target + " <= " + doc;
-    int advanced = in.advance(target);
-    assert advanced >= target : "backwards advance from: " + target + " to: " + advanced;
-    if (advanced == DocIdSetIterator.NO_MORE_DOCS) {
-      state = IteratorState.FINISHED;
-    } else {
-      state = IteratorState.ITERATING;
-    }
-    assert in.docID() == advanced;
-    return doc = advanced;
-  }
+  public DocIdSetIterator iterator() {
+    final DocIdSetIterator in = this.in.iterator();
+    assert in != null;
+    return new DocIdSetIterator() {
+      
+      @Override
+      public int docID() {
+        assert AssertingScorer.this.in.docID() == in.docID();
+        return in.docID();
+      }
 
-  @Override
-  public long cost() {
-    return in.cost();
-  }
+      @Override
+      public int nextDoc() throws IOException {
+        assert state != IteratorState.FINISHED : "nextDoc() called after NO_MORE_DOCS";
+        int nextDoc = in.nextDoc();
+        assert nextDoc > doc : "backwards nextDoc from " + doc + " to " + nextDoc + "
" + in;
+        if (nextDoc == DocIdSetIterator.NO_MORE_DOCS) {
+          state = IteratorState.FINISHED;
+        } else {
+          state = IteratorState.ITERATING;
+        }
+        assert in.docID() == nextDoc;
+        assert AssertingScorer.this.in.docID() == in.docID();
+        return doc = nextDoc;
+      }
 
-  @Override
-  public String toString() {
-    return "AssertingScorer(" + in + ")";
+      @Override
+      public int advance(int target) throws IOException {
+        assert state != IteratorState.FINISHED : "advance() called after NO_MORE_DOCS";
+        assert target > doc : "target must be > docID(), got " + target + " <= "
+ doc;
+        int advanced = in.advance(target);
+        assert advanced >= target : "backwards advance from: " + target + " to: " + advanced;
+        if (advanced == DocIdSetIterator.NO_MORE_DOCS) {
+          state = IteratorState.FINISHED;
+        } else {
+          state = IteratorState.ITERATING;
+        }
+        assert in.docID() == advanced;
+        assert AssertingScorer.this.in.docID() == in.docID();
+        return doc = advanced;
+      }
+
+      @Override
+      public long cost() {
+        return in.cost();
+      }
+    };
   }
 
   @Override
-  public TwoPhaseIterator asTwoPhaseIterator() {
-    final TwoPhaseIterator in = this.in.asTwoPhaseIterator();
+  public TwoPhaseIterator twoPhaseIterator() {
+    final TwoPhaseIterator in = this.in.twoPhaseIterator();
     if (in == null) {
       return null;
     }
@@ -189,7 +205,7 @@ public class AssertingScorer extends Sco
         assert state == IteratorState.APPROXIMATING;
         final boolean matches = in.matches();
         if (matches) {
-          assert AssertingScorer.this.in.docID() == inApproximation.docID() : "Approximation
and scorer don't advance synchronously";
+          assert AssertingScorer.this.in.iterator().docID() == inApproximation.docID() :
"Approximation and scorer don't advance synchronously";
           doc = inApproximation.docID();
           state = IteratorState.ITERATING;
         }

Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/BulkScorerWrapperScorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/BulkScorerWrapperScorer.java?rev=1719081&r1=1719080&r2=1719081&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/BulkScorerWrapperScorer.java
(original)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/BulkScorerWrapperScorer.java
Thu Dec 10 13:43:50 2015
@@ -84,29 +84,39 @@ public class BulkScorerWrapperScorer ext
   }
 
   @Override
-  public int nextDoc() throws IOException {
-    return advance(docID() + 1);
-  }
+  public DocIdSetIterator iterator() {
+    return new DocIdSetIterator() {
+      @Override
+      public int docID() {
+        return doc;
+      }
 
-  @Override
-  public int advance(int target) throws IOException {
-    if (bufferLength == 0 || docs[bufferLength - 1] < target) {
-      refill(target);
-    }
-
-    i = Arrays.binarySearch(docs, i + 1, bufferLength, target);
-    if (i < 0) {
-      i = -1 - i;
-    }
-    if (i == bufferLength) {
-      return doc = DocIdSetIterator.NO_MORE_DOCS;
-    }
-    return doc = docs[i];
-  }
+      @Override
+      public int nextDoc() throws IOException {
+        return advance(docID() + 1);
+      }
 
-  @Override
-  public long cost() {
-    return scorer.cost();
+      @Override
+      public int advance(int target) throws IOException {
+        if (bufferLength == 0 || docs[bufferLength - 1] < target) {
+          refill(target);
+        }
+
+        i = Arrays.binarySearch(docs, i + 1, bufferLength, target);
+        if (i < 0) {
+          i = -1 - i;
+        }
+        if (i == bufferLength) {
+          return doc = DocIdSetIterator.NO_MORE_DOCS;
+        }
+        return doc = docs[i];
+      }
+
+      @Override
+      public long cost() {
+        return scorer.cost();
+      }
+    };
   }
 
 }

Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/QueryUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/QueryUtils.java?rev=1719081&r1=1719080&r2=1719081&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/QueryUtils.java
(original)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/QueryUtils.java
Thu Dec 10 13:43:50 2015
@@ -322,6 +322,7 @@ public class QueryUtils {
         s.search(q, new SimpleCollector() {
           private Scorer sc;
           private Scorer scorer;
+          private DocIdSetIterator iterator;
           private int leafPtr;
 
           @Override
@@ -338,13 +339,14 @@ public class QueryUtils {
                 Weight w = s.createNormalizedWeight(q, true);
                 LeafReaderContext context = readerContextArray.get(leafPtr);
                 scorer = w.scorer(context);
+                iterator = scorer.iterator();
               }
               
               int op = order[(opidx[0]++) % order.length];
               // System.out.println(op==skip_op ?
               // "skip("+(sdoc[0]+1)+")":"next()");
-              boolean more = op == skip_op ? scorer.advance(scorer.docID() + 1) != DocIdSetIterator.NO_MORE_DOCS
-                  : scorer.nextDoc() != DocIdSetIterator.NO_MORE_DOCS;
+              boolean more = op == skip_op ? iterator.advance(scorer.docID() + 1) != DocIdSetIterator.NO_MORE_DOCS
+                  : iterator.nextDoc() != DocIdSetIterator.NO_MORE_DOCS;
               int scorerDoc = scorer.docID();
               float scorerScore = scorer.score();
               float scorerScore2 = scorer.score();
@@ -403,9 +405,10 @@ public class QueryUtils {
               LeafReaderContext ctx = (LeafReaderContext)indexSearcher.getTopReaderContext();
               Scorer scorer = w.scorer(ctx);
               if (scorer != null) {
+                DocIdSetIterator iterator = scorer.iterator();
                 boolean more = false;
                 final Bits liveDocs = context.reader().getLiveDocs();
-                for (int d = scorer.advance(lastDoc[0] + 1); d != DocIdSetIterator.NO_MORE_DOCS;
d = scorer.nextDoc()) {
+                for (int d = iterator.advance(lastDoc[0] + 1); d != DocIdSetIterator.NO_MORE_DOCS;
d = iterator.nextDoc()) {
                   if (liveDocs == null || liveDocs.get(d)) {
                     more = true;
                     break;
@@ -432,9 +435,10 @@ public class QueryUtils {
           LeafReaderContext ctx = previousReader.getContext();
           Scorer scorer = w.scorer(ctx);
           if (scorer != null) {
+            DocIdSetIterator iterator = scorer.iterator();
             boolean more = false;
             final Bits liveDocs = lastReader[0].getLiveDocs();
-            for (int d = scorer.advance(lastDoc[0] + 1); d != DocIdSetIterator.NO_MORE_DOCS;
d = scorer.nextDoc()) {
+            for (int d = iterator.advance(lastDoc[0] + 1); d != DocIdSetIterator.NO_MORE_DOCS;
d = iterator.nextDoc()) {
               if (liveDocs == null || liveDocs.get(d)) {
                 more = true;
                 break;
@@ -468,7 +472,7 @@ public class QueryUtils {
           for (int i=lastDoc[0]+1; i<=doc; i++) {
             Weight w = s.createNormalizedWeight(q, true);
             Scorer scorer = w.scorer(context.get(leafPtr));
-            Assert.assertTrue("query collected "+doc+" but advance("+i+") says no more docs!",scorer.advance(i)
!= DocIdSetIterator.NO_MORE_DOCS);
+            Assert.assertTrue("query collected "+doc+" but advance("+i+") says no more docs!",scorer.iterator().advance(i)
!= DocIdSetIterator.NO_MORE_DOCS);
             Assert.assertEquals("query collected "+doc+" but advance("+i+") got to "+scorer.docID(),doc,scorer.docID());
             float advanceScore = scorer.score();
             Assert.assertEquals("unstable advance("+i+") score!",advanceScore,scorer.score(),maxDiff);

@@ -502,9 +506,10 @@ public class QueryUtils {
           Weight w = indexSearcher.createNormalizedWeight(q, true);
           Scorer scorer = w.scorer((LeafReaderContext)indexSearcher.getTopReaderContext());
           if (scorer != null) {
+            DocIdSetIterator iterator = scorer.iterator();
             boolean more = false;
             final Bits liveDocs = context.reader().getLiveDocs();
-            for (int d = scorer.advance(lastDoc[0] + 1); d != DocIdSetIterator.NO_MORE_DOCS;
d = scorer.nextDoc()) {
+            for (int d = iterator.advance(lastDoc[0] + 1); d != DocIdSetIterator.NO_MORE_DOCS;
d = iterator.nextDoc()) {
               if (liveDocs == null || liveDocs.get(d)) {
                 more = true;
                 break;
@@ -529,9 +534,10 @@ public class QueryUtils {
       Weight w = indexSearcher.createNormalizedWeight(q, true);
       Scorer scorer = w.scorer((LeafReaderContext)indexSearcher.getTopReaderContext());
       if (scorer != null) {
+        DocIdSetIterator iterator = scorer.iterator();
         boolean more = false;
         final Bits liveDocs = lastReader[0].getLiveDocs();
-        for (int d = scorer.advance(lastDoc[0] + 1); d != DocIdSetIterator.NO_MORE_DOCS;
d = scorer.nextDoc()) {
+        for (int d = iterator.advance(lastDoc[0] + 1); d != DocIdSetIterator.NO_MORE_DOCS;
d = iterator.nextDoc()) {
           if (liveDocs == null || liveDocs.get(d)) {
             more = true;
             break;
@@ -552,15 +558,16 @@ public class QueryUtils {
         continue;
       } else if (bulkScorer == null) {
         // ensure scorer is exhausted (it just didnt return null)
-        assert scorer.nextDoc() == DocIdSetIterator.NO_MORE_DOCS;
+        assert scorer.iterator().nextDoc() == DocIdSetIterator.NO_MORE_DOCS;
         continue;
       }
+      DocIdSetIterator iterator = scorer.iterator();
       int upTo = 0;
       while (true) {
         final int min = upTo + r.nextInt(5);
         final int max = min + 1 + r.nextInt(r.nextBoolean() ? 10 : 5000);
         if (scorer.docID() < min) {
-          scorer.advance(min);
+          iterator.advance(min);
         }
         final int next = bulkScorer.score(new LeafCollector() {
           Scorer scorer2;
@@ -574,7 +581,7 @@ public class QueryUtils {
             assert doc < max;
             Assert.assertEquals(scorer.docID(), doc);
             Assert.assertEquals(scorer.score(), scorer2.score(), 0.01f);
-            scorer.nextDoc();
+            iterator.nextDoc();
           }
         }, null, min, max);
         assert max <= next;

Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/RandomApproximationQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/RandomApproximationQuery.java?rev=1719081&r1=1719080&r2=1719081&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/RandomApproximationQuery.java
(original)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/RandomApproximationQuery.java
Thu Dec 10 13:43:50 2015
@@ -127,11 +127,11 @@ public class RandomApproximationQuery ex
     RandomApproximationScorer(Scorer scorer, Random random) {
       super(scorer.getWeight());
       this.scorer = scorer;
-      this.twoPhaseView = new RandomTwoPhaseView(random, scorer);
+      this.twoPhaseView = new RandomTwoPhaseView(random, scorer.iterator());
     }
 
     @Override
-    public TwoPhaseIterator asTwoPhaseIterator() {
+    public TwoPhaseIterator twoPhaseIterator() {
       return twoPhaseView;
     }
 
@@ -151,18 +151,8 @@ public class RandomApproximationQuery ex
     }
 
     @Override
-    public int nextDoc() throws IOException {
-      return scorer.nextDoc();
-    }
-
-    @Override
-    public int advance(int target) throws IOException {
-      return scorer.advance(target);
-    }
-
-    @Override
-    public long cost() {
-      return scorer.cost();
+    public DocIdSetIterator iterator() {
+      return scorer.iterator();
     }
 
   }

Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/ScorerIndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/ScorerIndexSearcher.java?rev=1719081&r1=1719080&r2=1719081&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/ScorerIndexSearcher.java
(original)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/ScorerIndexSearcher.java
Thu Dec 10 13:43:50 2015
@@ -51,10 +51,11 @@ public class ScorerIndexSearcher extends
       // Scorer.getChildren
       Scorer scorer = weight.scorer(ctx);
       if (scorer != null) {
+        final DocIdSetIterator iterator = scorer.iterator();
         final LeafCollector leafCollector = collector.getLeafCollector(ctx);
         leafCollector.setScorer(scorer);
         final Bits liveDocs = ctx.reader().getLiveDocs();
-        for (int doc = scorer.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = scorer.nextDoc())
{
+        for (int doc = iterator.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = iterator.nextDoc())
{
           if (liveDocs == null || liveDocs.get(doc)) {
             leafCollector.collect(doc);
           }

Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/spans/AssertingSpanWeight.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/spans/AssertingSpanWeight.java?rev=1719081&r1=1719080&r2=1719081&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/spans/AssertingSpanWeight.java
(original)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/spans/AssertingSpanWeight.java
Thu Dec 10 13:43:50 2015
@@ -26,7 +26,6 @@ import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.Explanation;
 import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Scorer;
 import org.apache.lucene.search.similarities.Similarity;
 
 /**
@@ -56,7 +55,7 @@ public class AssertingSpanWeight extends
     Spans spans = in.getSpans(context, requiredPostings);
     if (spans == null)
       return null;
-    return new AssertingSpans(spans, in.getSimScorer(context));
+    return new AssertingSpans(spans);
   }
 
   @Override
@@ -80,7 +79,7 @@ public class AssertingSpanWeight extends
   }
 
   @Override
-  public Scorer scorer(LeafReaderContext context) throws IOException {
+  public SpanScorer scorer(LeafReaderContext context) throws IOException {
     return in.scorer(context);
   }
 

Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/spans/AssertingSpans.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/spans/AssertingSpans.java?rev=1719081&r1=1719080&r2=1719081&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/spans/AssertingSpans.java
(original)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/search/spans/AssertingSpans.java
Thu Dec 10 13:43:50 2015
@@ -21,7 +21,6 @@ import java.io.IOException;
 
 import org.apache.lucene.search.DocIdSetIterator;
 import org.apache.lucene.search.TwoPhaseIterator;
-import org.apache.lucene.search.similarities.Similarity;
 
 /** 
  * Wraps a Spans with additional asserts
@@ -68,8 +67,7 @@ class AssertingSpans extends Spans {
   
   State state = State.DOC_START;
   
-  AssertingSpans(Spans in, Similarity.SimScorer docScorer) {
-    super((SpanWeight)in.getWeight(), docScorer);
+  AssertingSpans(Spans in) {
     this.in = in;
   }
   
@@ -199,12 +197,6 @@ class AssertingSpans extends Spans {
   }
 
   @Override
-  protected float scoreCurrentDoc() throws IOException {
-    assert in.docScorer != null : in.getClass() + " has no docScorer!";
-    return in.scoreCurrentDoc();
-  }
-
-  @Override
   public TwoPhaseIterator asTwoPhaseIterator() {
     final TwoPhaseIterator iterator = in.asTwoPhaseIterator();
     if (iterator == null) {

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java?rev=1719081&r1=1719080&r2=1719081&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
(original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
Thu Dec 10 13:43:50 2015
@@ -37,6 +37,7 @@ import org.apache.lucene.index.IndexRead
 import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.ReaderUtil;
 import org.apache.lucene.index.Term;
+import org.apache.lucene.search.DocIdSetIterator;
 import org.apache.lucene.search.FieldComparator;
 import org.apache.lucene.search.LeafFieldComparator;
 import org.apache.lucene.search.MatchNoDocsQuery;
@@ -1367,21 +1368,11 @@ public class QueryComponent extends Sear
     }
 
     @Override
-    public int nextDoc() throws IOException {
+    public DocIdSetIterator iterator() {
       throw new UnsupportedOperationException();
     }
 
     @Override
-    public int advance(int target) throws IOException {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public long cost() {
-      return 1;
-    }
-
-    @Override
     public Weight getWeight() {
       throw new UnsupportedOperationException();
     }

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/schema/LatLonType.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/schema/LatLonType.java?rev=1719081&r1=1719080&r2=1719081&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/schema/LatLonType.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/schema/LatLonType.java Thu Dec 10
13:43:50 2015
@@ -31,6 +31,7 @@ import org.apache.lucene.queries.functio
 import org.apache.lucene.search.BooleanClause;
 import org.apache.lucene.search.BooleanQuery;
 import org.apache.lucene.search.ConstantScoreWeight;
+import org.apache.lucene.search.DocIdSetIterator;
 import org.apache.lucene.search.Explanation;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
@@ -427,27 +428,44 @@ class SpatialDistanceQuery extends Exten
       return doc;
     }
 
-    // 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)
     @Override
-    public int nextDoc() throws IOException {
-      for(;;) {
-        ++doc;
-        if (doc>=maxDoc) {
-          return doc=NO_MORE_DOCS;
+    public DocIdSetIterator iterator() {
+      return new DocIdSetIterator() {
+
+        @Override
+        public int docID() {
+          return doc;
         }
-        if (!match()) 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)
+        // Boost:        foo:myTerm^floatline("myFloatField",1.0,0.0f)
+        @Override
+        public int nextDoc() throws IOException {
+          for(;;) {
+            ++doc;
+            if (doc>=maxDoc) {
+              return doc=NO_MORE_DOCS;
+            }
+            if (!match()) 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();
+        }
+
+        @Override
+        public long cost() {
+          return maxDoc;
+        }
+
+      };
     }
 
     @Override
@@ -461,11 +479,6 @@ class SpatialDistanceQuery extends Exten
       return 1;
     }
 
-    @Override
-    public long cost() {
-      return maxDoc;
-    }
-
     public Explanation explain(Explanation base, int doc) throws IOException {
       if (base.isMatch() == false) {
         return base;

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java?rev=1719081&r1=1719080&r2=1719081&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
(original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
Thu Dec 10 13:43:50 2015
@@ -447,20 +447,13 @@ public class CollapsingQParserPlugin ext
       return 0;
     }
 
-    public int advance(int i) {
-      return -1;
-    }
-
-    public int nextDoc() {
-      return 0;
-    }
-
     public int docID() {
       return docId;
     }
 
-    public long cost() {
-      return 0;
+    @Override
+    public DocIdSetIterator iterator() {
+      throw new UnsupportedOperationException();
     }
   }
 

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/Filter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/Filter.java?rev=1719081&r1=1719080&r2=1719081&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/Filter.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/Filter.java Thu Dec 10 13:43:50
2015
@@ -106,7 +106,7 @@ public abstract class Filter extends Que
       @Override
       public Explanation explain(LeafReaderContext context, int doc) throws IOException {
         final Scorer scorer = scorer(context);
-        final boolean match = (scorer != null && scorer.advance(doc) == doc);
+        final boolean match = (scorer != null && scorer.iterator().advance(doc) ==
doc);
         if (match) {
           assert scorer.score() == 0f;
           return Explanation.match(0f, "Match on id " + doc);

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/QueryWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/QueryWrapperFilter.java?rev=1719081&r1=1719080&r2=1719081&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/QueryWrapperFilter.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/QueryWrapperFilter.java Thu
Dec 10 13:43:50 2015
@@ -28,6 +28,7 @@ import org.apache.lucene.search.DocIdSet
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.NumericRangeQuery;
 import org.apache.lucene.search.Query;
+import org.apache.lucene.search.Scorer;
 import org.apache.lucene.search.Weight;
 import org.apache.lucene.util.Bits;
 
@@ -71,7 +72,8 @@ public class QueryWrapperFilter extends
     DocIdSet set = new DocIdSet() {
       @Override
       public DocIdSetIterator iterator() throws IOException {
-        return weight.scorer(privateContext);
+        Scorer scorer = weight.scorer(privateContext);
+        return scorer == null ? null : scorer.iterator();
       }
 
       @Override

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java?rev=1719081&r1=1719080&r2=1719081&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java Thu
Dec 10 13:43:50 2015
@@ -2535,7 +2535,7 @@ class FilterImpl extends Filter {
       for (Weight w : weights) {
         Scorer scorer = w.scorer(context);
         if (scorer == null) return null;
-        iterators.add(scorer);
+        iterators.add(scorer.iterator());
       }
       if (iterators.size()==0) return null;
       if (iterators.size()==1) return iterators.get(0);

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/function/ValueSourceRangeFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/function/ValueSourceRangeFilter.java?rev=1719081&r1=1719080&r2=1719081&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/function/ValueSourceRangeFilter.java
(original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/function/ValueSourceRangeFilter.java
Thu Dec 10 13:43:50 2015
@@ -22,6 +22,7 @@ import org.apache.lucene.queries.functio
 import org.apache.lucene.search.DocIdSet;
 import org.apache.lucene.search.DocIdSetIterator;
 import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Scorer;
 import org.apache.lucene.util.Bits;
 import org.apache.solr.search.BitsFilteredDocIdSet;
 import org.apache.solr.search.SolrFilter;
@@ -78,7 +79,8 @@ public class ValueSourceRangeFilter exte
      return BitsFilteredDocIdSet.wrap(new DocIdSet() {
        @Override
        public DocIdSetIterator iterator() throws IOException {
-         return valueSource.getValues(context, readerContext).getRangeScorer(readerContext.reader(),
lowerVal, upperVal, includeLower, includeUpper);
+         Scorer scorer = valueSource.getValues(context, readerContext).getRangeScorer(readerContext.reader(),
lowerVal, upperVal, includeLower, includeUpper);
+         return scorer == null ? null : scorer.iterator();
        }
        @Override
        public Bits bits() {

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/join/GraphQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/join/GraphQuery.java?rev=1719081&r1=1719080&r2=1719081&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/join/GraphQuery.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/join/GraphQuery.java Thu Dec
10 13:43:50 2015
@@ -150,7 +150,7 @@ public class GraphQuery extends Query {
     public Explanation explain(LeafReaderContext context, int doc) throws IOException {
       // currently no ranking for graph queries. 
       final Scorer cs = scorer(context);
-      final boolean exists = (cs != null && cs.advance(doc) == doc);
+      final boolean exists = (cs != null && cs.iterator().advance(doc) == doc);
       if (exists) {
         List<Explanation> subs = new ArrayList<Explanation>();
         return Explanation.match(1.0F, "Graph Match", subs);
@@ -331,12 +331,12 @@ public class GraphQuery extends Query {
       // no dynamic scoring now.  
       return score;
     }
-    
+
     @Override
-    public int nextDoc() throws IOException {
-      return iter.nextDoc();
+    public DocIdSetIterator iterator() {
+      return iter;
     }
-    
+
     @Override
     public int docID() {
       // current position of the doc iterator.
@@ -344,20 +344,9 @@ public class GraphQuery extends Query {
     }
     
     @Override
-    public int advance(int target) throws IOException {
-      return iter.advance(target);
-    }
-    
-    @Override
     public int freq() throws IOException {
       return 1;
     }
-    
-    @Override
-    public long cost() {
-      // TODO: potentially very expensive!  what's a good value for this?
-      return 0;
-    }
   }
   
   /**

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestQueryWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestQueryWrapperFilter.java?rev=1719081&r1=1719080&r2=1719081&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestQueryWrapperFilter.java
(original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestQueryWrapperFilter.java
Thu Dec 10 13:43:50 2015
@@ -229,7 +229,7 @@ public class TestQueryWrapperFilter exte
     final Query query = new QueryWrapperFilter(new RandomApproximationQuery(new TermQuery(new
Term("foo", "bar")), random()));
     final Weight weight = searcher.createNormalizedWeight(query, random().nextBoolean());
     final Scorer scorer = weight.scorer(reader.leaves().get(0));
-    assertNotNull(scorer.asTwoPhaseIterator());
+    assertNotNull(scorer.twoPhaseIterator());
     reader.close();
     dir.close();
   }

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestRankQueryPlugin.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestRankQueryPlugin.java?rev=1719081&r1=1719080&r2=1719081&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestRankQueryPlugin.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestRankQueryPlugin.java Thu
Dec 10 13:43:50 2015
@@ -33,6 +33,7 @@ import org.apache.lucene.index.IndexRead
 import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.NumericDocValues;
 import org.apache.lucene.index.ReaderUtil;
+import org.apache.lucene.search.DocIdSetIterator;
 import org.apache.lucene.search.FieldComparator;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.LeafCollector;
@@ -469,21 +470,11 @@ public class TestRankQueryPlugin extends
       }
 
       @Override
-      public int nextDoc() throws IOException {
+      public DocIdSetIterator iterator() {
         throw new UnsupportedOperationException();
       }
 
       @Override
-      public int advance(int target) throws IOException {
-        throw new UnsupportedOperationException();
-      }
-
-      @Override
-      public long cost() {
-        return 1;
-      }
-
-      @Override
       public Weight getWeight() {
         throw new UnsupportedOperationException();
       }



Mime
View raw message