lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1576273 - in /lucene/dev/branches/lucene5487: lucene/core/src/java/org/apache/lucene/search/ lucene/core/src/test/org/apache/lucene/search/ lucene/facet/src/java/org/apache/lucene/facet/taxonomy/ lucene/grouping/src/java/org/apache/lucene/...
Date Tue, 11 Mar 2014 10:47:44 GMT
Author: mikemccand
Date: Tue Mar 11 10:47:43 2014
New Revision: 1576273

URL: http://svn.apache.org/r1576273
Log:
LUCENE-5487: consolidate the FakeScorers within one package

Added:
    lucene/dev/branches/lucene5487/lucene/core/src/java/org/apache/lucene/search/FakeScorer.java
  (with props)
Modified:
    lucene/dev/branches/lucene5487/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java
    lucene/dev/branches/lucene5487/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java
    lucene/dev/branches/lucene5487/lucene/core/src/test/org/apache/lucene/search/TestBooleanScorer.java
    lucene/dev/branches/lucene5487/lucene/core/src/test/org/apache/lucene/search/TestConstantScoreQuery.java
    lucene/dev/branches/lucene5487/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacetSumValueSource.java
    lucene/dev/branches/lucene5487/lucene/grouping/src/java/org/apache/lucene/search/grouping/BlockGroupingCollector.java
    lucene/dev/branches/lucene5487/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java
    lucene/dev/branches/lucene5487/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java
    lucene/dev/branches/lucene5487/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java

Modified: lucene/dev/branches/lucene5487/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5487/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java?rev=1576273&r1=1576272&r2=1576273&view=diff
==============================================================================
--- lucene/dev/branches/lucene5487/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java
(original)
+++ lucene/dev/branches/lucene5487/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java
Tue Mar 11 10:47:43 2014
@@ -109,57 +109,6 @@ final class BooleanScorer extends BulkSc
 
   }
   
-  // An internal class which is used in score(Collector, int) for setting the
-  // current score. This is required since Collector exposes a setScorer method
-  // and implementations that need the score will call scorer.score().
-  // Therefore the only methods that are implemented are
-  // score(), doc() and freq().
-  private static final class FakeScorer extends Scorer {
-
-    float score;
-    int doc = -1;
-    int freq;
-    
-    public FakeScorer() {
-      super(null);
-    }
-    
-    @Override
-    public int advance(int target) {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public int docID() {
-      return doc;
-    }
-
-    @Override
-    public int freq() {
-      return freq;
-    }
-
-    @Override
-    public int nextDoc() {
-      throw new UnsupportedOperationException();
-    }
-    
-    @Override
-    public float score() {
-      return score;
-    }
-    
-    @Override
-    public long cost() {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public Weight getWeight() {
-      throw new UnsupportedOperationException();
-    }
-  }
-
   static final class Bucket {
     int doc = -1;            // tells if bucket is valid
     double score;             // incremental score

Added: lucene/dev/branches/lucene5487/lucene/core/src/java/org/apache/lucene/search/FakeScorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5487/lucene/core/src/java/org/apache/lucene/search/FakeScorer.java?rev=1576273&view=auto
==============================================================================
--- lucene/dev/branches/lucene5487/lucene/core/src/java/org/apache/lucene/search/FakeScorer.java
(added)
+++ lucene/dev/branches/lucene5487/lucene/core/src/java/org/apache/lucene/search/FakeScorer.java
Tue Mar 11 10:47:43 2014
@@ -0,0 +1,72 @@
+package org.apache.lucene.search;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Collection;
+
+/** Used by {@link BulkScorers} that need to pass a {@link
+ *  Scorer} to {@link Collector#setScorer}. */
+final class FakeScorer extends Scorer {
+  float score;
+  int doc = -1;
+  int freq = 1;
+
+  public FakeScorer() {
+    super(null);
+  }
+    
+  @Override
+  public int advance(int target) {
+    throw new UnsupportedOperationException("FakeScorer doesn't support advance(int)");
+  }
+
+  @Override
+  public int docID() {
+    return doc;
+  }
+
+  @Override
+  public int freq() {
+    return freq;
+  }
+
+  @Override
+  public int nextDoc() {
+    throw new UnsupportedOperationException("FakeScorer doesn't support nextDoc()");
+  }
+    
+  @Override
+  public float score() {
+    return score;
+  }
+
+  @Override
+  public long cost() {
+    return 1;
+  }
+
+  @Override
+  public Weight getWeight() {
+    throw new UnsupportedOperationException();
+  }
+
+  @Override
+  public Collection<ChildScorer> getChildren() {
+    throw new UnsupportedOperationException();
+  }
+}

Modified: lucene/dev/branches/lucene5487/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5487/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java?rev=1576273&r1=1576272&r2=1576273&view=diff
==============================================================================
--- lucene/dev/branches/lucene5487/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java
(original)
+++ lucene/dev/branches/lucene5487/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java
Tue Mar 11 10:47:43 2014
@@ -768,50 +768,6 @@ public class IndexSearcher {
       this.doMaxScore = doMaxScore;
     }
 
-    private final class FakeScorer extends Scorer {
-      float score;
-      int doc;
-
-      public FakeScorer() {
-        super(null);
-      }
-    
-      @Override
-      public int advance(int target) {
-        throw new UnsupportedOperationException("FakeScorer doesn't support advance(int)");
-      }
-
-      @Override
-      public int docID() {
-        return doc;
-      }
-
-      @Override
-      public int freq() {
-        throw new UnsupportedOperationException("FakeScorer doesn't support freq()");
-      }
-
-      @Override
-      public int nextDoc() {
-        throw new UnsupportedOperationException("FakeScorer doesn't support nextDoc()");
-      }
-    
-      @Override
-      public float score() {
-        return score;
-      }
-
-      @Override
-      public long cost() {
-        return 1;
-      }
-
-      @Override
-      public Weight getWeight() {
-        throw new UnsupportedOperationException();
-      }
-    }
-
     private final FakeScorer fakeScorer = new FakeScorer();
 
     @Override

Modified: lucene/dev/branches/lucene5487/lucene/core/src/test/org/apache/lucene/search/TestBooleanScorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5487/lucene/core/src/test/org/apache/lucene/search/TestBooleanScorer.java?rev=1576273&r1=1576272&r2=1576273&view=diff
==============================================================================
--- lucene/dev/branches/lucene5487/lucene/core/src/test/org/apache/lucene/search/TestBooleanScorer.java
(original)
+++ lucene/dev/branches/lucene5487/lucene/core/src/test/org/apache/lucene/search/TestBooleanScorer.java
Tue Mar 11 10:47:43 2014
@@ -87,37 +87,10 @@ public class TestBooleanScorer extends L
       public boolean score(Collector c, int maxDoc) throws IOException {
         assert doc == -1;
         doc = 3000;
-        c.setScorer(new Scorer(null) {
-            @Override
-            public int advance(int target) {
-              throw new UnsupportedOperationException("FakeScorer doesn't support advance(int)");
-            }
-
-            @Override
-            public int docID() {
-              return doc;
-            }
-
-            @Override
-            public int freq() {
-              throw new UnsupportedOperationException("FakeScorer doesn't support freq()");
-            }
-
-            @Override
-            public int nextDoc() {
-              throw new UnsupportedOperationException("FakeScorer doesn't support nextDoc()");
-            }
-    
-            @Override
-            public float score() {
-              return 1.0f;
-            }
-
-            @Override
-            public long cost() {
-              return 1;
-            }
-          });
+        FakeScorer fs = new FakeScorer();
+        fs.doc = doc;
+        fs.score = 1.0f;
+        c.setScorer(fs);
         c.collect(3000);
         return false;
       }
@@ -182,7 +155,7 @@ public class TestBooleanScorer extends L
       public void setScorer(Scorer scorer) {
         // Make sure we got BooleanScorer:
         final Class<?> clazz = scorer instanceof AssertingScorer ? ((AssertingScorer)
scorer).getIn().getClass() : scorer.getClass();
-        assertEquals("Scorer is implemented by wrong class", BooleanScorer.class.getName()
+ "$FakeScorer", clazz.getName());
+        assertEquals("Scorer is implemented by wrong class", FakeScorer.class.getName(),
clazz.getName());
       }
       
       @Override
@@ -206,47 +179,6 @@ public class TestBooleanScorer extends L
     d.close();
   }
 
-  private static final class FakeScorer extends Scorer {
-    public FakeScorer() {
-      super(null);
-    }
-    
-    @Override
-    public int advance(int target) {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public int docID() {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public int freq() {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public int nextDoc() {
-      throw new UnsupportedOperationException();
-    }
-    
-    @Override
-    public float score() {
-      return 1.0f;
-    }
-
-    @Override
-    public long cost() {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public Weight getWeight() {
-      throw new UnsupportedOperationException();
-    }
-  }
-
   /** Throws UOE if Weight.scorer is called */
   private static class CrazyMustUseBulkScorerQuery extends Query {
 

Modified: lucene/dev/branches/lucene5487/lucene/core/src/test/org/apache/lucene/search/TestConstantScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5487/lucene/core/src/test/org/apache/lucene/search/TestConstantScoreQuery.java?rev=1576273&r1=1576272&r2=1576273&view=diff
==============================================================================
--- lucene/dev/branches/lucene5487/lucene/core/src/test/org/apache/lucene/search/TestConstantScoreQuery.java
(original)
+++ lucene/dev/branches/lucene5487/lucene/core/src/test/org/apache/lucene/search/TestConstantScoreQuery.java
Tue Mar 11 10:47:43 2014
@@ -121,7 +121,7 @@ public class TestConstantScoreQuery exte
       checkHits(searcher, csq2, csq2.getBoost(), ConstantScoreQuery.ConstantScorer.class.getName(),
ConstantScoreQuery.ConstantScorer.class.getName());
       
       // for the combined BQ, the scorer should always be BooleanScorer's BucketScorer, because
our scorer supports out-of order collection!
-      final String bucketScorerClass = BooleanScorer.class.getName() + "$FakeScorer";
+      final String bucketScorerClass = FakeScorer.class.getName();
       checkHits(searcher, bq, csq1.getBoost() + csq2.getBoost(), bucketScorerClass, null);
       checkHits(searcher, csqbq, csqbq.getBoost(), ConstantScoreQuery.ConstantScorer.class.getName(),
bucketScorerClass);
     } finally {

Modified: lucene/dev/branches/lucene5487/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacetSumValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5487/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacetSumValueSource.java?rev=1576273&r1=1576272&r2=1576273&view=diff
==============================================================================
--- lucene/dev/branches/lucene5487/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacetSumValueSource.java
(original)
+++ lucene/dev/branches/lucene5487/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacetSumValueSource.java
Tue Mar 11 10:47:43 2014
@@ -18,6 +18,7 @@ package org.apache.lucene.facet.taxonomy
  */
 
 import java.io.IOException;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -76,6 +77,11 @@ public class TaxonomyFacetSumValueSource
     public Weight getWeight() {
       throw new UnsupportedOperationException();
     }
+
+    @Override
+    public Collection<ChildScorer> getChildren() {
+      throw new UnsupportedOperationException();
+    }
   }
 
   private final void sumValues(List<MatchingDocs> matchingDocs, boolean keepScores,
ValueSource valueSource) throws IOException {

Modified: lucene/dev/branches/lucene5487/lucene/grouping/src/java/org/apache/lucene/search/grouping/BlockGroupingCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5487/lucene/grouping/src/java/org/apache/lucene/search/grouping/BlockGroupingCollector.java?rev=1576273&r1=1576272&r2=1576273&view=diff
==============================================================================
--- lucene/dev/branches/lucene5487/lucene/grouping/src/java/org/apache/lucene/search/grouping/BlockGroupingCollector.java
(original)
+++ lucene/dev/branches/lucene5487/lucene/grouping/src/java/org/apache/lucene/search/grouping/BlockGroupingCollector.java
Tue Mar 11 10:47:43 2014
@@ -18,14 +18,15 @@ package org.apache.lucene.search.groupin
  */
 
 
+import java.io.IOException;
+import java.util.Collection;
+
 import org.apache.lucene.index.AtomicReaderContext;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.search.*;
 import org.apache.lucene.util.ArrayUtil;
 import org.apache.lucene.util.PriorityQueue;
 
-import java.io.IOException;
-
 // TODO: this sentence is too long for the class summary.
 /** BlockGroupingCollector performs grouping with a
  *  single pass collector, as long as you are grouping by a
@@ -127,6 +128,11 @@ public class BlockGroupingCollector exte
     public Weight getWeight() {
       throw new UnsupportedOperationException();
     }
+
+    @Override
+    public Collection<ChildScorer> getChildren() {
+      throw new UnsupportedOperationException();
+    }
   }
 
   private static final class OneGroup {

Modified: lucene/dev/branches/lucene5487/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5487/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java?rev=1576273&r1=1576272&r2=1576273&view=diff
==============================================================================
--- lucene/dev/branches/lucene5487/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java
(original)
+++ lucene/dev/branches/lucene5487/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java
Tue Mar 11 10:47:43 2014
@@ -205,50 +205,6 @@ class TermsIncludingScoreQuery extends Q
     };
   }
 
-  final static class FakeScorer extends Scorer {
-    float score;
-    int doc;
-
-    public FakeScorer() {
-      super(null);
-    }
-    
-    @Override
-    public int advance(int target) {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public int docID() {
-      return doc;
-    }
-
-    @Override
-    public int freq() {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public int nextDoc() {
-      throw new UnsupportedOperationException();
-    }
-    
-    @Override
-    public float score() {
-      return score;
-    }
-
-    @Override
-    public long cost() {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public Weight getWeight() {
-      throw new UnsupportedOperationException();
-    }
-  }
-
   // This impl assumes that the 'join' values are used uniquely per doc per field. Used for
one to many relations.
   class SVInnerScorer extends BulkScorer {
 

Modified: lucene/dev/branches/lucene5487/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5487/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java?rev=1576273&r1=1576272&r2=1576273&view=diff
==============================================================================
--- lucene/dev/branches/lucene5487/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java
(original)
+++ lucene/dev/branches/lucene5487/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java
Tue Mar 11 10:47:43 2014
@@ -325,51 +325,6 @@ public class ToParentBlockJoinCollector 
     }
   }
 
-  private final static class FakeScorer extends Scorer {
-
-    float score;
-    int doc;
-
-    public FakeScorer() {
-      super(null);
-    }
-
-    @Override
-    public float score() {
-      return score;
-    }
-    
-    @Override
-    public int freq() {
-      return 1; // TODO: does anything else make sense?... duplicate of grouping's FakeScorer
btw?
-    }
-
-    @Override
-    public int docID() {
-      return doc;
-    }
-
-    @Override
-    public int advance(int target) {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public int nextDoc() {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public long cost() {
-      return 1;
-    }
-
-    @Override
-    public Weight getWeight() {
-      throw new UnsupportedOperationException();
-    }
-  }
-
   private OneGroup[] sortedGroups;
 
   private void sortQueue() {

Modified: lucene/dev/branches/lucene5487/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5487/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java?rev=1576273&r1=1576272&r2=1576273&view=diff
==============================================================================
--- lucene/dev/branches/lucene5487/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
(original)
+++ lucene/dev/branches/lucene5487/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
Tue Mar 11 10:47:43 2014
@@ -17,6 +17,21 @@
 
 package org.apache.solr.handler.component;
 
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.commons.lang.StringUtils;
 import org.apache.lucene.index.AtomicReaderContext;
 import org.apache.lucene.index.IndexReaderContext;
 import org.apache.lucene.index.ReaderUtil;
@@ -28,6 +43,7 @@ import org.apache.lucene.search.ScoreDoc
 import org.apache.lucene.search.Scorer;
 import org.apache.lucene.search.Sort;
 import org.apache.lucene.search.SortField;
+import org.apache.lucene.search.Weight;
 import org.apache.lucene.search.grouping.GroupDocs;
 import org.apache.lucene.search.grouping.SearchGroup;
 import org.apache.lucene.search.grouping.TopGroups;
@@ -83,22 +99,6 @@ import org.apache.solr.search.grouping.e
 import org.apache.solr.search.grouping.endresulttransformer.SimpleEndResultTransformer;
 import org.apache.solr.util.SolrPluginUtils;
 
-import org.apache.commons.lang.StringUtils;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
 /**
  * TODO!
  * 
@@ -1227,5 +1227,15 @@ public class QueryComponent extends Sear
     public long cost() {
       return 1;
     }
+
+    @Override
+    public Weight getWeight() {
+      throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Collection<ChildScorer> getChildren() {
+      throw new UnsupportedOperationException();
+    }
   }
 }



Mime
View raw message