From d1ddcfa7c1bf290405fcb2416308bf5396a2dbc4 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Mon, 10 Mar 2014 21:41:44 +0000 Subject: [PATCH] LUCENE-5487: throw OUE from FakeScorer.getWeight git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene5487@1576096 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/java/org/apache/lucene/search/BooleanScorer.java | 5 +++++ .../src/java/org/apache/lucene/search/IndexSearcher.java | 5 +++++ .../test/org/apache/lucene/search/TestBooleanScorer.java | 5 +++++ .../java/org/apache/lucene/facet/DrillSidewaysScorer.java | 5 +++++ .../facet/taxonomy/TaxonomyFacetSumValueSource.java | 8 +++++++- .../lucene/search/grouping/BlockGroupingCollector.java | 7 ++++++- .../lucene/search/join/TermsIncludingScoreQuery.java | 5 +++++ .../lucene/search/join/ToParentBlockJoinCollector.java | 7 ++++++- 8 files changed, 44 insertions(+), 3 deletions(-) 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 0c85caa7a93..d2ed377e8f2 100644 --- a/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java +++ b/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java @@ -153,6 +153,11 @@ final class BooleanScorer extends BulkScorer { public long cost() { throw new UnsupportedOperationException(); } + + @Override + public Weight getWeight() { + throw new UnsupportedOperationException(); + } } static final class Bucket { 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 ccfff976987..715b0ace6be 100644 --- a/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java +++ b/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java @@ -805,6 +805,11 @@ public class IndexSearcher { public long cost() { return 1; } + + @Override + public Weight getWeight() { + throw new UnsupportedOperationException(); + } } private final FakeScorer fakeScorer = new FakeScorer(); 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 f476b45f5b7..d34e85d1415 100644 --- a/lucene/core/src/test/org/apache/lucene/search/TestBooleanScorer.java +++ b/lucene/core/src/test/org/apache/lucene/search/TestBooleanScorer.java @@ -240,6 +240,11 @@ public class TestBooleanScorer extends LuceneTestCase { public long cost() { throw new UnsupportedOperationException(); } + + @Override + public Weight getWeight() { + throw new UnsupportedOperationException(); + } } /** Throws UOE if Weight.scorer is called */ diff --git a/lucene/facet/src/java/org/apache/lucene/facet/DrillSidewaysScorer.java b/lucene/facet/src/java/org/apache/lucene/facet/DrillSidewaysScorer.java index 854a85ffd0c..8764f7e4a98 100644 --- a/lucene/facet/src/java/org/apache/lucene/facet/DrillSidewaysScorer.java +++ b/lucene/facet/src/java/org/apache/lucene/facet/DrillSidewaysScorer.java @@ -661,6 +661,11 @@ class DrillSidewaysScorer extends BulkScorer { public Collection getChildren() { return Collections.singletonList(new ChildScorer(baseScorer, "MUST")); } + + @Override + public Weight getWeight() { + throw new UnsupportedOperationException(); + } } static class DocsAndCost implements Comparable { 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 bb04db1d5ec..8eb9542bfb9 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 @@ -22,8 +22,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.lucene.facet.FacetsCollector; import org.apache.lucene.facet.FacetsCollector.MatchingDocs; +import org.apache.lucene.facet.FacetsCollector; import org.apache.lucene.facet.FacetsConfig; import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.queries.function.FunctionValues; @@ -31,6 +31,7 @@ import org.apache.lucene.queries.function.ValueSource; import org.apache.lucene.queries.function.docvalues.DoubleDocValues; import org.apache.lucene.search.DocIdSetIterator; import org.apache.lucene.search.Scorer; +import org.apache.lucene.search.Weight; import org.apache.lucene.util.IntsRef; /** Aggregates sum of values from {@link @@ -70,6 +71,11 @@ public class TaxonomyFacetSumValueSource extends FloatTaxonomyFacets { @Override public int nextDoc() throws IOException { throw new UnsupportedOperationException(); } @Override public int advance(int target) throws IOException { throw new UnsupportedOperationException(); } @Override public long cost() { return 0; } + + @Override + public Weight getWeight() { + 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 a39678d07f2..012fd8a3ee7 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 @@ -90,7 +90,7 @@ public class BlockGroupingCollector extends Collector { int doc; public FakeScorer() { - super((Weight) null); + super(null); } @Override @@ -122,6 +122,11 @@ public class BlockGroupingCollector extends Collector { public long cost() { return 1; } + + @Override + public Weight getWeight() { + 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 ab7655155d2..6cbdac006c7 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 @@ -242,6 +242,11 @@ class TermsIncludingScoreQuery extends Query { 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. 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 5e68f5ea9bd..3fbf95a1d07 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 @@ -331,7 +331,7 @@ public class ToParentBlockJoinCollector extends Collector { int doc; public FakeScorer() { - super((Weight) null); + super(null); } @Override @@ -363,6 +363,11 @@ public class ToParentBlockJoinCollector extends Collector { public long cost() { return 1; } + + @Override + public Weight getWeight() { + throw new UnsupportedOperationException(); + } } private OneGroup[] sortedGroups;