diff --git a/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java b/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java index d2ed377e8f2..7c2b6aa38ca 100644 --- a/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java +++ b/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java @@ -109,57 +109,6 @@ final class BooleanScorer extends BulkScorer { } - // 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 diff --git a/lucene/core/src/java/org/apache/lucene/search/FakeScorer.java b/lucene/core/src/java/org/apache/lucene/search/FakeScorer.java new file mode 100644 index 00000000000..8884a546b43 --- /dev/null +++ b/lucene/core/src/java/org/apache/lucene/search/FakeScorer.java @@ -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 getChildren() { + throw new UnsupportedOperationException(); + } +} diff --git a/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java b/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java index 715b0ace6be..8a9aec99a4e 100644 --- a/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java +++ b/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java @@ -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 diff --git a/lucene/core/src/test/org/apache/lucene/search/TestBooleanScorer.java b/lucene/core/src/test/org/apache/lucene/search/TestBooleanScorer.java index d34e85d1415..41e5f60b3ab 100644 --- a/lucene/core/src/test/org/apache/lucene/search/TestBooleanScorer.java +++ b/lucene/core/src/test/org/apache/lucene/search/TestBooleanScorer.java @@ -87,37 +87,10 @@ public class TestBooleanScorer extends LuceneTestCase { 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 LuceneTestCase { 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 LuceneTestCase { 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 { diff --git a/lucene/core/src/test/org/apache/lucene/search/TestConstantScoreQuery.java b/lucene/core/src/test/org/apache/lucene/search/TestConstantScoreQuery.java index 9fc2f8694ea..21a6a7d4269 100644 --- a/lucene/core/src/test/org/apache/lucene/search/TestConstantScoreQuery.java +++ b/lucene/core/src/test/org/apache/lucene/search/TestConstantScoreQuery.java @@ -121,7 +121,7 @@ public class TestConstantScoreQuery extends LuceneTestCase { 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 { diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacetSumValueSource.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacetSumValueSource.java index 8eb9542bfb9..1342c187866 100644 --- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacetSumValueSource.java +++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacetSumValueSource.java @@ -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 extends FloatTaxonomyFacets { public Weight getWeight() { throw new UnsupportedOperationException(); } + + @Override + public Collection getChildren() { + throw new UnsupportedOperationException(); + } } private final void sumValues(List matchingDocs, boolean keepScores, ValueSource valueSource) throws IOException { diff --git a/lucene/grouping/src/java/org/apache/lucene/search/grouping/BlockGroupingCollector.java b/lucene/grouping/src/java/org/apache/lucene/search/grouping/BlockGroupingCollector.java index 012fd8a3ee7..195ec230ed7 100644 --- a/lucene/grouping/src/java/org/apache/lucene/search/grouping/BlockGroupingCollector.java +++ b/lucene/grouping/src/java/org/apache/lucene/search/grouping/BlockGroupingCollector.java @@ -18,14 +18,15 @@ package org.apache.lucene.search.grouping; */ +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 extends Collector { public Weight getWeight() { throw new UnsupportedOperationException(); } + + @Override + public Collection getChildren() { + throw new UnsupportedOperationException(); + } } private static final class OneGroup { diff --git a/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java b/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java index 6cbdac006c7..739ef35ed13 100644 --- a/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java +++ b/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java @@ -205,50 +205,6 @@ class TermsIncludingScoreQuery extends Query { }; } - 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 { diff --git a/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java b/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java index 3fbf95a1d07..9dbb2a9e83c 100644 --- a/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java +++ b/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java @@ -325,51 +325,6 @@ public class ToParentBlockJoinCollector extends Collector { } } - 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() { diff --git a/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java b/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java index e2c5ba8e5cb..71f4e4538d2 100644 --- a/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java +++ b/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java @@ -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.endresulttransformer.MainEndResultTransfo 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 SearchComponent public long cost() { return 1; } + + @Override + public Weight getWeight() { + throw new UnsupportedOperationException(); + } + + @Override + public Collection getChildren() { + throw new UnsupportedOperationException(); + } } }