lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r830377 - in /lucene/java/trunk: ./ src/java/org/apache/lucene/search/ src/java/org/apache/lucene/search/function/ src/java/org/apache/lucene/search/payloads/ src/java/org/apache/lucene/search/spans/ src/test/org/apache/lucene/search/ src/t...
Date Tue, 27 Oct 2009 22:29:42 GMT
Author: uschindler
Date: Tue Oct 27 22:29:41 2009
New Revision: 830377

URL: http://svn.apache.org/viewvc?rev=830377&view=rev
Log:
LUCENE-2011: Remove deprecated Scorer.explain(int) and replace by Weight.explain(IR,int) calls in tests and PhraseQuery/SpanQuery explanations methods

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/common-build.xml
    lucene/java/trunk/src/java/org/apache/lucene/search/BooleanScorer.java
    lucene/java/trunk/src/java/org/apache/lucene/search/BooleanScorer2.java
    lucene/java/trunk/src/java/org/apache/lucene/search/ConjunctionScorer.java
    lucene/java/trunk/src/java/org/apache/lucene/search/ConstantScoreQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/DisjunctionMaxScorer.java
    lucene/java/trunk/src/java/org/apache/lucene/search/DisjunctionSumScorer.java
    lucene/java/trunk/src/java/org/apache/lucene/search/FilteredQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/MatchAllDocsQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/MultiPhraseQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/PhraseQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/PhraseScorer.java
    lucene/java/trunk/src/java/org/apache/lucene/search/ReqExclScorer.java
    lucene/java/trunk/src/java/org/apache/lucene/search/ReqOptSumScorer.java
    lucene/java/trunk/src/java/org/apache/lucene/search/ScoreCachingWrappingScorer.java
    lucene/java/trunk/src/java/org/apache/lucene/search/Scorer.java
    lucene/java/trunk/src/java/org/apache/lucene/search/TermQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/TermScorer.java
    lucene/java/trunk/src/java/org/apache/lucene/search/function/CustomScoreQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/function/ValueSourceQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/payloads/PayloadNearQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/payloads/PayloadTermQuery.java
    lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanScorer.java
    lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanWeight.java
    lucene/java/trunk/src/test/org/apache/lucene/search/JustCompileSearch.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanScorer.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestTermScorer.java
    lucene/java/trunk/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Tue Oct 27 22:29:41 2009
@@ -125,6 +125,9 @@
 * LUCENE-1973: Un-deprecate IndexSearcher.setDefaultFieldSortScoring,
   to allow controlling per-IndexSearcher whether scores are computed
   when sorting by field.  (Uwe Schindler, Mike McCandless)
+  
+* LUCENE-2011: Remove deprecated Scorer.explain(int).
+  (Uwe Schindler, Mark Miller)
    
 Bug fixes
 

Modified: lucene/java/trunk/common-build.xml
URL: http://svn.apache.org/viewvc/lucene/java/trunk/common-build.xml?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/common-build.xml (original)
+++ lucene/java/trunk/common-build.xml Tue Oct 27 22:29:41 2009
@@ -42,7 +42,7 @@
   <property name="Name" value="Lucene"/>
   <property name="dev.version" value="3.0-dev"/>
   <property name="version" value="${dev.version}"/>
-  <property name="compatibility.tag" value="lucene_2_9_back_compat_tests_20091023a"/>
+  <property name="compatibility.tag" value="lucene_2_9_back_compat_tests_20091027"/>
   <property name="spec.version" value="${version}"/>	
   <property name="year" value="2000-${current.year}"/>
   <property name="final.name" value="lucene-${name}-${version}"/>

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/BooleanScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/BooleanScorer.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/BooleanScorer.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/BooleanScorer.java Tue Oct 27 22:29:41 2009
@@ -66,6 +66,8 @@
       this.mask = mask;
       this.bucketTable = bucketTable;
     }
+    
+    @Override
     public final void collect(final int doc) throws IOException {
       final BucketTable table = bucketTable;
       final int i = doc & BucketTable.MASK;
@@ -88,14 +90,17 @@
       }
     }
     
+    @Override
     public void setNextReader(IndexReader reader, int docBase) {
       // not needed by this implementation
     }
     
+    @Override
     public void setScorer(Scorer scorer) throws IOException {
       this.scorer = scorer;
     }
     
+    @Override
     public boolean acceptsDocsOutOfOrder() {
       return true;
     }
@@ -113,14 +118,16 @@
     
     public BucketScorer() { super(null); }
     
+    @Override
     public int advance(int target) throws IOException { return NO_MORE_DOCS; }
 
+    @Override
     public int docID() { return doc; }
 
-    public Explanation explain(int doc) throws IOException { return null; }
-    
+    @Override
     public int nextDoc() throws IOException { return NO_MORE_DOCS; }
     
+    @Override
     public float score() throws IOException { return score; }
     
   }
@@ -213,6 +220,7 @@
   }
 
   // firstDocID is ignored since nextDoc() initializes 'current'
+  @Override
   protected boolean score(Collector collector, int max, int firstDocID) throws IOException {
     boolean more;
     Bucket tmp;
@@ -268,18 +276,17 @@
     return false;
   }
   
+  @Override
   public int advance(int target) throws IOException {
     throw new UnsupportedOperationException();
   }
 
+  @Override
   public int docID() {
     return doc;
   }
 
-  public Explanation explain(int doc) {
-    throw new UnsupportedOperationException();
-  }
-
+  @Override
   public int nextDoc() throws IOException {
     boolean more;
     do {
@@ -313,14 +320,17 @@
     return doc = NO_MORE_DOCS;
   }
 
+  @Override
   public float score() {
     return current.score * coordFactors[current.coord];
   }
 
+  @Override
   public void score(Collector collector) throws IOException {
     score(collector, Integer.MAX_VALUE, nextDoc());
   }
   
+  @Override
   public String toString() {
     StringBuilder buffer = new StringBuilder();
     buffer.append("boolean(");

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/BooleanScorer2.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/BooleanScorer2.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/BooleanScorer2.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/BooleanScorer2.java Tue Oct 27 22:29:41 2009
@@ -113,6 +113,8 @@
       super(scorer.getSimilarity());
       this.scorer = scorer;
     }
+
+    @Override
     public float score() throws IOException {
       int doc = docID();
       if (doc >= lastScoredDoc) {
@@ -124,18 +126,21 @@
       }
       return lastDocScore;
     }
+
+    @Override
     public int docID() {
       return scorer.docID();
     }
+
+    @Override
     public int nextDoc() throws IOException {
       return scorer.nextDoc();
     }
+
+    @Override
     public int advance(int target) throws IOException {
       return scorer.advance(target);
     }
-    public Explanation explain(int docNr) throws IOException {
-      return scorer.explain(docNr);
-    }
   }
 
   private Scorer countingDisjunctionSumScorer(final List<Scorer> scorers,
@@ -146,7 +151,7 @@
       // Save the score of lastScoredDoc, so that we don't compute it more than
       // once in score().
       private float lastDocScore = Float.NaN;
-      public float score() throws IOException {
+      @Override public float score() throws IOException {
         int doc = docID();
         if (doc >= lastScoredDoc) {
           if (doc > lastScoredDoc) {
@@ -170,7 +175,7 @@
       // Save the score of lastScoredDoc, so that we don't compute it more than
       // once in score().
       private float lastDocScore = Float.NaN;
-      public float score() throws IOException {
+      @Override public float score() throws IOException {
         int doc = docID();
         if (doc >= lastScoredDoc) {
           if (doc > lastScoredDoc) {
@@ -262,8 +267,8 @@
 
   /** Scores and collects all matching documents.
    * @param collector The collector to which all matching documents are passed through.
-   * <br>When this method is used the {@link #explain(int)} method should not be used.
    */
+  @Override
   public void score(Collector collector) throws IOException {
     collector.setScorer(this);
     while ((doc = countingSumScorer.nextDoc()) != NO_MORE_DOCS) {
@@ -271,6 +276,7 @@
     }
   }
   
+  @Override
   protected boolean score(Collector collector, int max, int firstDocID) throws IOException {
     doc = firstDocID;
     collector.setScorer(this);
@@ -281,36 +287,27 @@
     return doc != NO_MORE_DOCS;
   }
 
+  @Override
   public int docID() {
     return doc;
   }
   
+  @Override
   public int nextDoc() throws IOException {
     return doc = countingSumScorer.nextDoc();
   }
   
+  @Override
   public float score() throws IOException {
     coordinator.nrMatchers = 0;
     float sum = countingSumScorer.score();
     return sum * coordinator.coordFactors[coordinator.nrMatchers];
   }
 
+  @Override
   public int advance(int target) throws IOException {
     return doc = countingSumScorer.advance(target);
   }
-  
-  /** Throws an UnsupportedOperationException.
-   * TODO: Implement an explanation of the coordination factor.
-   * @param doc The document number for the explanation.
-   * @throws UnsupportedOperationException
-   */
-  public Explanation explain(int doc) {
-    throw new UnsupportedOperationException();
- /* How to explain the coordination factor?
-    initCountingSumScorer();
-    return countingSumScorer.explain(doc); // misses coord factor. 
-  */
-  }
 }
 
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/ConjunctionScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/ConjunctionScorer.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/ConjunctionScorer.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/ConjunctionScorer.java Tue Oct 27 22:29:41 2009
@@ -100,6 +100,7 @@
     return doc;
   }
   
+  @Override
   public int advance(int target) throws IOException {
     if (lastDoc == NO_MORE_DOCS) {
       return lastDoc;
@@ -109,14 +110,12 @@
     return lastDoc = doNext();
   }
 
+  @Override
   public int docID() {
     return lastDoc;
   }
   
-  public Explanation explain(int doc) {
-    throw new UnsupportedOperationException();
-  }
-
+  @Override
   public int nextDoc() throws IOException {
     if (lastDoc == NO_MORE_DOCS) {
       return lastDoc;
@@ -127,6 +126,7 @@
     return lastDoc = doNext();
   }
   
+  @Override
   public float score() throws IOException {
     float sum = 0.0f;
     for (int i = 0; i < scorers.length; i++) {

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/ConstantScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/ConstantScoreQuery.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/ConstantScoreQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/ConstantScoreQuery.java Tue Oct 27 22:29:41 2009
@@ -39,10 +39,12 @@
     return filter;
   }
 
+  @Override
   public Query rewrite(IndexReader reader) throws IOException {
     return this;
   }
 
+  @Override
   public void extractTerms(Set<Term> terms) {
     // OK to not add any terms when used for MultiSearcher,
     // but may not be OK for highlighting
@@ -57,28 +59,34 @@
       this.similarity = getSimilarity(searcher);
     }
 
+    @Override
     public Query getQuery() {
       return ConstantScoreQuery.this;
     }
 
+    @Override
     public float getValue() {
       return queryWeight;
     }
 
+    @Override
     public float sumOfSquaredWeights() throws IOException {
       queryWeight = getBoost();
       return queryWeight * queryWeight;
     }
 
+    @Override
     public void normalize(float norm) {
       this.queryNorm = norm;
       queryWeight *= this.queryNorm;
     }
 
+    @Override
     public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
       return new ConstantScorer(similarity, reader, this);
     }
 
+    @Override
     public Explanation explain(IndexReader reader, int doc) throws IOException {
       
       ConstantScorer cs = new ConstantScorer(similarity, reader, this);
@@ -124,38 +132,41 @@
       }
     }
 
+    @Override
     public int nextDoc() throws IOException {
       return docIdSetIterator.nextDoc();
     }
     
+    @Override
     public int docID() {
       return docIdSetIterator.docID();
     }
 
+    @Override
     public float score() throws IOException {
       return theScore;
     }
 
+    @Override
     public int advance(int target) throws IOException {
       return docIdSetIterator.advance(target);
     }
-    
-    public Explanation explain(int doc) throws IOException {
-      throw new UnsupportedOperationException();
-    }
   }
 
+  @Override
   public Weight createWeight(Searcher searcher) {
     return new ConstantScoreQuery.ConstantWeight(searcher);
   }
 
   /** Prints a user-readable version of this query. */
+  @Override
   public String toString(String field) {
     return "ConstantScore(" + filter.toString()
       + (getBoost()==1.0 ? ")" : "^" + getBoost());
   }
 
   /** Returns true if <code>o</code> is equal to this. */
+  @Override
   public boolean equals(Object o) {
     if (this == o) return true;
     if (!(o instanceof ConstantScoreQuery)) return false;
@@ -164,6 +175,7 @@
   }
 
   /** Returns a hash code value for this object. */
+  @Override
   public int hashCode() {
     // Simple add is OK since no existing filter hashcode has a float component.
     return filter.hashCode() + Float.floatToIntBits(getBoost());

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/DisjunctionMaxScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/DisjunctionMaxScorer.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/DisjunctionMaxScorer.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/DisjunctionMaxScorer.java Tue Oct 27 22:29:41 2009
@@ -62,6 +62,7 @@
     heapify();
   }
 
+  @Override
   public int nextDoc() throws IOException {
     if (numScorers == 0) return doc = NO_MORE_DOCS;
     while (subScorers[0].docID() == doc) {
@@ -78,6 +79,7 @@
     return doc = subScorers[0].docID();
   }
 
+  @Override
   public int docID() {
     return doc;
   }
@@ -85,6 +87,7 @@
   /** Determine the current document score.  Initially invalid, until {@link #next()} is called the first time.
    * @return the score of the current generated document
    */
+  @Override
   public float score() throws IOException {
     int doc = subScorers[0].docID();
     float[] sum = { subScorers[0].score() }, max = { sum[0] };
@@ -105,6 +108,7 @@
     }
   }
 
+  @Override
   public int advance(int target) throws IOException {
     if (numScorers == 0) return doc = NO_MORE_DOCS;
     while (subScorers[0].docID() < target) {
@@ -120,14 +124,6 @@
     return doc = subScorers[0].docID();
   }
 
-  /** Explain a score that we computed.  UNSUPPORTED -- see explanation capability in DisjunctionMaxQuery.
-   * @param doc the number of a document we scored
-   * @return the Explanation for our score
-   */
-  public Explanation explain(int doc) throws IOException {
-    throw new UnsupportedOperationException();
-  }
-
   // Organize subScorers into a min heap with scorers generating the earliest document on top.
   private void heapify() {
     for (int i = (numScorers >> 1) - 1; i >= 0; i--) {

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/DisjunctionSumScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/DisjunctionSumScorer.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/DisjunctionSumScorer.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/DisjunctionSumScorer.java Tue Oct 27 22:29:41 2009
@@ -106,7 +106,6 @@
 
   /** Scores and collects all matching documents.
    * @param collector The collector to which all matching documents are passed through.
-   * <br>When this method is used the {@link #explain(int)} method should not be used.
    */
   @Override
   public void score(Collector collector) throws IOException {
@@ -209,8 +208,6 @@
   /**
    * Advances to the first match beyond the current whose document number is
    * greater than or equal to a given target. <br>
-   * When this method is used the {@link #explain(int)} method should not be
-   * used. <br>
    * The implementation uses the skipTo() method on the subscorers.
    * 
    * @param target
@@ -236,31 +233,4 @@
       }
     } while (true);
   }
-  
-  /** @return An explanation for the score of a given document. */
-  @Override
-  public Explanation explain(int doc) throws IOException {
-    Explanation res = new Explanation();
-    float sumScore = 0.0f;
-    int nrMatches = 0;
-    for (Scorer se : subScorers) {
-      Explanation es = se.explain(doc);
-      if (es.getValue() > 0.0f) { // indicates match
-        sumScore += es.getValue();
-        nrMatches++;
-      }
-      res.addDetail(es);
-    }
-    if (nrMatchers >= minimumNrMatchers) {
-      res.setValue(sumScore);
-      res.setDescription("sum over at least " + minimumNrMatchers
-                         + " of " + subScorers.size() + ":");
-    } else {
-      res.setValue(0.0f);
-      res.setDescription(nrMatches + " match(es) but at least "
-                         + minimumNrMatchers + " of "
-                         + subScorers.size() + " needed");
-    }
-    return res;
-  }
 }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/FilteredQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/FilteredQuery.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/FilteredQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/FilteredQuery.java Tue Oct 27 22:29:41 2009
@@ -65,14 +65,21 @@
       private float value;
         
       // pass these methods through to enclosed query's weight
+      @Override
       public float getValue() { return value; }
+      
+      @Override
       public float sumOfSquaredWeights() throws IOException { 
         return weight.sumOfSquaredWeights() * getBoost() * getBoost(); 
       }
+
+      @Override
       public void normalize (float v) { 
         weight.normalize(v);
         value = weight.getValue() * getBoost();
       }
+
+      @Override
       public Explanation explain (IndexReader ir, int i) throws IOException {
         Explanation inner = weight.explain (ir, i);
         if (getBoost()!=1) {
@@ -98,9 +105,11 @@
       }
 
       // return this query
+      @Override
       public Query getQuery() { return FilteredQuery.this; }
 
       // return a filtering scorer
+      @Override
       public Scorer scorer(IndexReader indexReader, boolean scoreDocsInOrder, boolean topScorer)
           throws IOException {
         final Scorer scorer = weight.scorer(indexReader, true, false);
@@ -131,6 +140,7 @@
             return scorerDoc;
           }
 
+          @Override
           public int nextDoc() throws IOException {
             int scorerDoc, disiDoc;
             return doc = (disiDoc = docIdSetIterator.nextDoc()) != NO_MORE_DOCS
@@ -138,8 +148,10 @@
                 && advanceToCommon(scorerDoc, disiDoc) != NO_MORE_DOCS ? scorer.docID() : NO_MORE_DOCS;
           }
           
+          @Override
           public int docID() { return doc; }
           
+          @Override
           public int advance(int target) throws IOException {
             int disiDoc, scorerDoc;
             return doc = (disiDoc = docIdSetIterator.advance(target)) != NO_MORE_DOCS
@@ -147,27 +159,15 @@
                 && advanceToCommon(scorerDoc, disiDoc) != NO_MORE_DOCS ? scorer.docID() : NO_MORE_DOCS;
           }
 
+          @Override
           public float score() throws IOException { return getBoost() * scorer.score(); }
-
-          // add an explanation about whether the document was filtered
-          public Explanation explain (int i) throws IOException {
-            Explanation exp = scorer.explain(i);
-            
-            if (docIdSetIterator.advance(i) == i) {
-              exp.setDescription ("allowed by filter: "+exp.getDescription());
-              exp.setValue(getBoost() * exp.getValue());
-            } else {
-              exp.setDescription ("removed by filter: "+exp.getDescription());
-              exp.setValue(0.0f);
-            }
-            return exp;
-          }
         };
       }
     };
   }
 
   /** Rewrites the wrapped query. */
+  @Override
   public Query rewrite(IndexReader reader) throws IOException {
     Query rewritten = query.rewrite(reader);
     if (rewritten != query) {
@@ -188,11 +188,13 @@
   }
 
   // inherit javadoc
+  @Override
   public void extractTerms(Set<Term> terms) {
       getQuery().extractTerms(terms);
   }
 
   /** Prints a user-readable version of this query. */
+  @Override
   public String toString (String s) {
     StringBuilder buffer = new StringBuilder();
     buffer.append("filtered(");
@@ -204,6 +206,7 @@
   }
 
   /** Returns true iff <code>o</code> is equal to this. */
+  @Override
   public boolean equals(Object o) {
     if (o instanceof FilteredQuery) {
       FilteredQuery fq = (FilteredQuery) o;
@@ -213,6 +216,7 @@
   }
 
   /** Returns a hash code value for this object. */
+  @Override
   public int hashCode() {
     return query.hashCode() ^ filter.hashCode() + Float.floatToRawIntBits(getBoost());
   }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/MatchAllDocsQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/MatchAllDocsQuery.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/MatchAllDocsQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/MatchAllDocsQuery.java Tue Oct 27 22:29:41 2009
@@ -58,22 +58,22 @@
       this.norms = norms;
     }
 
-    public Explanation explain(int doc) {
-      return null; // not called... see MatchAllDocsWeight.explain()
-    }
-
+    @Override
     public int docID() {
       return doc;
     }
 
+    @Override
     public int nextDoc() throws IOException {
       return doc = termDocs.next() ? termDocs.doc() : NO_MORE_DOCS;
     }
     
+    @Override
     public float score() {
       return norms == null ? score : score * Similarity.decodeNorm(norms[docID()]);
     }
 
+    @Override
     public int advance(int target) throws IOException {
       return doc = termDocs.skipTo(target) ? termDocs.doc() : NO_MORE_DOCS;
     }
@@ -88,33 +88,40 @@
       this.similarity = searcher.getSimilarity();
     }
 
+    @Override
     public String toString() {
       return "weight(" + MatchAllDocsQuery.this + ")";
     }
 
+    @Override
     public Query getQuery() {
       return MatchAllDocsQuery.this;
     }
 
+    @Override
     public float getValue() {
       return queryWeight;
     }
 
+    @Override
     public float sumOfSquaredWeights() {
       queryWeight = getBoost();
       return queryWeight * queryWeight;
     }
 
+    @Override
     public void normalize(float queryNorm) {
       this.queryNorm = queryNorm;
       queryWeight *= this.queryNorm;
     }
 
+    @Override
     public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
       return new MatchAllScorer(reader, similarity, this,
           normsField != null ? reader.norms(normsField) : null);
     }
 
+    @Override
     public Explanation explain(IndexReader reader, int doc) {
       // explain query weight
       Explanation queryExpl = new ComplexExplanation
@@ -128,13 +135,16 @@
     }
   }
 
+  @Override
   public Weight createWeight(Searcher searcher) {
     return new MatchAllDocsWeight(searcher);
   }
 
+  @Override
   public void extractTerms(Set<Term> terms) {
   }
 
+  @Override
   public String toString(String field) {
     StringBuilder buffer = new StringBuilder();
     buffer.append("*:*");
@@ -142,6 +152,7 @@
     return buffer.toString();
   }
 
+  @Override
   public boolean equals(Object o) {
     if (!(o instanceof MatchAllDocsQuery))
       return false;
@@ -149,6 +160,7 @@
     return this.getBoost() == other.getBoost();
   }
 
+  @Override
   public int hashCode() {
     return Float.floatToIntBits(getBoost()) ^ 0x1AA71190;
   }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/MultiPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/MultiPhraseQuery.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/MultiPhraseQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/MultiPhraseQuery.java Tue Oct 27 22:29:41 2009
@@ -113,6 +113,7 @@
   }
 
   // inherit javadoc
+  @Override
   public void extractTerms(Set<Term> terms) {
     for (final Term[] arr : termArrays) {
       for (final Term term: arr) {
@@ -142,20 +143,26 @@
       }
     }
 
+    @Override
     public Query getQuery() { return MultiPhraseQuery.this; }
+
+    @Override
     public float getValue() { return value; }
 
+    @Override
     public float sumOfSquaredWeights() {
       queryWeight = idf * getBoost();             // compute query weight
       return queryWeight * queryWeight;           // square it
     }
 
+    @Override
     public void normalize(float queryNorm) {
       this.queryNorm = queryNorm;
       queryWeight *= queryNorm;                   // normalize query weight
       value = queryWeight * idf;                  // idf for document 
     }
 
+    @Override
     public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
       if (termArrays.size() == 0)                  // optimize zero-term case
         return null;
@@ -184,6 +191,7 @@
                                       slop, reader.norms(field));
     }
 
+    @Override
     public Explanation explain(IndexReader reader, int doc)
       throws IOException {
       ComplexExplanation result = new ComplexExplanation();
@@ -215,12 +223,16 @@
       fieldExpl.setDescription("fieldWeight("+getQuery()+" in "+doc+
                                "), product of:");
 
-      Scorer scorer = scorer(reader, true, false);
+      PhraseScorer scorer = (PhraseScorer) scorer(reader, true, false);
       if (scorer == null) {
         return new Explanation(0.0f, "no matching docs");
       }
-      Explanation tfExpl = scorer.explain(doc);
-      fieldExpl.addDetail(tfExpl);
+      Explanation tfExplanation = new Explanation();
+      int d = scorer.advance(doc);
+      float phraseFreq = (d == doc) ? scorer.currentFreq() : 0.0f;
+      tfExplanation.setValue(similarity.tf(phraseFreq));
+      tfExplanation.setDescription("tf(phraseFreq=" + phraseFreq + ")");
+      fieldExpl.addDetail(tfExplanation);
       fieldExpl.addDetail(idfExpl);
 
       Explanation fieldNormExpl = new Explanation();
@@ -231,8 +243,8 @@
       fieldNormExpl.setDescription("fieldNorm(field="+field+", doc="+doc+")");
       fieldExpl.addDetail(fieldNormExpl);
 
-      fieldExpl.setMatch(Boolean.valueOf(tfExpl.isMatch()));
-      fieldExpl.setValue(tfExpl.getValue() *
+      fieldExpl.setMatch(Boolean.valueOf(tfExplanation.isMatch()));
+      fieldExpl.setValue(tfExplanation.getValue() *
                          idfExpl.getValue() *
                          fieldNormExpl.getValue());
 
@@ -249,6 +261,7 @@
     }
   }
 
+  @Override
   public Query rewrite(IndexReader reader) {
     if (termArrays.size() == 1) {                 // optimize one-term case
       Term[] terms = termArrays.get(0);
@@ -263,11 +276,13 @@
     }
   }
 
+  @Override
   public Weight createWeight(Searcher searcher) throws IOException {
     return new MultiPhraseWeight(searcher);
   }
 
   /** Prints a user-readable version of this query. */
+  @Override
   public final String toString(String f) {
     StringBuilder buffer = new StringBuilder();
     if (!field.equals(f)) {
@@ -307,6 +322,7 @@
 
 
   /** Returns true if <code>o</code> is equal to this. */
+  @Override
   public boolean equals(Object o) {
     if (!(o instanceof MultiPhraseQuery)) return false;
     MultiPhraseQuery other = (MultiPhraseQuery)o;
@@ -317,6 +333,7 @@
   }
 
   /** Returns a hash code value for this object.*/
+  @Override
   public int hashCode() {
     return Float.floatToIntBits(getBoost())
       ^ slop
@@ -330,25 +347,11 @@
     int hashCode = 1;
     for (final Term[] termArray: termArrays) {
       hashCode = 31 * hashCode
-          + (termArray == null ? 0 : arraysHashCode(termArray));
+          + (termArray == null ? 0 : Arrays.hashCode(termArray));
     }
     return hashCode;
   }
 
-  private int arraysHashCode(Term[] termArray) {
-      if (termArray == null)
-          return 0;
-
-      int result = 1;
-
-      for (int i = 0; i < termArray.length; i++) {
-        Term term = termArray[i];
-        result = 31 * result + (term == null ? 0 : term.hashCode());
-      }
-
-      return result;
-  }
-
   // Breakout calculation of the termArrays equals
   private boolean termArraysEquals(List<Term[]> termArrays1, List<Term[]> termArrays2) {
     if (termArrays1.size() != termArrays2.size()) {

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/PhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/PhraseQuery.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/PhraseQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/PhraseQuery.java Tue Oct 27 22:29:41 2009
@@ -123,22 +123,29 @@
       idf = idfExp.getIdf();
     }
 
+    @Override
     public String toString() { return "weight(" + PhraseQuery.this + ")"; }
 
+    @Override
     public Query getQuery() { return PhraseQuery.this; }
+
+    @Override
     public float getValue() { return value; }
 
+    @Override
     public float sumOfSquaredWeights() {
       queryWeight = idf * getBoost();             // compute query weight
       return queryWeight * queryWeight;           // square it
     }
 
+    @Override
     public void normalize(float queryNorm) {
       this.queryNorm = queryNorm;
       queryWeight *= queryNorm;                   // normalize query weight
       value = queryWeight * idf;                  // idf for document 
     }
 
+    @Override
     public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
       if (terms.size() == 0)			  // optimize zero-term case
         return null;
@@ -161,6 +168,7 @@
 
     }
 
+    @Override
     public Explanation explain(IndexReader reader, int doc)
       throws IOException {
 
@@ -208,12 +216,17 @@
       fieldExpl.setDescription("fieldWeight("+field+":"+query+" in "+doc+
                                "), product of:");
 
-      Scorer scorer = scorer(reader, true, false);
+      PhraseScorer scorer = (PhraseScorer) scorer(reader, true, false);
       if (scorer == null) {
         return new Explanation(0.0f, "no matching docs");
       }
-      Explanation tfExpl = scorer.explain(doc);
-      fieldExpl.addDetail(tfExpl);
+      Explanation tfExplanation = new Explanation();
+      int d = scorer.advance(doc);
+      float phraseFreq = (d == doc) ? scorer.currentFreq() : 0.0f;
+      tfExplanation.setValue(similarity.tf(phraseFreq));
+      tfExplanation.setDescription("tf(phraseFreq=" + phraseFreq + ")");
+      
+      fieldExpl.addDetail(tfExplanation);
       fieldExpl.addDetail(idfExpl);
 
       Explanation fieldNormExpl = new Explanation();
@@ -224,7 +237,7 @@
       fieldNormExpl.setDescription("fieldNorm(field="+field+", doc="+doc+")");
       fieldExpl.addDetail(fieldNormExpl);
 
-      fieldExpl.setValue(tfExpl.getValue() *
+      fieldExpl.setValue(tfExplanation.getValue() *
                          idfExpl.getValue() *
                          fieldNormExpl.getValue());
 
@@ -240,6 +253,7 @@
     }
   }
 
+  @Override
   public Weight createWeight(Searcher searcher) throws IOException {
     if (terms.size() == 1) {			  // optimize one-term case
       Term term = terms.get(0);
@@ -253,11 +267,13 @@
   /**
    * @see org.apache.lucene.search.Query#extractTerms(Set)
    */
+  @Override
   public void extractTerms(Set<Term> queryTerms) {
     queryTerms.addAll(terms);
   }
 
   /** Prints a user-readable version of this query. */
+  @Override
   public String toString(String f) {
     StringBuilder buffer = new StringBuilder();
     if (field != null && !field.equals(f)) {
@@ -301,6 +317,7 @@
   }
 
   /** Returns true iff <code>o</code> is equal to this. */
+  @Override
   public boolean equals(Object o) {
     if (!(o instanceof PhraseQuery))
       return false;
@@ -312,6 +329,7 @@
   }
 
   /** Returns a hash code value for this object.*/
+  @Override
   public int hashCode() {
     return Float.floatToIntBits(getBoost())
       ^ slop

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/PhraseScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/PhraseScorer.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/PhraseScorer.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/PhraseScorer.java Tue Oct 27 22:29:41 2009
@@ -69,8 +69,10 @@
     first.doc = -1;
   }
 
+  @Override
   public int docID() { return first.doc; }
 
+  @Override
   public int nextDoc() throws IOException {
     if (firstTime) {
       init();
@@ -104,12 +106,14 @@
     return false;                                 // no more matches
   }
 
+  @Override
   public float score() throws IOException {
     //System.out.println("scoring " + first.doc);
     float raw = getSimilarity().tf(freq) * value; // raw score
     return norms == null ? raw : raw * Similarity.decodeNorm(norms[first.doc]); // normalize
   }
 
+  @Override
   public int advance(int target) throws IOException {
     firstTime = false;
     for (PhrasePositions pp = first; more && pp != null; pp = pp.next) {
@@ -125,6 +129,11 @@
   }
   
   /**
+   * phrase frequency in current doc as computed by phraseFreq().
+   */
+  public final float currentFreq() { return freq; }
+  
+  /**
    * For a document containing all the phrase query terms, compute the
    * frequency of the phrase in that document. 
    * A non zero frequency means a match.
@@ -170,17 +179,7 @@
     last.next = null;
   }
 
-  public Explanation explain(final int doc) throws IOException {
-    Explanation tfExplanation = new Explanation();
-
-    int d = advance(doc);
-    float phraseFreq = (d == doc) ? freq : 0.0f;
-    tfExplanation.setValue(getSimilarity().tf(phraseFreq));
-    tfExplanation.setDescription("tf(phraseFreq=" + phraseFreq + ")");
-
-    return tfExplanation;
-  }
-
+  @Override
   public String toString() { return "scorer(" + weight + ")"; }
 
 }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/ReqExclScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/ReqExclScorer.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/ReqExclScorer.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/ReqExclScorer.java Tue Oct 27 22:29:41 2009
@@ -41,6 +41,7 @@
     this.exclDisi = exclDisi;
   }
 
+  @Override
   public int nextDoc() throws IOException {
     if (reqScorer == null) {
       return doc;
@@ -88,6 +89,7 @@
     return NO_MORE_DOCS;
   }
 
+  @Override
   public int docID() {
     return doc;
   }
@@ -96,10 +98,12 @@
    * Initially invalid, until {@link #next()} is called the first time.
    * @return The score of the required scorer.
    */
+  @Override
   public float score() throws IOException {
     return reqScorer.score(); // reqScorer may be null when next() or skipTo() already return false
   }
   
+  @Override
   public int advance(int target) throws IOException {
     if (reqScorer == null) {
       return doc = NO_MORE_DOCS;
@@ -113,15 +117,4 @@
     }
     return doc = toNonExcluded();
   }
-  
-  public Explanation explain(int doc) throws IOException {
-    Explanation res = new Explanation();
-    if (exclDisi.advance(doc) == doc) {
-      res.setDescription("excluded");
-    } else {
-      res.setDescription("not excluded");
-      res.addDetail(reqScorer.explain(doc));
-    }
-    return res;
-  }
 }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/ReqOptSumScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/ReqOptSumScorer.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/ReqOptSumScorer.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/ReqOptSumScorer.java Tue Oct 27 22:29:41 2009
@@ -43,14 +43,17 @@
     this.optScorer = optScorer;
   }
 
+  @Override
   public int nextDoc() throws IOException {
     return reqScorer.nextDoc();
   }
   
+  @Override
   public int advance(int target) throws IOException {
     return reqScorer.advance(target);
   }
   
+  @Override
   public int docID() {
     return reqScorer.docID();
   }
@@ -60,6 +63,7 @@
    * @return The score of the required scorer, eventually increased by the score
    * of the optional scorer when it also matches the current document.
    */
+  @Override
   public float score() throws IOException {
     int curDoc = reqScorer.docID();
     float reqScore = reqScorer.score();
@@ -76,16 +80,5 @@
     return optScorerDoc == curDoc ? reqScore + optScorer.score() : reqScore;
   }
 
-  /** Explain the score of a document.
-   * TODO: Also show the total score.
-   * See BooleanScorer.explain() on how to do this.
-   */
-  public Explanation explain(int doc) throws IOException {
-    Explanation res = new Explanation();
-    res.setDescription("required, optional");
-    res.addDetail(reqScorer.explain(doc));
-    res.addDetail(optScorer.explain(doc));
-    return res;
-  }
 }
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/ScoreCachingWrappingScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/ScoreCachingWrappingScorer.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/ScoreCachingWrappingScorer.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/ScoreCachingWrappingScorer.java Tue Oct 27 22:29:41 2009
@@ -42,18 +42,17 @@
     this.scorer = scorer;
   }
 
+  @Override
   protected boolean score(Collector collector, int max, int firstDocID) throws IOException {
     return scorer.score(collector, max, firstDocID);
   }
 
+  @Override
   public Similarity getSimilarity() {
     return scorer.getSimilarity();
   }
   
-  public Explanation explain(int doc) throws IOException {
-    return scorer.explain(doc);
-  }
-
+  @Override
   public float score() throws IOException {
     int doc = scorer.docID();
     if (doc != curDoc) {
@@ -64,18 +63,22 @@
     return curScore;
   }
 
+  @Override
   public int docID() {
     return scorer.docID();
   }
 
+  @Override
   public int nextDoc() throws IOException {
     return scorer.nextDoc();
   }
   
+  @Override
   public void score(Collector collector) throws IOException {
     scorer.score(collector);
   }
   
+  @Override
   public int advance(int target) throws IOException {
     return scorer.advance(target);
   }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/Scorer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/Scorer.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/Scorer.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/Scorer.java Tue Oct 27 22:29:41 2009
@@ -56,7 +56,6 @@
 
   /** Scores and collects all matching documents.
    * @param collector The collector to which all matching documents are passed.
-   * <br>When this method is used the {@link #explain(int)} method should not be used.
    */
   public void score(Collector collector) throws IOException {
     collector.setScorer(this);
@@ -97,16 +96,4 @@
    */
   public abstract float score() throws IOException;
 
-  /** Returns an explanation of the score for a document.
-   * <br>When this method is used, the {@link #next()}, {@link #skipTo(int)} and
-   * {@link #score(HitCollector)} methods should not be used.
-   * @param doc The document number for the explanation.
-   *
-   * @deprecated Please use {@link IndexSearcher#explain}
-   * or {@link Weight#explain} instead.
-   */
-  public Explanation explain(int doc) throws IOException {
-    throw new UnsupportedOperationException();
-  }
-
 }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/TermQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/TermQuery.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/TermQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/TermQuery.java Tue Oct 27 22:29:41 2009
@@ -47,22 +47,29 @@
       idf = idfExp.getIdf();
     }
 
+    @Override
     public String toString() { return "weight(" + TermQuery.this + ")"; }
 
+    @Override
     public Query getQuery() { return TermQuery.this; }
+
+    @Override
     public float getValue() { return value; }
 
+    @Override
     public float sumOfSquaredWeights() {
       queryWeight = idf * getBoost();             // compute query weight
       return queryWeight * queryWeight;           // square it
     }
 
+    @Override
     public void normalize(float queryNorm) {
       this.queryNorm = queryNorm;
       queryWeight *= queryNorm;                   // normalize query weight
       value = queryWeight * idf;                  // idf for document
     }
 
+    @Override
     public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
       TermDocs termDocs = reader.termDocs(term);
 
@@ -72,6 +79,7 @@
       return new TermScorer(this, termDocs, similarity, reader.norms(term.field()));
     }
 
+    @Override
     public Explanation explain(IndexReader reader, int doc)
       throws IOException {
 
@@ -104,8 +112,24 @@
       fieldExpl.setDescription("fieldWeight("+term+" in "+doc+
                                "), product of:");
 
-      Explanation tfExpl = scorer(reader, true, false).explain(doc);
-      fieldExpl.addDetail(tfExpl);
+      Explanation tfExplanation = new Explanation();
+      int tf = 0;
+      TermDocs termDocs = reader.termDocs(term);
+      if (termDocs != null) {
+        try {
+          if (termDocs.skipTo(doc) && termDocs.doc() == doc) {
+            tf = termDocs.freq();
+          }
+        } finally {
+          termDocs.close();
+        }
+        tfExplanation.setValue(similarity.tf(tf));
+        tfExplanation.setDescription("tf(termFreq("+term+")="+tf+")");
+      } else {
+        tfExplanation.setValue(0.0f);
+        tfExplanation.setDescription("no matching term");
+      }
+      fieldExpl.addDetail(tfExplanation);
       fieldExpl.addDetail(expl);
 
       Explanation fieldNormExpl = new Explanation();
@@ -116,8 +140,8 @@
       fieldNormExpl.setDescription("fieldNorm(field="+field+", doc="+doc+")");
       fieldExpl.addDetail(fieldNormExpl);
       
-      fieldExpl.setMatch(Boolean.valueOf(tfExpl.isMatch()));
-      fieldExpl.setValue(tfExpl.getValue() *
+      fieldExpl.setMatch(Boolean.valueOf(tfExplanation.isMatch()));
+      fieldExpl.setValue(tfExplanation.getValue() *
                          expl.getValue() *
                          fieldNormExpl.getValue());
 
@@ -142,15 +166,18 @@
   /** Returns the term of this query. */
   public Term getTerm() { return term; }
 
+  @Override
   public Weight createWeight(Searcher searcher) throws IOException {
     return new TermWeight(searcher);
   }
 
+  @Override
   public void extractTerms(Set<Term> terms) {
     terms.add(getTerm());
   }
 
   /** Prints a user-readable version of this query. */
+  @Override
   public String toString(String field) {
     StringBuilder buffer = new StringBuilder();
     if (!term.field().equals(field)) {
@@ -163,6 +190,7 @@
   }
 
   /** Returns true iff <code>o</code> is equal to this. */
+  @Override
   public boolean equals(Object o) {
     if (!(o instanceof TermQuery))
       return false;
@@ -172,6 +200,7 @@
   }
 
   /** Returns a hash code value for this object.*/
+  @Override
   public int hashCode() {
     return Float.floatToIntBits(getBoost()) ^ term.hashCode();
   }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/TermScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/TermScorer.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/TermScorer.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/TermScorer.java Tue Oct 27 22:29:41 2009
@@ -65,11 +65,13 @@
       scoreCache[i] = getSimilarity().tf(i) * weightValue;
   }
 
+  @Override
   public void score(Collector c) throws IOException {
     score(c, Integer.MAX_VALUE, nextDoc());
   }
 
   // firstDocID is ignored since nextDoc() sets 'doc'
+  @Override
   protected boolean score(Collector c, int end, int firstDocID) throws IOException {
     c.setScorer(this);
     while (doc < end) {                           // for docs in window
@@ -90,6 +92,7 @@
     return true;
   }
 
+  @Override
   public int docID() { return doc; }
 
   /**
@@ -99,6 +102,7 @@
    * 
    * @return the document matching the query or -1 if there are no more documents.
    */
+  @Override
   public int nextDoc() throws IOException {
     pointer++;
     if (pointer >= pointerMax) {
@@ -114,6 +118,7 @@
     return doc;
   }
   
+  @Override
   public float score() {
     assert doc != -1;
     int f = freqs[pointer];
@@ -134,6 +139,7 @@
    *          The target document number.
    * @return the matching document or -1 if none exist.
    */
+  @Override
   public int advance(int target) throws IOException {
     // first scan in cache
     for (pointer++; pointer < pointerMax; pointer++) {
@@ -155,34 +161,7 @@
     return doc;
   }
   
-  /** Returns an explanation of the score for a document.
-   * @param doc The document number for the explanation.
-   */
-  public Explanation explain(int doc) throws IOException {
-    TermQuery query = (TermQuery) weight.getQuery();
-    Explanation tfExplanation = new Explanation();
-    int tf = 0;
-    while (pointer < pointerMax) {
-      if (docs[pointer] == doc)
-        tf = freqs[pointer];
-      pointer++;
-    }
-    if (tf == 0) {
-        if (termDocs.skipTo(doc))
-        {
-            if (termDocs.doc() == doc)
-            {
-                tf = termDocs.freq();
-            }
-        }
-    }
-    termDocs.close();
-    tfExplanation.setValue(getSimilarity().tf(tf));
-    tfExplanation.setDescription("tf(termFreq("+query.getTerm()+")="+tf+")");
-    
-    return tfExplanation;
-  }
-
   /** Returns a string representation of this <code>TermScorer</code>. */
+  @Override
   public String toString() { return "scorer(" + weight + ")"; }
 }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/function/CustomScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/function/CustomScoreQuery.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/function/CustomScoreQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/function/CustomScoreQuery.java Tue Oct 27 22:29:41 2009
@@ -90,6 +90,7 @@
   }
 
   /*(non-Javadoc) @see org.apache.lucene.search.Query#rewrite(org.apache.lucene.index.IndexReader) */
+  @Override
   public Query rewrite(IndexReader reader) throws IOException {
     subQuery = subQuery.rewrite(reader);
     for(int i = 0; i < valSrcQueries.length; i++) {
@@ -99,6 +100,7 @@
   }
 
   /*(non-Javadoc) @see org.apache.lucene.search.Query#extractTerms(java.util.Set) */
+  @Override
   public void extractTerms(Set<Term> terms) {
     subQuery.extractTerms(terms);
     for(int i = 0; i < valSrcQueries.length; i++) {
@@ -107,6 +109,7 @@
   }
 
   /*(non-Javadoc) @see org.apache.lucene.search.Query#clone() */
+  @Override
   public Object clone() {
     CustomScoreQuery clone = (CustomScoreQuery)super.clone();
     clone.subQuery = (Query) subQuery.clone();
@@ -118,6 +121,7 @@
   }
 
   /* (non-Javadoc) @see org.apache.lucene.search.Query#toString(java.lang.String) */
+  @Override
   public String toString(String field) {
     StringBuilder sb = new StringBuilder(name()).append("(");
     sb.append(subQuery.toString(field));
@@ -130,6 +134,7 @@
   }
 
   /** Returns true if <code>o</code> is equal to this. */
+  @Override
   public boolean equals(Object o) {
     if (getClass() != o.getClass()) {
       return false;
@@ -149,6 +154,7 @@
   }
 
   /** Returns a hash code value for this object. */
+  @Override
   public int hashCode() {
     int valSrcHash = 0;
     for (int i=0; i<valSrcQueries.length; i++) { //TODO simplify with Arrays.deepHashcode() once moving to Java 1.5
@@ -289,16 +295,19 @@
     }
 
     /*(non-Javadoc) @see org.apache.lucene.search.Weight#getQuery() */
+    @Override
     public Query getQuery() {
       return CustomScoreQuery.this;
     }
 
     /*(non-Javadoc) @see org.apache.lucene.search.Weight#getValue() */
+    @Override
     public float getValue() {
       return getBoost();
     }
 
     /*(non-Javadoc) @see org.apache.lucene.search.Weight#sumOfSquaredWeights() */
+    @Override
     public float sumOfSquaredWeights() throws IOException {
       float sum = subQueryWeight.sumOfSquaredWeights();
       for(int i = 0; i < valSrcWeights.length; i++) {
@@ -313,6 +322,7 @@
     }
 
     /*(non-Javadoc) @see org.apache.lucene.search.Weight#normalize(float) */
+    @Override
     public void normalize(float norm) {
       norm *= getBoost(); // incorporate boost
       subQueryWeight.normalize(norm);
@@ -325,6 +335,7 @@
       }
     }
 
+    @Override
     public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
       // Pass true for "scoresDocsInOrder", because we
       // require in-order scoring, even if caller does not,
@@ -342,24 +353,21 @@
       return new CustomScorer(similarity, reader, this, subQueryScorer, valSrcScorers);
     }
 
+    @Override
     public Explanation explain(IndexReader reader, int doc) throws IOException {
       Explanation explain = doExplain(reader, doc);
       return explain == null ? new Explanation(0.0f, "no matching docs") : doExplain(reader, doc);
     }
     
     private Explanation doExplain(IndexReader reader, int doc) throws IOException {
-      Scorer[] valSrcScorers = new Scorer[valSrcWeights.length];
-      for(int i = 0; i < valSrcScorers.length; i++) {
-         valSrcScorers[i] = valSrcWeights[i].scorer(reader, true, false);
-      }
       Explanation subQueryExpl = subQueryWeight.explain(reader, doc);
       if (!subQueryExpl.isMatch()) {
         return subQueryExpl;
       }
       // match
-      Explanation[] valSrcExpls = new Explanation[valSrcScorers.length];
-      for(int i = 0; i < valSrcScorers.length; i++) {
-        valSrcExpls[i] = valSrcScorers[i].explain(doc);
+      Explanation[] valSrcExpls = new Explanation[valSrcWeights.length];
+      for(int i = 0; i < valSrcWeights.length; i++) {
+        valSrcExpls[i] = valSrcWeights[i].explain(reader, doc);
       }
       Explanation customExp = customExplain(doc,subQueryExpl,valSrcExpls);
       float sc = getValue() * customExp.getValue();
@@ -370,6 +378,7 @@
       return res;
     }
 
+    @Override
     public boolean scoresDocsOutOfOrder() {
       return false;
     }
@@ -402,6 +411,7 @@
       this.vScores = new float[valSrcScorers.length];
     }
 
+    @Override
     public int nextDoc() throws IOException {
       int doc = subQueryScorer.nextDoc();
       if (doc != NO_MORE_DOCS) {
@@ -412,11 +422,13 @@
       return doc;
     }
 
+    @Override
     public int docID() {
       return subQueryScorer.docID();
     }
     
     /*(non-Javadoc) @see org.apache.lucene.search.Scorer#score() */
+    @Override
     public float score() throws IOException {
       for (int i = 0; i < valSrcScorers.length; i++) {
         vScores[i] = valSrcScorers[i].score();
@@ -424,6 +436,7 @@
       return qWeight * customScore(subQueryScorer.docID(), subQueryScorer.score(), vScores);
     }
 
+    @Override
     public int advance(int target) throws IOException {
       int doc = subQueryScorer.advance(target);
       if (doc != NO_MORE_DOCS) {
@@ -433,29 +446,9 @@
       }
       return doc;
     }
-    
-    // TODO: remove in 3.0
-    /*(non-Javadoc) @see org.apache.lucene.search.Scorer#explain(int) */
-    public Explanation explain(int doc) throws IOException {
-      Explanation subQueryExpl = weight.subQueryWeight.explain(reader,doc);
-      if (!subQueryExpl.isMatch()) {
-        return subQueryExpl;
-      }
-      // match
-      Explanation[] valSrcExpls = new Explanation[valSrcScorers.length];
-      for(int i = 0; i < valSrcScorers.length; i++) {
-        valSrcExpls[i] = valSrcScorers[i].explain(doc);
-      }
-      Explanation customExp = customExplain(doc,subQueryExpl,valSrcExpls);
-      float sc = qWeight * customExp.getValue();
-      Explanation res = new ComplexExplanation(
-        true, sc, CustomScoreQuery.this.toString() + ", product of:");
-      res.addDetail(customExp);
-      res.addDetail(new Explanation(qWeight, "queryBoost")); // actually using the q boost as q weight (== weight value)
-      return res;
-    }
   }
 
+  @Override
   public Weight createWeight(Searcher searcher) throws IOException {
     return new CustomWeight(searcher);
   }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/function/ValueSourceQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/function/ValueSourceQuery.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/function/ValueSourceQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/function/ValueSourceQuery.java Tue Oct 27 22:29:41 2009
@@ -54,11 +54,13 @@
   }
 
   /*(non-Javadoc) @see org.apache.lucene.search.Query#rewrite(org.apache.lucene.index.IndexReader) */
+  @Override
   public Query rewrite(IndexReader reader) throws IOException {
     return this;
   }
 
   /*(non-Javadoc) @see org.apache.lucene.search.Query#extractTerms(java.util.Set) */
+  @Override
   public void extractTerms(Set<Term> terms) {
     // no terms involved here
   }
@@ -73,34 +75,49 @@
     }
 
     /*(non-Javadoc) @see org.apache.lucene.search.Weight#getQuery() */
+    @Override
     public Query getQuery() {
       return ValueSourceQuery.this;
     }
 
     /*(non-Javadoc) @see org.apache.lucene.search.Weight#getValue() */
+    @Override
     public float getValue() {
       return queryWeight;
     }
 
     /*(non-Javadoc) @see org.apache.lucene.search.Weight#sumOfSquaredWeights() */
+    @Override
     public float sumOfSquaredWeights() throws IOException {
       queryWeight = getBoost();
       return queryWeight * queryWeight;
     }
 
     /*(non-Javadoc) @see org.apache.lucene.search.Weight#normalize(float) */
+    @Override
     public void normalize(float norm) {
       this.queryNorm = norm;
       queryWeight *= this.queryNorm;
     }
 
+    @Override
     public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
       return new ValueSourceScorer(similarity, reader, this);
     }
 
     /*(non-Javadoc) @see org.apache.lucene.search.Weight#explain(org.apache.lucene.index.IndexReader, int) */
+    @Override
     public Explanation explain(IndexReader reader, int doc) throws IOException {
-      return new ValueSourceScorer(similarity, reader, this).explain(doc);
+      DocValues vals = valSrc.getValues(reader);
+      float sc = queryWeight * vals.floatVal(doc);
+
+      Explanation result = new ComplexExplanation(
+        true, sc, ValueSourceQuery.this.toString() + ", product of:");
+
+      result.addDetail(vals.explain(doc));
+      result.addDetail(new Explanation(getBoost(), "boost"));
+      result.addDetail(new Explanation(queryNorm,"queryNorm"));
+      return result;
     }
   }
 
@@ -127,46 +144,40 @@
       termDocs = reader.termDocs(null);
     }
 
+    @Override
     public int nextDoc() throws IOException {
       return doc = termDocs.next() ? termDocs.doc() : NO_MORE_DOCS;
     }
     
+    @Override
     public int docID() {
       return doc;
     }
     
+    @Override
     public int advance(int target) throws IOException {
       return doc = termDocs.skipTo(target) ? termDocs.doc() : NO_MORE_DOCS;
     }
     
     /*(non-Javadoc) @see org.apache.lucene.search.Scorer#score() */
+    @Override
     public float score() throws IOException {
       return qWeight * vals.floatVal(termDocs.doc());
     }
-
-    /*(non-Javadoc) @see org.apache.lucene.search.Scorer#explain(int) */
-    public Explanation explain(int doc) throws IOException {
-      float sc = qWeight * vals.floatVal(doc);
-
-      Explanation result = new ComplexExplanation(
-        true, sc, ValueSourceQuery.this.toString() + ", product of:");
-
-      result.addDetail(vals.explain(doc));
-      result.addDetail(new Explanation(getBoost(), "boost"));
-      result.addDetail(new Explanation(weight.queryNorm,"queryNorm"));
-      return result;
-    }
   }
 
+  @Override
   public Weight createWeight(Searcher searcher) {
     return new ValueSourceQuery.ValueSourceWeight(searcher);
   }
 
+  @Override
   public String toString(String field) {
     return valSrc.toString() + ToStringUtils.boost(getBoost());
   }
 
   /** Returns true if <code>o</code> is equal to this. */
+  @Override
   public boolean equals(Object o) {
     if (getClass() != o.getClass()) {
       return false;
@@ -177,6 +188,7 @@
   }
 
   /** Returns a hash code value for this object. */
+  @Override
   public int hashCode() {
     return (getClass().hashCode() + valSrc.hashCode()) ^ Float.floatToIntBits(getBoost());
   }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/payloads/PayloadNearQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/payloads/PayloadNearQuery.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/payloads/PayloadNearQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/payloads/PayloadNearQuery.java Tue Oct 27 22:29:41 2009
@@ -223,7 +223,7 @@
     }
 
     @Override
-    public Explanation explain(int doc) throws IOException {
+    protected Explanation explain(int doc) throws IOException {
       Explanation result = new Explanation();
       Explanation nonPayloadExpl = super.explain(doc);
       result.addDetail(nonPayloadExpl);

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/payloads/PayloadTermQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/payloads/PayloadTermQuery.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/payloads/PayloadTermQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/payloads/PayloadTermQuery.java Tue Oct 27 22:29:41 2009
@@ -60,6 +60,7 @@
     this.includeSpanScore = includeSpanScore;
   }
 
+  @Override
   public Weight createWeight(Searcher searcher) throws IOException {
     return new PayloadTermWeight(this, searcher);
   }
@@ -71,6 +72,7 @@
       super(query, searcher);
     }
 
+    @Override
     public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder,
         boolean topScorer) throws IOException {
       return new PayloadTermSpanScorer((TermSpans) query.getSpans(reader),
@@ -90,6 +92,7 @@
         positions = spans.getPositions();
       }
 
+      @Override
       protected boolean setFreqCurrentDoc() throws IOException {
         if (!more) {
           return false;
@@ -130,6 +133,7 @@
        * @return {@link #getSpanScore()} * {@link #getPayloadScore()}
        * @throws IOException
        */
+      @Override
       public float score() throws IOException {
 
         return includeSpanScore ? getSpanScore() * getPayloadScore()
@@ -160,7 +164,8 @@
         return function.docScore(doc, term.field(), payloadsSeen, payloadScore);
       }
 
-      public Explanation explain(final int doc) throws IOException {
+      @Override
+      protected Explanation explain(final int doc) throws IOException {
         ComplexExplanation result = new ComplexExplanation();
         Explanation nonPayloadExpl = super.explain(doc);
         result.addDetail(nonPayloadExpl);
@@ -184,6 +189,7 @@
     }
   }
 
+  @Override
   public int hashCode() {
     final int prime = 31;
     int result = super.hashCode();
@@ -192,6 +198,7 @@
     return result;
   }
 
+  @Override
   public boolean equals(Object obj) {
     if (this == obj)
       return true;

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanScorer.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanScorer.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanScorer.java Tue Oct 27 22:29:41 2009
@@ -53,6 +53,7 @@
     }
   }
 
+  @Override
   public int nextDoc() throws IOException {
     if (!setFreqCurrentDoc()) {
       doc = NO_MORE_DOCS;
@@ -60,6 +61,7 @@
     return doc;
   }
 
+  @Override
   public int advance(int target) throws IOException {
     if (!more) {
       return doc = NO_MORE_DOCS;
@@ -87,14 +89,18 @@
     return true;
   }
 
+  @Override
   public int docID() { return doc; }
 
+  @Override
   public float score() throws IOException {
     float raw = getSimilarity().tf(freq) * value; // raw score
     return norms == null? raw : raw * Similarity.decodeNorm(norms[doc]); // normalize
   }
 
-  public Explanation explain(final int doc) throws IOException {
+  /** This method is no longer an official member of {@link Scorer},
+   * but it is needed by SpanWeight to build an explanation. */
+  protected Explanation explain(final int doc) throws IOException {
     Explanation tfExplanation = new Explanation();
 
     int expDoc = advance(doc);

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanWeight.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanWeight.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanWeight.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/spans/SpanWeight.java Tue Oct 27 22:29:41 2009
@@ -52,25 +52,32 @@
     idf = idfExp.getIdf();
   }
 
+  @Override
   public Query getQuery() { return query; }
+
+  @Override
   public float getValue() { return value; }
 
+  @Override
   public float sumOfSquaredWeights() throws IOException {
     queryWeight = idf * query.getBoost();         // compute query weight
     return queryWeight * queryWeight;             // square it
   }
 
+  @Override
   public void normalize(float queryNorm) {
     this.queryNorm = queryNorm;
     queryWeight *= queryNorm;                     // normalize query weight
     value = queryWeight * idf;                    // idf for document
   }
 
+  @Override
   public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
     return new SpanScorer(query.getSpans(reader), this, similarity, reader
         .norms(query.getField()));
   }
 
+  @Override
   public Explanation explain(IndexReader reader, int doc)
     throws IOException {
 
@@ -104,7 +111,7 @@
     fieldExpl.setDescription("fieldWeight("+field+":"+query.toString(field)+
                              " in "+doc+"), product of:");
 
-    Explanation tfExpl = scorer(reader, true, false).explain(doc);
+    Explanation tfExpl = ((SpanScorer)scorer(reader, true, false)).explain(doc);
     fieldExpl.addDetail(tfExpl);
     fieldExpl.addDetail(idfExpl);
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/JustCompileSearch.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/JustCompileSearch.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/JustCompileSearch.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/JustCompileSearch.java Tue Oct 27 22:29:41 2009
@@ -308,10 +308,6 @@
       throw new UnsupportedOperationException(UNSUPPORTED_MSG);
     }
     
-    public Explanation explain(int doc) throws IOException {
-      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
-    }
-
     public float score() throws IOException {
       throw new UnsupportedOperationException(UNSUPPORTED_MSG);
     }

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanScorer.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanScorer.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanScorer.java Tue Oct 27 22:29:41 2009
@@ -80,15 +80,14 @@
     Similarity sim = Similarity.getDefault();
     Scorer[] scorers = new Scorer[] {new Scorer(sim) {
       private int doc = -1;
-      public Explanation explain(int doc) throws IOException { return null; }
-      public float score() throws IOException { return 0; }
-      public int docID() { return doc; }
+      @Override public float score() throws IOException { return 0; }
+      @Override public int docID() { return doc; }
       
-      public int nextDoc() throws IOException {
+      @Override public int nextDoc() throws IOException {
         return doc = doc == -1 ? 3000 : NO_MORE_DOCS;
       }
 
-      public int advance(int target) throws IOException {
+      @Override public int advance(int target) throws IOException {
         return doc = target <= 3000 ? 3000 : NO_MORE_DOCS;
       }
       

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java Tue Oct 27 22:29:41 2009
@@ -30,19 +30,17 @@
       super(null);
     }
     
-    public Explanation explain(int doc) throws IOException { return null; }
-
-    public float score() throws IOException {
+    @Override public float score() throws IOException {
       return idx == scores.length ? Float.NaN : scores[idx];
     }
 
-    public int docID() { return idx; }
+    @Override public int docID() { return idx; }
 
-    public int nextDoc() throws IOException {
+    @Override public int nextDoc() throws IOException {
       return ++idx != scores.length ? idx : NO_MORE_DOCS;
     }
     
-    public int advance(int target) throws IOException {
+    @Override public int advance(int target) throws IOException {
       idx = target;
       return idx < scores.length ? idx : NO_MORE_DOCS;
     }

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java Tue Oct 27 22:29:41 2009
@@ -32,9 +32,7 @@
       super(null);
     }
     
-    public Explanation explain(int doc) throws IOException { return null; }
-
-    public float score() throws IOException {
+    @Override public float score() throws IOException {
       // advance idx on purpose, so that consecutive calls to score will get
       // different results. This is to emulate computation of a score. If
       // ScoreCachingWrappingScorer is used, this should not be called more than
@@ -42,13 +40,13 @@
       return idx == scores.length ? Float.NaN : scores[idx++];
     }
 
-    public int docID() { return doc; }
+    @Override public int docID() { return doc; }
 
-    public int nextDoc() throws IOException {
+    @Override public int nextDoc() throws IOException {
       return ++doc < scores.length ? doc : NO_MORE_DOCS;
     }
     
-    public int advance(int target) throws IOException {
+    @Override public int advance(int target) throws IOException {
       doc = target;
       return doc < scores.length ? doc : NO_MORE_DOCS;
     }
@@ -65,7 +63,7 @@
       mscores = new float[numToCollect];
     }
     
-    public void collect(int doc) throws IOException {
+    @Override public void collect(int doc) throws IOException {
       // just a sanity check to avoid IOOB.
       if (idx == mscores.length) {
         return; 
@@ -78,15 +76,15 @@
       ++idx;
     }
 
-    public void setNextReader(IndexReader reader, int docBase)
+    @Override public void setNextReader(IndexReader reader, int docBase)
         throws IOException {
     }
 
-    public void setScorer(Scorer scorer) throws IOException {
+    @Override public void setScorer(Scorer scorer) throws IOException {
       this.scorer = new ScoreCachingWrappingScorer(scorer);
     }
     
-    public boolean acceptsDocsOutOfOrder() {
+    @Override public boolean acceptsDocsOutOfOrder() {
       return true;
     }
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestTermScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestTermScorer.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestTermScorer.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestTermScorer.java Tue Oct 27 22:29:41 2009
@@ -158,49 +158,6 @@
         assertTrue("doc should be number 5", ts.docID() == 5);
     }
 
-    public void testExplain() throws Exception
-    {
-        Term allTerm = new Term(FIELD, "all");
-        TermQuery termQuery = new TermQuery(allTerm);
-
-        Weight weight = termQuery.weight(indexSearcher);
-
-        TermScorer ts = new TermScorer(weight,
-                                       indexReader.termDocs(allTerm), indexSearcher.getSimilarity(),
-                                       indexReader.norms(FIELD));
-        Explanation explanation = ts.explain(0);
-        assertTrue("explanation is null and it shouldn't be", explanation != null);
-        //System.out.println("Explanation: " + explanation.toString());
-        //All this Explain does is return the term frequency
-        assertTrue("term frq is not 1", explanation.getValue() == 1);
-        explanation = ts.explain(1);
-        assertTrue("explanation is null and it shouldn't be", explanation != null);
-        //System.out.println("Explanation: " + explanation.toString());
-        //All this Explain does is return the term frequency
-        assertTrue("term frq is not 0", explanation.getValue() == 0);
-
-        Term dogsTerm = new Term(FIELD, "dogs");
-        termQuery = new TermQuery(dogsTerm);
-        weight = termQuery.weight(indexSearcher);
-
-        ts = new TermScorer(weight, indexReader.termDocs(dogsTerm), indexSearcher.getSimilarity(),
-                                       indexReader.norms(FIELD));
-        explanation = ts.explain(1);
-        assertTrue("explanation is null and it shouldn't be", explanation != null);
-        //System.out.println("Explanation: " + explanation.toString());
-        //All this Explain does is return the term frequency
-        float sqrtTwo = (float)Math.sqrt(2.0f);
-        assertTrue("term frq: " + explanation.getValue() + " is not the square root of 2", explanation.getValue() == sqrtTwo);
-
-        explanation = ts.explain(10);//try a doc out of range
-        assertTrue("explanation is null and it shouldn't be", explanation != null);
-        //System.out.println("Explanation: " + explanation.toString());
-        //All this Explain does is return the term frequency
-
-        assertTrue("term frq: " + explanation.getValue() + " is not 0", explanation.getValue() == 0);
-
-    }
-
     private class TestHit {
         public int doc;
         public float score;

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java?rev=830377&r1=830376&r2=830377&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java Tue Oct 27 22:29:41 2009
@@ -169,9 +169,7 @@
    */
   public void testSpanNearScorerExplain() throws Exception {
     SpanNearQuery q = makeQuery();
-    Weight w = q.weight(searcher);
-    Scorer s = w.scorer(searcher.getIndexReader(), true, false);
-    Explanation e = s.explain(1);
+    Explanation e = q.weight(searcher).explain(searcher.getIndexReader(), 1);
     assertTrue("Scorer explanation value for doc#1 isn't positive: "
                + e.toString(),
                0.0f < e.getValue());



Mime
View raw message