You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Uwe Schindler <uw...@thetaphi.de> on 2010/10/21 14:21:11 UTC
RE: svn commit: r1025929 - /lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/MultiTermQuery.java
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: uwe@thetaphi.de
> -----Original Message-----
> From: mikemccand@apache.org [mailto:mikemccand@apache.org]
> Sent: Thursday, October 21, 2010 12:23 PM
> To: commits@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-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org
Re: svn commit: r1025929 - /lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/MultiTermQuery.java
Posted by Michael McCandless <lu...@mikemccandless.com>.
Whoa, thanks for catching this Uwe!
On Thu, Oct 21, 2010 at 8:21 AM, Uwe Schindler <uw...@thetaphi.de> wrote:
> Why did you change this at all? I would revert or fix as described.
Because the current impl is wasteful, ie it does one too many .next()
calls. I like your fix (move up the count/cache)... I'll commit.
BTW this count is only for debugging/transparency right? Ie so you
can see how many terms were visited during MTQ rewrite.
Mike
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org