Now the logic no longer does what it should.

This is what happens in the base class:

        while ((bytes = termsEnum.next()) != null) {
          if (collector.collect(bytes)) {
            termsEnum.cacheCurrentTerm();
            count++;
          } else {
            return count; // interrupt whole term collection, so also don't 
iterate other subReaders
          }
        }

If you want to fix it, the count++ must be moved *before* the if-check here, 
too. The cacheCurrentTerm should also be added before, as the term was put into 
the pendingTerms enum. With current code the last term is no longer cached and 
counted. This would be correct then:

        while ((bytes = termsEnum.next()) != null) {
          termsEnum.cacheCurrentTerm();
          count++;
          if (!collector.collect(bytes)) {
            return count; // interrupt whole term collection, so also don't 
iterate other subReaders
          }
        }

Especially in 3.x the returned term count (incVistitedTerms) is no longer 
correct :)

Why did you change this at all? I would revert or fix as described.

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: u...@thetaphi.de


> -----Original Message-----
> From: mikemcc...@apache.org [mailto:mikemcc...@apache.org]
> Sent: Thursday, October 21, 2010 12:23 PM
> To: comm...@lucene.apache.org
> Subject: svn commit: r1025929 -
> /lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/MultiTermQuer
> y.java
> 
> Author: mikemccand
> Date: Thu Oct 21 10:22:58 2010
> New Revision: 1025929
> 
> URL: http://svn.apache.org/viewvc?rev=1025929&view=rev
> Log:
> fix MTQ.CutOffTermCollector to check limits after adding term, not before
> 
> Modified:
> 
> lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/MultiTermQuery.
> java
> 
> Modified:
> lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/MultiTermQuery.
> java
> URL:
> http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lu
> cene/search/MultiTermQuery.java?rev=1025929&r1=1025928&r2=1025929&vi
> ew=diff
> ================================================================
> ==============
> ---
> lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/MultiTermQuery.
> java (original)
> +++
> lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/MultiTermQuery.
> java Thu Oct 21 10:22:58 2010
> @@ -759,12 +759,12 @@ public abstract class MultiTermQuery ext
> 
>        @Override
>        public boolean collect(BytesRef bytes) throws IOException {
> +        pendingTerms.add(bytes);
> +        docVisitCount += termsEnum.docFreq();
>          if (pendingTerms.size() >= termCountLimit || docVisitCount >=
> docCountCutoff) {
>            hasCutOff = true;
>            return false;
>          }
> -        pendingTerms.add(bytes);
> -        docVisitCount += termsEnum.docFreq();
>          return true;
>        }
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to