From d6724ddb84e33a1d40b7be7be8776a40e7d71556 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Tue, 12 Jul 2011 10:11:07 +0000 Subject: [PATCH] make ScoreDocQueue final git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1145521 13f79535-47bb-0310-9956-ffa450edef68 --- .../lucene/search/DisjunctionSumScorer.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lucene/src/java/org/apache/lucene/search/DisjunctionSumScorer.java b/lucene/src/java/org/apache/lucene/search/DisjunctionSumScorer.java index 2f7fa5daf33..20db4da2b31 100644 --- a/lucene/src/java/org/apache/lucene/search/DisjunctionSumScorer.java +++ b/lucene/src/java/org/apache/lucene/search/DisjunctionSumScorer.java @@ -47,7 +47,7 @@ class DisjunctionSumScorer extends Scorer { * nrMatchers is the number of matching scorers, * and all scorers are after the matching doc, or are exhausted. */ - private ScorerDocQueue scorerDocQueue; + private final ScorerDocQueue scorerDocQueue; /** The document number of the current match. */ private int currentDoc = -1; @@ -83,7 +83,7 @@ class DisjunctionSumScorer extends Scorer { this.minimumNrMatchers = minimumNrMatchers; this.subScorers = subScorers; - initScorerDocQueue(); + scorerDocQueue = initScorerDocQueue(); } /** Construct a DisjunctionScorer, using one as the minimum number @@ -95,14 +95,16 @@ class DisjunctionSumScorer extends Scorer { /** Called the first time nextDoc() or advance() is called to * initialize scorerDocQueue. + * @return */ - private void initScorerDocQueue() throws IOException { - scorerDocQueue = new ScorerDocQueue(nrScorers); - for (Scorer se : subScorers) { + private ScorerDocQueue initScorerDocQueue() throws IOException { + final ScorerDocQueue docQueue = new ScorerDocQueue(nrScorers); + for (final Scorer se : subScorers) { if (se.nextDoc() != NO_MORE_DOCS) { - scorerDocQueue.insert(se); + docQueue.insert(se); } } + return docQueue; } /** Scores and collects all matching documents. @@ -138,6 +140,7 @@ class DisjunctionSumScorer extends Scorer { @Override public int nextDoc() throws IOException { + if (scorerDocQueue.size() < minimumNrMatchers || !advanceAfterCurrent()) { currentDoc = NO_MORE_DOCS; }