Return-Path: X-Original-To: apmail-lucene-commits-archive@www.apache.org Delivered-To: apmail-lucene-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4A5D892DE for ; Fri, 20 Jul 2012 01:02:51 +0000 (UTC) Received: (qmail 28877 invoked by uid 500); 20 Jul 2012 01:02:51 -0000 Mailing-List: contact commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list commits@lucene.apache.org Received: (qmail 28783 invoked by uid 99); 20 Jul 2012 01:02:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Jul 2012 01:02:51 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Jul 2012 01:02:32 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 8B67223889DA; Fri, 20 Jul 2012 01:02:10 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1363608 [4/10] - in /lucene/dev/branches/LUCENE-2878: ./ dev-tools/ dev-tools/eclipse/ dev-tools/idea/.idea/copyright/ dev-tools/idea/.idea/libraries/ dev-tools/idea/lucene/ dev-tools/maven/ dev-tools/maven/lucene/benchmark/ dev-tools/mave... Date: Fri, 20 Jul 2012 01:01:52 -0000 To: commits@lucene.apache.org From: simonw@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120720010210.8B67223889DA@eris.apache.org> Modified: lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecContentSource.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecContentSource.java?rev=1363608&r1=1363607&r2=1363608&view=diff ============================================================================== --- lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecContentSource.java (original) +++ lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecContentSource.java Fri Jul 20 01:01:39 2012 @@ -22,7 +22,6 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.Reader; import java.text.DateFormat; import java.text.ParsePosition; import java.text.SimpleDateFormat; @@ -33,8 +32,6 @@ import java.util.Locale; import org.apache.lucene.benchmark.byTask.feeds.TrecDocParser.ParsePathType; import org.apache.lucene.benchmark.byTask.utils.Config; import org.apache.lucene.benchmark.byTask.utils.StreamUtils; -import org.apache.lucene.benchmark.byTask.utils.StringBuilderReader; -import org.apache.lucene.util.ThreadInterruptedException; /** * Implements a {@link ContentSource} over the TREC collection. @@ -57,7 +54,7 @@ import org.apache.lucene.util.ThreadInte */ public class TrecContentSource extends ContentSource { - private static final class DateFormatInfo { + static final class DateFormatInfo { DateFormat[] dfs; ParsePosition pos; } @@ -83,13 +80,10 @@ public class TrecContentSource extends C }; private ThreadLocal dateFormats = new ThreadLocal(); - private ThreadLocal trecDocReader = new ThreadLocal(); private ThreadLocal trecDocBuffer = new ThreadLocal(); private File dataDir = null; private ArrayList inputFiles = new ArrayList(); private int nextFile = 0; - private int rawDocSize = 0; - // Use to synchronize threads on reading from the TREC documents. private Object lock = new Object(); @@ -126,17 +120,6 @@ public class TrecContentSource extends C return sb; } - Reader getTrecDocReader(StringBuilder docBuffer) { - StringBuilderReader r = trecDocReader.get(); - if (r == null) { - r = new StringBuilderReader(docBuffer); - trecDocReader.set(r); - } else { - r.set(docBuffer); - } - return r; - } - HTMLParser getHtmlParser() { return htmlParser; } @@ -161,7 +144,7 @@ public class TrecContentSource extends C continue; } - rawDocSize += line.length(); + line.length(); if (lineStart!=null && line.startsWith(lineStart)) { if (collectMatchLine) { @@ -287,12 +270,8 @@ public class TrecContentSource extends C // This code segment relies on HtmlParser being thread safe. When we get // here, everything else is already private to that thread, so we're safe. - try { - docData = trecDocParser.parse(docData, name, this, docBuf, parsedPathType); - addItem(); - } catch (InterruptedException ie) { - throw new ThreadInterruptedException(ie); - } + docData = trecDocParser.parse(docData, name, this, docBuf, parsedPathType); + addItem(); return docData; } Modified: lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecDocParser.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecDocParser.java?rev=1363608&r1=1363607&r2=1363608&view=diff ============================================================================== --- lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecDocParser.java (original) +++ lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecDocParser.java Fri Jul 20 01:01:39 2012 @@ -80,7 +80,7 @@ public abstract class TrecDocParser { * parsers to alter their behavior according to the file path type. */ public abstract DocData parse(DocData docData, String name, TrecContentSource trecSrc, - StringBuilder docBuf, ParsePathType pathType) throws IOException, InterruptedException; + StringBuilder docBuf, ParsePathType pathType) throws IOException; /** * strip tags from buf: each tag is replaced by a single blank. Modified: lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecFBISParser.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecFBISParser.java?rev=1363608&r1=1363607&r2=1363608&view=diff ============================================================================== --- lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecFBISParser.java (original) +++ lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecFBISParser.java Fri Jul 20 01:01:39 2012 @@ -37,7 +37,7 @@ public class TrecFBISParser extends Trec @Override public DocData parse(DocData docData, String name, TrecContentSource trecSrc, - StringBuilder docBuf, ParsePathType pathType) throws IOException, InterruptedException { + StringBuilder docBuf, ParsePathType pathType) throws IOException { int mark = 0; // that much is skipped // optionally skip some of the text, set date, title Date date = null; Modified: lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecFR94Parser.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecFR94Parser.java?rev=1363608&r1=1363607&r2=1363608&view=diff ============================================================================== --- lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecFR94Parser.java (original) +++ lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecFR94Parser.java Fri Jul 20 01:01:39 2012 @@ -41,7 +41,7 @@ public class TrecFR94Parser extends Trec @Override public DocData parse(DocData docData, String name, TrecContentSource trecSrc, - StringBuilder docBuf, ParsePathType pathType) throws IOException, InterruptedException { + StringBuilder docBuf, ParsePathType pathType) throws IOException { int mark = 0; // that much is skipped // optionally skip some of the text, set date (no title?) Date date = null; Modified: lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecFTParser.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecFTParser.java?rev=1363608&r1=1363607&r2=1363608&view=diff ============================================================================== --- lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecFTParser.java (original) +++ lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecFTParser.java Fri Jul 20 01:01:39 2012 @@ -33,7 +33,7 @@ public class TrecFTParser extends TrecDo @Override public DocData parse(DocData docData, String name, TrecContentSource trecSrc, - StringBuilder docBuf, ParsePathType pathType) throws IOException, InterruptedException { + StringBuilder docBuf, ParsePathType pathType) throws IOException { int mark = 0; // that much is skipped // date... Modified: lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecGov2Parser.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecGov2Parser.java?rev=1363608&r1=1363607&r2=1363608&view=diff ============================================================================== --- lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecGov2Parser.java (original) +++ lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecGov2Parser.java Fri Jul 20 01:01:39 2012 @@ -18,7 +18,7 @@ package org.apache.lucene.benchmark.byTa */ import java.io.IOException; -import java.io.Reader; +import java.io.StringReader; import java.util.Date; /** @@ -31,29 +31,24 @@ public class TrecGov2Parser extends Trec private static final String DOCHDR = ""; private static final String TERMINATING_DOCHDR = ""; - private static final int TERMINATING_DOCHDR_LENGTH = TERMINATING_DOCHDR.length(); @Override public DocData parse(DocData docData, String name, TrecContentSource trecSrc, - StringBuilder docBuf, ParsePathType pathType) throws IOException, InterruptedException { - // Set up a (per-thread) reused Reader over the read content, reset it to re-read from docBuf - Reader r = trecSrc.getTrecDocReader(docBuf); - - // skip some of the text, optionally set date + StringBuilder docBuf, ParsePathType pathType) throws IOException { + // skip some of the non-html text, optionally set date Date date = null; - int h1 = docBuf.indexOf(DOCHDR); - if (h1>=0) { - int h2 = docBuf.indexOf(TERMINATING_DOCHDR,h1); - String dateStr = extract(docBuf, DATE, DATE_END, h2, null); + int start = 0; + final int h1 = docBuf.indexOf(DOCHDR); + if (h1 >= 0) { + final int h2 = docBuf.indexOf(TERMINATING_DOCHDR, h1); + final String dateStr = extract(docBuf, DATE, DATE_END, h2, null); if (dateStr != null) { date = trecSrc.parseDate(dateStr); } - r.mark(h2+TERMINATING_DOCHDR_LENGTH); + start = h2 + TERMINATING_DOCHDR.length(); } - - r.reset(); - HTMLParser htmlParser = trecSrc.getHtmlParser(); - return htmlParser.parse(docData, name, date, null, r, null); + final String html = docBuf.substring(start); + return trecSrc.getHtmlParser().parse(docData, name, date, new StringReader(html), trecSrc); } } Modified: lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecLATimesParser.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecLATimesParser.java?rev=1363608&r1=1363607&r2=1363608&view=diff ============================================================================== --- lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecLATimesParser.java (original) +++ lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecLATimesParser.java Fri Jul 20 01:01:39 2012 @@ -36,7 +36,7 @@ public class TrecLATimesParser extends T @Override public DocData parse(DocData docData, String name, TrecContentSource trecSrc, - StringBuilder docBuf, ParsePathType pathType) throws IOException, InterruptedException { + StringBuilder docBuf, ParsePathType pathType) throws IOException { int mark = 0; // that much is skipped // date... Modified: lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecParserByPath.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecParserByPath.java?rev=1363608&r1=1363607&r2=1363608&view=diff ============================================================================== --- lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecParserByPath.java (original) +++ lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecParserByPath.java Fri Jul 20 01:01:39 2012 @@ -26,7 +26,7 @@ public class TrecParserByPath extends Tr @Override public DocData parse(DocData docData, String name, TrecContentSource trecSrc, - StringBuilder docBuf, ParsePathType pathType) throws IOException, InterruptedException { + StringBuilder docBuf, ParsePathType pathType) throws IOException { return pathType2parser.get(pathType).parse(docData, name, trecSrc, docBuf, pathType); } Modified: lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/feeds/TrecContentSourceTest.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/feeds/TrecContentSourceTest.java?rev=1363608&r1=1363607&r2=1363608&view=diff ============================================================================== --- lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/feeds/TrecContentSourceTest.java (original) +++ lucene/dev/branches/LUCENE-2878/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/feeds/TrecContentSourceTest.java Fri Jul 20 01:01:39 2012 @@ -166,6 +166,7 @@ public class TrecContentSourceTest exten "\r\n" + "TEST-001 title\r\n" + "\r\n" + + "" + "\r\n" + "\r\n" + "\r\n" + @@ -183,7 +184,7 @@ public class TrecContentSourceTest exten dd = source.getNextDocData(dd); assertDocData(dd, "TEST-001_0", "TEST-001 title", "TEST-001 text", source - .parseDate("Sun, 11 Jan 2009 08:01:00 GMT")); + .parseDate("Tue, 09 Dec 2003 22:39:08 GMT")); assertNoMoreDataException(source); } @@ -331,6 +332,7 @@ public class TrecContentSourceTest exten dd = source.getNextDocData(dd); assertDocData(dd, "TEST-000_1", "TEST-000 title", "TEST-000 text", source .parseDate("Sun, 11 Jan 2009 08:00:00 GMT")); + source.close(); // Don't test that NoMoreDataException is thrown, since the forever flag is // turned on. Modified: lucene/dev/branches/LUCENE-2878/lucene/build.xml URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/build.xml?rev=1363608&r1=1363607&r2=1363608&view=diff ============================================================================== --- lucene/dev/branches/LUCENE-2878/lucene/build.xml (original) +++ lucene/dev/branches/LUCENE-2878/lucene/build.xml Fri Jul 20 01:01:39 2012 @@ -143,13 +143,9 @@ - + + Clover not enabled! - - - - - @@ -158,25 +154,25 @@ - - - + - + + + @@ -186,11 +182,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -374,6 +412,8 @@ + + Modified: lucene/dev/branches/LUCENE-2878/lucene/common-build.xml URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/common-build.xml?rev=1363608&r1=1363607&r2=1363608&view=diff ============================================================================== --- lucene/dev/branches/LUCENE-2878/lucene/common-build.xml (original) +++ lucene/dev/branches/LUCENE-2878/lucene/common-build.xml Fri Jul 20 01:01:39 2012 @@ -95,7 +95,17 @@ + + + + + + + + + + @@ -124,9 +134,6 @@ - - @@ -155,7 +162,6 @@ - @@ -213,31 +219,20 @@ - - + + + - - - - - - - - - @@ -793,6 +788,7 @@ > + @@ -802,6 +798,7 @@ + @@ -1091,48 +1088,55 @@ ${tests-output}/junit4-*.suites - pe - + - + + + + + - + ######################################################################### + Atlassian Clover License not found! + + Current License path: ${clover.license.path} + + To use Atlassian Clover with Lucene build, you need a proper license + and let the system property 'clover.license.path' point to it. + You can pass it to ANT with: + + $ ant -Dclover.license.path=/path/to/clover.license -Drun.clover=true ... + + Apache Lucene/Solr source checkouts from SVN already contain the + file, but source distributions cannot because of legal reasons. + ######################################################################### + +]]> + Code coverage with Atlassian Clover enabled. + + - - + + - - - - + + - - - Clover not found. Code coverage reports disabled. - - - - - - ################################################################## - Clover not found. - Please make sure clover.jar is in ANT_HOME/lib, or made available - to Ant using other mechanisms like -lib or CLASSPATH. - ################################################################## - + + + @@ -1259,13 +1263,10 @@ ${tests-output}/junit4-*.suites - pe - - - - - - - + + + + * * @param fieldName the name of the field the created TokenStream is used for @@ -83,7 +83,7 @@ public abstract class Analyzer { components = createComponents(fieldName, r); reuseStrategy.setReusableComponents(fieldName, components); } else { - components.reset(r); + components.setReader(r); } return components.getTokenStream(); } @@ -181,8 +181,8 @@ public abstract class Analyzer { * @throws IOException * if the component's reset method throws an {@link IOException} */ - protected void reset(final Reader reader) throws IOException { - source.reset(reader); + protected void setReader(final Reader reader) throws IOException { + source.setReader(reader); } /** Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/analysis/Tokenizer.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/analysis/Tokenizer.java?rev=1363608&r1=1363607&r2=1363608&view=diff ============================================================================== --- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/analysis/Tokenizer.java (original) +++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/analysis/Tokenizer.java Fri Jul 20 01:01:39 2012 @@ -65,21 +65,21 @@ public abstract class Tokenizer extends } } - /** Return the corrected offset. If {@link #input} is a {@link CharStream} subclass - * this method calls {@link CharStream#correctOffset}, else returns currentOff. + /** Return the corrected offset. If {@link #input} is a {@link CharFilter} subclass + * this method calls {@link CharFilter#correctOffset}, else returns currentOff. * @param currentOff offset as seen in the output * @return corrected offset based on the input - * @see CharStream#correctOffset + * @see CharFilter#correctOffset */ protected final int correctOffset(int currentOff) { assert input != null: "this tokenizer is closed"; - return (input instanceof CharStream) ? ((CharStream) input).correctOffset(currentOff) : currentOff; + return (input instanceof CharFilter) ? ((CharFilter) input).correctOffset(currentOff) : currentOff; } /** Expert: Reset the tokenizer to a new reader. Typically, an * analyzer (in its tokenStream method) will use * this to re-use a previously created tokenizer. */ - public void reset(Reader input) throws IOException { + public void setReader(Reader input) throws IOException { assert input != null: "input must not be null"; this.input = input; } Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsReader.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsReader.java?rev=1363608&r1=1363607&r2=1363608&view=diff ============================================================================== --- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsReader.java (original) +++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsReader.java Fri Jul 20 01:01:39 2012 @@ -1958,11 +1958,11 @@ public class BlockTreeTermsReader extend } @SuppressWarnings("unused") - private void printSeekState() throws IOException { + private void printSeekState(PrintStream out) throws IOException { if (currentFrame == staticFrame) { - System.out.println(" no prior seek"); + out.println(" no prior seek"); } else { - System.out.println(" prior seek state:"); + out.println(" prior seek state:"); int ord = 0; boolean isSeekFrame = true; while(true) { @@ -1970,26 +1970,26 @@ public class BlockTreeTermsReader extend assert f != null; final BytesRef prefix = new BytesRef(term.bytes, 0, f.prefix); if (f.nextEnt == -1) { - System.out.println(" frame " + (isSeekFrame ? "(seek)" : "(next)") + " ord=" + ord + " fp=" + f.fp + (f.isFloor ? (" (fpOrig=" + f.fpOrig + ")") : "") + " prefixLen=" + f.prefix + " prefix=" + prefix + (f.nextEnt == -1 ? "" : (" (of " + f.entCount + ")")) + " hasTerms=" + f.hasTerms + " isFloor=" + f.isFloor + " code=" + ((f.fp< wIter = weights.iterator(); wIter.hasNext();) { Weight w = wIter.next(); BooleanClause c = cIter.next(); - if (w.scorer(context, true, true, context.reader().getLiveDocs()) == null) { + if (w.scorer(context, true, true, false, false, false, context.reader().getLiveDocs()) == null) { if (c.isRequired()) { fail = true; Explanation r = new Explanation(0.0f, "no match on required clause (" + c.getQuery().toString() + ")"); @@ -303,11 +302,11 @@ public class BooleanQuery extends Query @Override public Scorer scorer(AtomicReaderContext context, boolean scoreDocsInOrder, - boolean topScorer, Bits acceptDocs) + boolean topScorer, boolean needsPositions, boolean needsOffsets, boolean collectPositions, Bits acceptDocs) throws IOException { if (termConjunction) { // specialized scorer for term conjunctions - return createConjunctionTermScorer(context, acceptDocs); + return createConjunctionTermScorer(context, acceptDocs, needsPositions, needsOffsets, collectPositions); } List required = new ArrayList(); List prohibited = new ArrayList(); @@ -315,7 +314,7 @@ public class BooleanQuery extends Query Iterator cIter = clauses.iterator(); for (Weight w : weights) { BooleanClause c = cIter.next(); - Scorer subScorer = w.scorer(context, true, false, acceptDocs); + Scorer subScorer = w.scorer(context, true, false, needsPositions, needsOffsets, collectPositions, acceptDocs); if (subScorer == null) { if (c.isRequired()) { return null; @@ -330,7 +329,7 @@ public class BooleanQuery extends Query } // Check if we can return a BooleanScorer - if (!scoreDocsInOrder && topScorer && required.size() == 0) { + if (!scoreDocsInOrder && !needsPositions && topScorer && required.size() == 0) { return new BooleanScorer(this, disableCoord, minNrShouldMatch, optional, prohibited, maxCoord); } @@ -345,10 +344,10 @@ public class BooleanQuery extends Query } // Return a BooleanScorer2 - return new BooleanScorer2(this, disableCoord, minNrShouldMatch, required, prohibited, optional, maxCoord); + return new BooleanScorer2(this, disableCoord, minNrShouldMatch, required, prohibited, optional, maxCoord, collectPositions); } - private Scorer createConjunctionTermScorer(AtomicReaderContext context, Bits acceptDocs) + private Scorer createConjunctionTermScorer(AtomicReaderContext context, Bits acceptDocs, boolean needsPositions, boolean needsOffsets, boolean collectPositions) throws IOException { // TODO: fix scorer API to specify "needsScores" up @@ -358,47 +357,18 @@ public class BooleanQuery extends Query final DocsAndFreqs[] docsAndFreqs = new DocsAndFreqs[weights.size()]; for (int i = 0; i < docsAndFreqs.length; i++) { final TermWeight weight = (TermWeight) weights.get(i); - final TermsEnum termsEnum = weight.getTermsEnum(context); - if (termsEnum == null) { + final Scorer scorer = weight.scorer(context, true, false, needsPositions, needsOffsets, collectPositions, acceptDocs); + if (scorer == null) { return null; } - final ExactSimScorer docScorer = weight.createDocScorer(context); - final DocsEnum docsAndFreqsEnum = termsEnum.docs(acceptDocs, null, true); - if (docsAndFreqsEnum == null) { - // TODO: we could carry over TermState from the - // terms we already seek'd to, to save re-seeking - // to make the match-only scorer, but it's likely - // rare that BQ mixes terms from omitTf and - // non-omitTF fields: - - // At least one sub cannot provide freqs; abort - // and fallback to full match-only scorer: - return createMatchOnlyConjunctionTermScorer(context, acceptDocs); + if (scorer instanceof TermScorer) { + docsAndFreqs[i] = new DocsAndFreqs((TermScorer) scorer); + } else { + docsAndFreqs[i] = new DocsAndFreqs((MatchOnlyTermScorer) scorer); } - TermDocsEnumFactory factory = new TermDocsEnumFactory(termsEnum, acceptDocs); - docsAndFreqs[i] = new DocsAndFreqs(termsEnum.docFreq(), docScorer, docsAndFreqsEnum, factory); } return new ConjunctionTermScorer(this, disableCoord ? 1.0f : coord( - docsAndFreqs.length, docsAndFreqs.length), docsAndFreqs); - } - - private Scorer createMatchOnlyConjunctionTermScorer(AtomicReaderContext context, Bits acceptDocs) - throws IOException { - - final DocsAndFreqs[] docsAndFreqs = new DocsAndFreqs[weights.size()]; - for (int i = 0; i < docsAndFreqs.length; i++) { - final TermWeight weight = (TermWeight) weights.get(i); - final TermsEnum termsEnum = weight.getTermsEnum(context); - if (termsEnum == null) { - return null; - } - final ExactSimScorer docScorer = weight.createDocScorer(context); - TermDocsEnumFactory factory = new TermDocsEnumFactory(termsEnum, acceptDocs); - docsAndFreqs[i] = new DocsAndFreqs(termsEnum.docFreq(), docScorer, termsEnum.docs(acceptDocs, null, false), factory); - } - - return new MatchOnlyConjunctionTermScorer(this, disableCoord ? 1.0f : coord( - docsAndFreqs.length, docsAndFreqs.length), docsAndFreqs); + docsAndFreqs.length, docsAndFreqs.length), collectPositions, docsAndFreqs); } @Override Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java?rev=1363608&r1=1363607&r2=1363608&view=diff ============================================================================== --- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java (original) +++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/BooleanScorer.java Fri Jul 20 01:01:39 2012 @@ -141,7 +141,7 @@ final class BooleanScorer extends Scorer public float score() { return score; } @Override - public IntervalIterator positions(boolean needsPayloads, boolean needsOffsets, boolean collectPositions) throws IOException { + public IntervalIterator positions() throws IOException { return IntervalIterator.NO_MORE_POSITIONS; } @@ -327,20 +327,13 @@ final class BooleanScorer extends Scorer } @Override - public IntervalIterator positions(boolean needsPayloads, boolean needsOffsets, boolean collectPositions) throws IOException { - final List scorers = new ArrayList(); - SubScorer sub = this.scorers; - while(sub != null) { - if (!sub.prohibited) { - scorers.add(sub.scorer); - } - sub = sub.next; - } - if (this.minNrShouldMatch > 1) { - return new ConjunctionIntervalIterator(this, - collectPositions, this.minNrShouldMatch, BooleanIntervalIterator.pullIterators(needsPayloads, needsOffsets, collectPositions, scorers)); - } - return new DisjunctionIntervalIterator(this, collectPositions, BooleanIntervalIterator.pullIterators(needsPayloads, needsOffsets, collectPositions, scorers)); + public IntervalIterator positions() throws IOException { + throw new UnsupportedOperationException("intervals are not available if docs are matched out of order"); + } + + @Override + public float freq() throws IOException { + return current.coord; } @Override @@ -364,7 +357,8 @@ final class BooleanScorer extends Scorer public Collection getChildren() { List children = new ArrayList(); for (SubScorer sub = scorers; sub != null; sub = sub.next) { - children.add(new ChildScorer(sub.scorer, sub.prohibited ? Occur.MUST_NOT.toString() : Occur.SHOULD.toString())); + // TODO: fix this if BQ ever sends us required clauses + children.add(new ChildScorer(sub.scorer, sub.prohibited ? "MUST_NOT" : "SHOULD")); } return children; } Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/BooleanScorer2.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/BooleanScorer2.java?rev=1363608&r1=1363607&r2=1363608&view=diff ============================================================================== --- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/BooleanScorer2.java (original) +++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/BooleanScorer2.java Fri Jul 20 01:01:39 2012 @@ -88,7 +88,7 @@ class BooleanScorer2 extends Scorer { * the list of optional scorers. */ public BooleanScorer2(BooleanWeight weight, boolean disableCoord, int minNrShouldMatch, - List required, List prohibited, List optional, int maxCoord) throws IOException { + List required, List prohibited, List optional, int maxCoord, boolean collectPositions) throws IOException { super(weight); if (minNrShouldMatch < 0) { throw new IllegalArgumentException("Minimum number of optional scorers should not be negative"); @@ -102,7 +102,7 @@ class BooleanScorer2 extends Scorer { prohibitedScorers = prohibited; coordinator.init(disableCoord); - countingSumScorer = makeCountingSumScorer(disableCoord); + countingSumScorer = makeCountingSumScorer(disableCoord, collectPositions); } /** Count a scorer as a single match. */ @@ -132,6 +132,11 @@ class BooleanScorer2 extends Scorer { } @Override + public float freq() throws IOException { + return 1; + } + + @Override public int docID() { return scorer.docID(); } @@ -147,15 +152,15 @@ class BooleanScorer2 extends Scorer { } @Override - public IntervalIterator positions(boolean needsPayloads, boolean needsOffsets, boolean collectPositions) throws IOException { - return scorer.positions(needsPayloads, needsOffsets, false); + public IntervalIterator positions() throws IOException { + return scorer.positions(); } } private Scorer countingDisjunctionSumScorer(final List scorers, - int minNrShouldMatch) throws IOException { + int minNrShouldMatch, boolean collectPositions) throws IOException { // each scorer from the list counted as a single matcher - return new DisjunctionSumScorer(weight, scorers, minNrShouldMatch) { + return new DisjunctionSumScorer(weight, scorers, minNrShouldMatch, collectPositions) { private int lastScoredDoc = -1; // Save the score of lastScoredDoc, so that we don't compute it more than // once in score(). @@ -174,11 +179,11 @@ class BooleanScorer2 extends Scorer { }; } - private Scorer countingConjunctionSumScorer(boolean disableCoord, + private Scorer countingConjunctionSumScorer(boolean disableCoord, boolean collectPositions, List requiredScorers) throws IOException { // each scorer from the list counted as a single matcher final int requiredNrMatchers = requiredScorers.size(); - return new ConjunctionScorer(weight, disableCoord ? 1.0f : ((BooleanWeight)weight).coord(requiredScorers.size(), requiredScorers.size()), requiredScorers) { + return new ConjunctionScorer(weight, disableCoord ? 1.0f : ((BooleanWeight)weight).coord(requiredScorers.size(), requiredScorers.size()), collectPositions, requiredScorers) { private int lastScoredDoc = -1; // Save the score of lastScoredDoc, so that we don't compute it more than // once in score(). @@ -201,9 +206,9 @@ class BooleanScorer2 extends Scorer { }; } - private Scorer dualConjunctionSumScorer(boolean disableCoord, + private Scorer dualConjunctionSumScorer(boolean disableCoord, boolean collectPositions, Scorer req1, Scorer req2) throws IOException { // non counting. - return new ConjunctionScorer(weight, disableCoord ? 1.0f : ((BooleanWeight)weight).coord(2, 2), req1, req2); + return new ConjunctionScorer(weight, disableCoord ? 1.0f : ((BooleanWeight)weight).coord(2, 2), collectPositions, req1, req2); // All scorers match, so defaultSimilarity always has 1 as // the coordination factor. // Therefore the sum of the scores of two scorers @@ -213,51 +218,52 @@ class BooleanScorer2 extends Scorer { /** Returns the scorer to be used for match counting and score summing. * Uses requiredScorers, optionalScorers and prohibitedScorers. */ - private Scorer makeCountingSumScorer(boolean disableCoord) throws IOException { // each scorer counted as a single matcher + private Scorer makeCountingSumScorer(boolean disableCoord, boolean collectPositions) throws IOException { // each scorer counted as a single matcher return (requiredScorers.size() == 0) - ? makeCountingSumScorerNoReq(disableCoord) - : makeCountingSumScorerSomeReq(disableCoord); + ? makeCountingSumScorerNoReq(disableCoord, collectPositions) + : makeCountingSumScorerSomeReq(disableCoord, collectPositions); } - private Scorer makeCountingSumScorerNoReq(boolean disableCoord) throws IOException { // No required scorers + private Scorer makeCountingSumScorerNoReq(boolean disableCoord, boolean collectPositions) throws IOException { // No required scorers // minNrShouldMatch optional scorers are required, but at least 1 int nrOptRequired = (minNrShouldMatch < 1) ? 1 : minNrShouldMatch; Scorer requiredCountingSumScorer; if (optionalScorers.size() > nrOptRequired) - requiredCountingSumScorer = countingDisjunctionSumScorer(optionalScorers, nrOptRequired); + requiredCountingSumScorer = countingDisjunctionSumScorer(optionalScorers, nrOptRequired, collectPositions); else if (optionalScorers.size() == 1) requiredCountingSumScorer = new SingleMatchScorer(optionalScorers.get(0)); else { - requiredCountingSumScorer = countingConjunctionSumScorer(disableCoord, optionalScorers); + requiredCountingSumScorer = countingConjunctionSumScorer(disableCoord, collectPositions, optionalScorers); } - return addProhibitedScorers(requiredCountingSumScorer); + return addProhibitedScorers(requiredCountingSumScorer, collectPositions); } - private Scorer makeCountingSumScorerSomeReq(boolean disableCoord) throws IOException { // At least one required scorer. + private Scorer makeCountingSumScorerSomeReq(boolean disableCoord, boolean collectPositions) throws IOException { // At least one required scorer. if (optionalScorers.size() == minNrShouldMatch) { // all optional scorers also required. ArrayList allReq = new ArrayList(requiredScorers); allReq.addAll(optionalScorers); - return addProhibitedScorers(countingConjunctionSumScorer(disableCoord, allReq)); + return addProhibitedScorers(countingConjunctionSumScorer(disableCoord, collectPositions, allReq), collectPositions); } else { // optionalScorers.size() > minNrShouldMatch, and at least one required scorer Scorer requiredCountingSumScorer = requiredScorers.size() == 1 ? new SingleMatchScorer(requiredScorers.get(0)) - : countingConjunctionSumScorer(disableCoord, requiredScorers); + : countingConjunctionSumScorer(disableCoord, collectPositions, requiredScorers); if (minNrShouldMatch > 0) { // use a required disjunction scorer over the optional scorers return addProhibitedScorers( dualConjunctionSumScorer( // non counting - disableCoord, + disableCoord, + collectPositions, requiredCountingSumScorer, countingDisjunctionSumScorer( optionalScorers, - minNrShouldMatch))); + minNrShouldMatch, collectPositions)), collectPositions); } else { // minNrShouldMatch == 0 return new ReqOptSumScorer( - addProhibitedScorers(requiredCountingSumScorer), + addProhibitedScorers(requiredCountingSumScorer, collectPositions), optionalScorers.size() == 1 ? new SingleMatchScorer(optionalScorers.get(0)) // require 1 in combined, optional scorer. - : countingDisjunctionSumScorer(optionalScorers, 1)); + : countingDisjunctionSumScorer(optionalScorers, 1, collectPositions), collectPositions); } } } @@ -266,14 +272,14 @@ class BooleanScorer2 extends Scorer { * Uses the given required scorer and the prohibitedScorers. * @param requiredCountingSumScorer A required scorer already built. */ - private Scorer addProhibitedScorers(Scorer requiredCountingSumScorer) throws IOException + private Scorer addProhibitedScorers(Scorer requiredCountingSumScorer, boolean collectPositions) throws IOException { return (prohibitedScorers.size() == 0) ? requiredCountingSumScorer // no prohibited : new ReqExclScorer(requiredCountingSumScorer, ((prohibitedScorers.size() == 1) ? prohibitedScorers.get(0) - : new DisjunctionSumScorer(weight, prohibitedScorers))); + : new DisjunctionSumScorer(weight, collectPositions, prohibitedScorers)), collectPositions); } /** Scores and collects all matching documents. @@ -316,8 +322,8 @@ class BooleanScorer2 extends Scorer { } @Override - public float freq() { - return coordinator.nrMatchers; + public float freq() throws IOException { + return countingSumScorer.freq(); } @Override @@ -326,21 +332,21 @@ class BooleanScorer2 extends Scorer { } @Override - public IntervalIterator positions(boolean needsPayloads, boolean needsOffsets, boolean collectPositions) throws IOException { - return countingSumScorer.positions(needsPayloads, needsOffsets, collectPositions); + public IntervalIterator positions() throws IOException { + return countingSumScorer.positions(); } @Override public Collection getChildren() { ArrayList children = new ArrayList(); for (Scorer s : optionalScorers) { - children.add(new ChildScorer(s, Occur.SHOULD.toString())); + children.add(new ChildScorer(s, "SHOULD")); } for (Scorer s : prohibitedScorers) { - children.add(new ChildScorer(s, Occur.MUST_NOT.toString())); + children.add(new ChildScorer(s, "MUST_NOT")); } for (Scorer s : requiredScorers) { - children.add(new ChildScorer(s, Occur.MUST.toString())); + children.add(new ChildScorer(s, "MUST")); } return children; } Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/CachingCollector.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/CachingCollector.java?rev=1363608&r1=1363607&r2=1363608&view=diff ============================================================================== --- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/CachingCollector.java (original) +++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/CachingCollector.java Fri Jul 20 01:01:39 2012 @@ -92,7 +92,7 @@ public abstract class CachingCollector e public final int nextDoc() { throw new UnsupportedOperationException(); } @Override - public IntervalIterator positions(boolean needsPayloads, boolean needsOffsets, boolean collectPositions) throws IOException { throw new UnsupportedOperationException(); } + public IntervalIterator positions() throws IOException { throw new UnsupportedOperationException(); } } // A CachingCollector which caches scores Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/Collector.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/Collector.java?rev=1363608&r1=1363607&r2=1363608&view=diff ============================================================================== --- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/Collector.java (original) +++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/Collector.java Fri Jul 20 01:01:39 2012 @@ -175,6 +175,9 @@ public abstract class Collector { public boolean needsPositions() { return false; } - public boolean needsPayloads() { return false; } + public boolean needsOffsets() { return false; } + + public boolean collectsPositions() { return false; } + } Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/ConjunctionScorer.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/ConjunctionScorer.java?rev=1363608&r1=1363607&r2=1363608&view=diff ============================================================================== --- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/ConjunctionScorer.java (original) +++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/ConjunctionScorer.java Fri Jul 20 01:01:39 2012 @@ -18,6 +18,7 @@ package org.apache.lucene.search; */ import java.io.IOException; +import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; @@ -33,13 +34,15 @@ class ConjunctionScorer extends Scorer { private final Scorer[] scorers; private final float coord; private int lastDoc = -1; + private final boolean collectPositions; - public ConjunctionScorer(Weight weight, float coord, Collection scorers) throws IOException { - this(weight, coord, scorers.toArray(new Scorer[scorers.size()])); + public ConjunctionScorer(Weight weight, float coord, boolean collectPositions, Collection scorers) throws IOException { + this(weight, coord, collectPositions, scorers.toArray(new Scorer[scorers.size()])); } - public ConjunctionScorer(Weight weight, float coord, Scorer... scorers) throws IOException { + public ConjunctionScorer(Weight weight, float coord, boolean collectPositions, Scorer... scorers) throws IOException { super(weight); + this.collectPositions = collectPositions; scorersOrdered = new Scorer[scorers.length]; System.arraycopy(scorers, 0, scorersOrdered, 0, scorers.length); this.scorers = scorers; @@ -145,12 +148,26 @@ class ConjunctionScorer extends Scorer { } @Override - public IntervalIterator positions(boolean needsPayloads, boolean needsOffsets, boolean collectPositions) throws IOException { + public IntervalIterator positions() throws IOException { if (scorersOrdered == null) { throw new IllegalStateException("no positions requested for this scorer"); } // only created if needed for this scorer - no penalty for non-positional queries - return new ConjunctionIntervalIterator(this, collectPositions, BooleanIntervalIterator.pullIterators(needsPayloads, needsOffsets, collectPositions, scorersOrdered)); + return new ConjunctionIntervalIterator(this, collectPositions, BooleanIntervalIterator.pullIterators(scorersOrdered)); } + + @Override + public float freq() throws IOException { + return scorers.length; + } + + @Override + public Collection getChildren() { + ArrayList children = new ArrayList(scorers.length); + for (Scorer scorer : scorers) { + children.add(new ChildScorer(scorer, "MUST")); + } + return children; + } } Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/ConjunctionTermScorer.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/ConjunctionTermScorer.java?rev=1363608&r1=1363607&r2=1363608&view=diff ============================================================================== --- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/ConjunctionTermScorer.java (original) +++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/ConjunctionTermScorer.java Fri Jul 20 01:01:39 2012 @@ -18,14 +18,15 @@ package org.apache.lucene.search; */ import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; import java.util.Comparator; +import org.apache.lucene.index.DocsAndPositionsEnum; import org.apache.lucene.index.DocsEnum; -import org.apache.lucene.search.TermQuery.TermDocsEnumFactory; import org.apache.lucene.search.positions.ConjunctionIntervalIterator; import org.apache.lucene.search.positions.IntervalIterator; import org.apache.lucene.search.positions.TermIntervalIterator; -import org.apache.lucene.search.similarities.Similarity.ExactSimScorer; import org.apache.lucene.util.ArrayUtil; @@ -36,10 +37,12 @@ class ConjunctionTermScorer extends Scor protected final DocsAndFreqs[] docsAndFreqs; private final DocsAndFreqs lead; private DocsAndFreqs[] origDocsAndFreqs; + private final boolean collectPositions; - ConjunctionTermScorer(Weight weight, float coord, + ConjunctionTermScorer(Weight weight, float coord, boolean collectPositions, DocsAndFreqs[] docsAndFreqs) { super(weight); + this.collectPositions = collectPositions; this.coord = coord; this.docsAndFreqs = docsAndFreqs; this.origDocsAndFreqs = new DocsAndFreqs[docsAndFreqs.length]; @@ -99,34 +102,54 @@ class ConjunctionTermScorer extends Scor public float score() throws IOException { float sum = 0.0f; for (DocsAndFreqs docs : docsAndFreqs) { - sum += docs.docScorer.score(lastDoc, docs.docs.freq()); + sum += docs.scorer.score(); } return sum * coord; } + + @Override + public float freq() { + return docsAndFreqs.length; + } + + @Override + public Collection getChildren() { + ArrayList children = new ArrayList(docsAndFreqs.length); + for (DocsAndFreqs docs : docsAndFreqs) { + children.add(new ChildScorer(docs.scorer, "MUST")); + } + return children; + } static final class DocsAndFreqs { - //final DocsEnum docsAndFreqs; final DocsEnum docs; final int docFreq; - final ExactSimScorer docScorer; + final Scorer scorer; int doc = -1; - private final TermDocsEnumFactory factory; - DocsAndFreqs( int docFreq, ExactSimScorer docScorer, DocsEnum docs, TermDocsEnumFactory factory) throws IOException { - //this.docsAndFreqs = factory.docsAndFreqsEnum(); + DocsAndFreqs(TermScorer termScorer) { + this(termScorer, termScorer.getDocsEnum(), termScorer.getDocFreq()); + } + + DocsAndFreqs(MatchOnlyTermScorer termScorer) { + this(termScorer, termScorer.getDocsEnum(), termScorer.getDocFreq()); + } + + DocsAndFreqs(Scorer scorer, DocsEnum docs, int docFreq) { this.docs = docs; this.docFreq = docFreq; - this.docScorer = docScorer; - this.factory = factory; + this.scorer = scorer; } } @Override - public IntervalIterator positions(boolean needsPayloads, boolean needsOffsets, boolean collectPositions) throws IOException { + public IntervalIterator positions() throws IOException { + TermIntervalIterator[] positionIters = new TermIntervalIterator[origDocsAndFreqs.length]; for (int i = 0; i < positionIters.length; i++) { DocsAndFreqs d = origDocsAndFreqs[i]; - positionIters[i] = new TermIntervalIterator(this, d.factory.docsAndPositionsEnum(needsOffsets), needsPayloads, collectPositions); + assert d.docs instanceof DocsAndPositionsEnum; + positionIters[i] = new TermIntervalIterator(this, (DocsAndPositionsEnum)d.docs, false, collectPositions); } return new ConjunctionIntervalIterator(this, collectPositions, positionIters); } Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/ConstantScoreQuery.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/ConstantScoreQuery.java?rev=1363608&r1=1363607&r2=1363608&view=diff ============================================================================== --- lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/ConstantScoreQuery.java (original) +++ lucene/dev/branches/LUCENE-2878/lucene/core/src/java/org/apache/lucene/search/ConstantScoreQuery.java Fri Jul 20 01:01:39 2012 @@ -123,7 +123,7 @@ public class ConstantScoreQuery extends @Override public Scorer scorer(AtomicReaderContext context, boolean scoreDocsInOrder, - boolean topScorer, final Bits acceptDocs) throws IOException { + boolean topScorer, boolean needsPositions, boolean needsOffsets, boolean collectPositions, final Bits acceptDocs) throws IOException { final DocIdSetIterator disi; if (filter != null) { assert query == null; @@ -134,7 +134,7 @@ public class ConstantScoreQuery extends disi = dis.iterator(); } else { assert query != null && innerWeight != null; - disi = innerWeight.scorer(context, scoreDocsInOrder, topScorer, acceptDocs); + disi = innerWeight.scorer(context, scoreDocsInOrder, topScorer, needsPositions, needsOffsets, collectPositions, acceptDocs); } if (disi == null) { @@ -150,7 +150,7 @@ public class ConstantScoreQuery extends @Override public Explanation explain(AtomicReaderContext context, int doc) throws IOException { - final Scorer cs = scorer(context, true, false, context.reader().getLiveDocs()); + final Scorer cs = scorer(context, true, false, false, false, false, context.reader().getLiveDocs()); final boolean exists = (cs != null && cs.advance(doc) == doc); final ComplexExplanation result = new ComplexExplanation(); @@ -195,6 +195,11 @@ public class ConstantScoreQuery extends } @Override + public float freq() throws IOException { + return 1; + } + + @Override public int advance(int target) throws IOException { return docIdSetIterator.advance(target); } @@ -229,8 +234,8 @@ public class ConstantScoreQuery extends } @Override - public boolean needsPayloads() { - return collector.needsPayloads(); + public boolean needsOffsets() { + return collector.needsOffsets(); } }; } @@ -256,9 +261,9 @@ public class ConstantScoreQuery extends } @Override - public IntervalIterator positions(boolean needsPayloads, boolean needsOffsets, boolean collectPositions) throws IOException { + public IntervalIterator positions() throws IOException { if (docIdSetIterator instanceof Scorer) { - return ((Scorer) docIdSetIterator).positions(needsPayloads, needsOffsets, false); + return ((Scorer) docIdSetIterator).positions(); } else { throw new UnsupportedOperationException("positions are only supported on Scorer subclasses"); }