RE: svn commit: r888398 - in /lucene/java/trunk: CHANGES.txt contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java src/java/org/apache/lucene/index/DirectoryReader.java src/java/org/apache/lucene/index/MultiReader.java

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

RE: svn commit: r888398 - in /lucene/java/trunk: CHANGES.txt contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java src/java/org/apache/lucene/index/DirectoryReader.java src/java/org/apache/lucene/index/MultiReader.java

Uwe Schindler
Mike,

the test for RegEx was correct, it uses getEnum() not getTermsEnum()! So the
first term returned must be null, because the enum must be positioned on the
first term (which was the case for old enums). If that is not the case such
a query would at least hit one term. So in trunk this test is perfectly
legal and important!

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: [hidden email]


> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]
> Sent: Tuesday, December 08, 2009 2:47 PM
> To: [hidden email]
> Subject: svn commit: r888398 - in /lucene/java/trunk: CHANGES.txt
> contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
> src/java/org/apache/lucene/index/DirectoryReader.java
> src/java/org/apache/lucene/index/MultiReader.java
>
> Author: mikemccand
> Date: Tue Dec  8 13:47:20 2009
> New Revision: 888398
>
> URL: http://svn.apache.org/viewvc?rev=888398&view=rev
> Log:
> LUCENE-2136: optimization: if Multi/DirectoryReader only has a single
> reader, delegate enums to it
>
> Modified:
>     lucene/java/trunk/CHANGES.txt
>
> lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/Te
> stRegexQuery.java
>
> lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
>     lucene/java/trunk/src/java/org/apache/lucene/index/MultiReader.java
>
> Modified: lucene/java/trunk/CHANGES.txt
> URL:
> http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=888398&r1=8
> 88397&r2=888398&view=diff
> ==========================================================================
> ====
> --- lucene/java/trunk/CHANGES.txt (original)
> +++ lucene/java/trunk/CHANGES.txt Tue Dec  8 13:47:20 2009
> @@ -70,6 +70,11 @@
>    lots of seeking (Mike McCandless, Uwe Schindler, Robert Muir, Yonik
>    Seeley)
>
> +* LUCENE-2136: If the multi reader (DirectoryReader or MultiReader)
> +  only has a single sub-reader, delegate all enum requests to it.
> +  This avoid the overhead of using a PQ unecessarily.  (Mike
> +  McCandless)
> +
>  Build
>
>  Test Cases
>
> Modified:
> lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/Te
> stRegexQuery.java
> URL:
> http://svn.apache.org/viewvc/lucene/java/trunk/contrib/regex/src/test/org/
> apache/lucene/search/regex/TestRegexQuery.java?rev=888398&r1=888397&r2=888
> 398&view=diff
> ==========================================================================
> ====
> ---
> lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/Te
> stRegexQuery.java (original)
> +++
> lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/Te
> stRegexQuery.java Tue Dec  8 13:47:20 2009
> @@ -83,7 +83,6 @@
>    public void testMatchAll() throws Exception {
>      TermEnum terms = new RegexQuery(new Term(FN,
> "jum.")).getEnum(searcher.getIndexReader());
>      // no term should match
> -    assertNull(terms.term());
>      assertFalse(terms.next());
>    }
>
>
> Modified:
> lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
> URL:
> http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/
> index/DirectoryReader.java?rev=888398&r1=888397&r2=888398&view=diff
> ==========================================================================
> ====
> ---
> lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
> (original)
> +++
> lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
> Tue Dec  8 13:47:20 2009
> @@ -627,13 +627,23 @@
>    @Override
>    public TermEnum terms() throws IOException {
>      ensureOpen();
> -    return new MultiTermEnum(this, subReaders, starts, null);
> +    if (subReaders.length == 1) {
> +      // Optimize single segment case:
> +      return subReaders[0].terms();
> +    } else {
> +      return new MultiTermEnum(this, subReaders, starts, null);
> +    }
>    }
>
>    @Override
>    public TermEnum terms(Term term) throws IOException {
>      ensureOpen();
> -    return new MultiTermEnum(this, subReaders, starts, term);
> +    if (subReaders.length == 1) {
> +      // Optimize single segment case:
> +      return subReaders[0].terms(term);
> +    } else {
> +      return new MultiTermEnum(this, subReaders, starts, term);
> +    }
>    }
>
>    @Override
> @@ -648,13 +658,34 @@
>    @Override
>    public TermDocs termDocs() throws IOException {
>      ensureOpen();
> -    return new MultiTermDocs(this, subReaders, starts);
> +    if (subReaders.length == 1) {
> +      // Optimize single segment case:
> +      return subReaders[0].termDocs();
> +    } else {
> +      return new MultiTermDocs(this, subReaders, starts);
> +    }
> +  }
> +
> +  @Override
> +  public TermDocs termDocs(Term term) throws IOException {
> +    ensureOpen();
> +    if (subReaders.length == 1) {
> +      // Optimize single segment case:
> +      return subReaders[0].termDocs(term);
> +    } else {
> +      return super.termDocs(term);
> +    }
>    }
>
>    @Override
>    public TermPositions termPositions() throws IOException {
>      ensureOpen();
> -    return new MultiTermPositions(this, subReaders, starts);
> +    if (subReaders.length == 1) {
> +      // Optimize single segment case:
> +      return subReaders[0].termPositions();
> +    } else {
> +      return new MultiTermPositions(this, subReaders, starts);
> +    }
>    }
>
>    /**
>
> Modified:
> lucene/java/trunk/src/java/org/apache/lucene/index/MultiReader.java
> URL:
> http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/
> index/MultiReader.java?rev=888398&r1=888397&r2=888398&view=diff
> ==========================================================================
> ====
> --- lucene/java/trunk/src/java/org/apache/lucene/index/MultiReader.java
> (original)
> +++ lucene/java/trunk/src/java/org/apache/lucene/index/MultiReader.java
> Tue Dec  8 13:47:20 2009
> @@ -339,13 +339,23 @@
>    @Override
>    public TermEnum terms() throws IOException {
>      ensureOpen();
> -    return new MultiTermEnum(this, subReaders, starts, null);
> +    if (subReaders.length == 1) {
> +      // Optimize single segment case:
> +      return subReaders[0].terms();
> +    } else {
> +      return new MultiTermEnum(this, subReaders, starts, null);
> +    }
>    }
>
>    @Override
>    public TermEnum terms(Term term) throws IOException {
>      ensureOpen();
> -    return new MultiTermEnum(this, subReaders, starts, term);
> +    if (subReaders.length == 1) {
> +      // Optimize single segment case:
> +      return subReaders[0].terms(term);
> +    } else {
> +      return new MultiTermEnum(this, subReaders, starts, term);
> +    }
>    }
>
>    @Override
> @@ -360,13 +370,34 @@
>    @Override
>    public TermDocs termDocs() throws IOException {
>      ensureOpen();
> -    return new MultiTermDocs(this, subReaders, starts);
> +    if (subReaders.length == 1) {
> +      // Optimize single segment case:
> +      return subReaders[0].termDocs();
> +    } else {
> +      return new MultiTermDocs(this, subReaders, starts);
> +    }
> +  }
> +
> +  @Override
> +  public TermDocs termDocs(Term term) throws IOException {
> +    ensureOpen();
> +    if (subReaders.length == 1) {
> +      // Optimize single segment case:
> +      return subReaders[0].termDocs(term);
> +    } else {
> +      return super.termDocs(term);
> +    }
>    }
>
>    @Override
>    public TermPositions termPositions() throws IOException {
>      ensureOpen();
> -    return new MultiTermPositions(this, subReaders, starts);
> +    if (subReaders.length == 1) {
> +      // Optimize single segment case:
> +      return subReaders[0].termPositions();
> +    } else {
> +      return new MultiTermPositions(this, subReaders, starts);
> +    }
>    }
>
>    @Override
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: svn commit: r888398 - in /lucene/java/trunk: CHANGES.txt contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java src/java/org/apache/lucene/index/DirectoryReader.java src/java/org/apache/lucene/index/MultiReader.java

Uwe Schindler
Mike I checked,

it seems that you simply copied the code from flex, where the test must be
removed.

In trunk, I'll revert, test passes correctly. I was a little bit confused,
why it should not pass.

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: [hidden email]


> -----Original Message-----
> From: Uwe Schindler [mailto:[hidden email]]
> Sent: Tuesday, December 08, 2009 4:00 PM
> To: [hidden email]
> Subject: RE: svn commit: r888398 - in /lucene/java/trunk: CHANGES.txt
> contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
> src/java/org/apache/lucene/index/DirectoryReader.java
> src/java/org/apache/lucene/index/MultiReader.java
>
> Mike,
>
> the test for RegEx was correct, it uses getEnum() not getTermsEnum()! So
> the
> first term returned must be null, because the enum must be positioned on
> the
> first term (which was the case for old enums). If that is not the case
> such
> a query would at least hit one term. So in trunk this test is perfectly
> legal and important!
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: [hidden email]
>
>
> > -----Original Message-----
> > From: [hidden email] [mailto:[hidden email]]
> > Sent: Tuesday, December 08, 2009 2:47 PM
> > To: [hidden email]
> > Subject: svn commit: r888398 - in /lucene/java/trunk: CHANGES.txt
> >
> contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
> > src/java/org/apache/lucene/index/DirectoryReader.java
> > src/java/org/apache/lucene/index/MultiReader.java
> >
> > Author: mikemccand
> > Date: Tue Dec  8 13:47:20 2009
> > New Revision: 888398
> >
> > URL: http://svn.apache.org/viewvc?rev=888398&view=rev
> > Log:
> > LUCENE-2136: optimization: if Multi/DirectoryReader only has a single
> > reader, delegate enums to it
> >
> > Modified:
> >     lucene/java/trunk/CHANGES.txt
> >
> >
> lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/Te
> > stRegexQuery.java
> >
> > lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
> >     lucene/java/trunk/src/java/org/apache/lucene/index/MultiReader.java
> >
> > Modified: lucene/java/trunk/CHANGES.txt
> > URL:
> >
> http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=888398&r1=8
> > 88397&r2=888398&view=diff
> >
> ==========================================================================
> > ====
> > --- lucene/java/trunk/CHANGES.txt (original)
> > +++ lucene/java/trunk/CHANGES.txt Tue Dec  8 13:47:20 2009
> > @@ -70,6 +70,11 @@
> >    lots of seeking (Mike McCandless, Uwe Schindler, Robert Muir, Yonik
> >    Seeley)
> >
> > +* LUCENE-2136: If the multi reader (DirectoryReader or MultiReader)
> > +  only has a single sub-reader, delegate all enum requests to it.
> > +  This avoid the overhead of using a PQ unecessarily.  (Mike
> > +  McCandless)
> > +
> >  Build
> >
> >  Test Cases
> >
> > Modified:
> >
> lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/Te
> > stRegexQuery.java
> > URL:
> >
> http://svn.apache.org/viewvc/lucene/java/trunk/contrib/regex/src/test/org/
> >
> apache/lucene/search/regex/TestRegexQuery.java?rev=888398&r1=888397&r2=888
> > 398&view=diff
> >
> ==========================================================================
> > ====
> > ---
> >
> lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/Te
> > stRegexQuery.java (original)
> > +++
> >
> lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/Te
> > stRegexQuery.java Tue Dec  8 13:47:20 2009
> > @@ -83,7 +83,6 @@
> >    public void testMatchAll() throws Exception {
> >      TermEnum terms = new RegexQuery(new Term(FN,
> > "jum.")).getEnum(searcher.getIndexReader());
> >      // no term should match
> > -    assertNull(terms.term());
> >      assertFalse(terms.next());
> >    }
> >
> >
> > Modified:
> > lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
> > URL:
> >
> http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/
> > index/DirectoryReader.java?rev=888398&r1=888397&r2=888398&view=diff
> >
> ==========================================================================
> > ====
> > ---
> > lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
> > (original)
> > +++
> > lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
> > Tue Dec  8 13:47:20 2009
> > @@ -627,13 +627,23 @@
> >    @Override
> >    public TermEnum terms() throws IOException {
> >      ensureOpen();
> > -    return new MultiTermEnum(this, subReaders, starts, null);
> > +    if (subReaders.length == 1) {
> > +      // Optimize single segment case:
> > +      return subReaders[0].terms();
> > +    } else {
> > +      return new MultiTermEnum(this, subReaders, starts, null);
> > +    }
> >    }
> >
> >    @Override
> >    public TermEnum terms(Term term) throws IOException {
> >      ensureOpen();
> > -    return new MultiTermEnum(this, subReaders, starts, term);
> > +    if (subReaders.length == 1) {
> > +      // Optimize single segment case:
> > +      return subReaders[0].terms(term);
> > +    } else {
> > +      return new MultiTermEnum(this, subReaders, starts, term);
> > +    }
> >    }
> >
> >    @Override
> > @@ -648,13 +658,34 @@
> >    @Override
> >    public TermDocs termDocs() throws IOException {
> >      ensureOpen();
> > -    return new MultiTermDocs(this, subReaders, starts);
> > +    if (subReaders.length == 1) {
> > +      // Optimize single segment case:
> > +      return subReaders[0].termDocs();
> > +    } else {
> > +      return new MultiTermDocs(this, subReaders, starts);
> > +    }
> > +  }
> > +
> > +  @Override
> > +  public TermDocs termDocs(Term term) throws IOException {
> > +    ensureOpen();
> > +    if (subReaders.length == 1) {
> > +      // Optimize single segment case:
> > +      return subReaders[0].termDocs(term);
> > +    } else {
> > +      return super.termDocs(term);
> > +    }
> >    }
> >
> >    @Override
> >    public TermPositions termPositions() throws IOException {
> >      ensureOpen();
> > -    return new MultiTermPositions(this, subReaders, starts);
> > +    if (subReaders.length == 1) {
> > +      // Optimize single segment case:
> > +      return subReaders[0].termPositions();
> > +    } else {
> > +      return new MultiTermPositions(this, subReaders, starts);
> > +    }
> >    }
> >
> >    /**
> >
> > Modified:
> > lucene/java/trunk/src/java/org/apache/lucene/index/MultiReader.java
> > URL:
> >
> http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/
> > index/MultiReader.java?rev=888398&r1=888397&r2=888398&view=diff
> >
> ==========================================================================
> > ====
> > --- lucene/java/trunk/src/java/org/apache/lucene/index/MultiReader.java
> > (original)
> > +++ lucene/java/trunk/src/java/org/apache/lucene/index/MultiReader.java
> > Tue Dec  8 13:47:20 2009
> > @@ -339,13 +339,23 @@
> >    @Override
> >    public TermEnum terms() throws IOException {
> >      ensureOpen();
> > -    return new MultiTermEnum(this, subReaders, starts, null);
> > +    if (subReaders.length == 1) {
> > +      // Optimize single segment case:
> > +      return subReaders[0].terms();
> > +    } else {
> > +      return new MultiTermEnum(this, subReaders, starts, null);
> > +    }
> >    }
> >
> >    @Override
> >    public TermEnum terms(Term term) throws IOException {
> >      ensureOpen();
> > -    return new MultiTermEnum(this, subReaders, starts, term);
> > +    if (subReaders.length == 1) {
> > +      // Optimize single segment case:
> > +      return subReaders[0].terms(term);
> > +    } else {
> > +      return new MultiTermEnum(this, subReaders, starts, term);
> > +    }
> >    }
> >
> >    @Override
> > @@ -360,13 +370,34 @@
> >    @Override
> >    public TermDocs termDocs() throws IOException {
> >      ensureOpen();
> > -    return new MultiTermDocs(this, subReaders, starts);
> > +    if (subReaders.length == 1) {
> > +      // Optimize single segment case:
> > +      return subReaders[0].termDocs();
> > +    } else {
> > +      return new MultiTermDocs(this, subReaders, starts);
> > +    }
> > +  }
> > +
> > +  @Override
> > +  public TermDocs termDocs(Term term) throws IOException {
> > +    ensureOpen();
> > +    if (subReaders.length == 1) {
> > +      // Optimize single segment case:
> > +      return subReaders[0].termDocs(term);
> > +    } else {
> > +      return super.termDocs(term);
> > +    }
> >    }
> >
> >    @Override
> >    public TermPositions termPositions() throws IOException {
> >      ensureOpen();
> > -    return new MultiTermPositions(this, subReaders, starts);
> > +    if (subReaders.length == 1) {
> > +      // Optimize single segment case:
> > +      return subReaders[0].termPositions();
> > +    } else {
> > +      return new MultiTermPositions(this, subReaders, starts);
> > +    }
> >    }
> >
> >    @Override
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r888398 - in /lucene/java/trunk: CHANGES.txt contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java src/java/org/apache/lucene/index/DirectoryReader.java src/java/org/apache/lucene/index/MultiReader.java

Michael McCandless-2
Sorry, right, test passed on trunk, but it's still not valid even on
trunk (I think?).  Ie TermEnum.term() is undefined until you've called
next?

Mike

On Tue, Dec 8, 2009 at 10:18 AM, Uwe Schindler <[hidden email]> wrote:

> Mike I checked,
>
> it seems that you simply copied the code from flex, where the test must be
> removed.
>
> In trunk, I'll revert, test passes correctly. I was a little bit confused,
> why it should not pass.
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: [hidden email]
>
>
>> -----Original Message-----
>> From: Uwe Schindler [mailto:[hidden email]]
>> Sent: Tuesday, December 08, 2009 4:00 PM
>> To: [hidden email]
>> Subject: RE: svn commit: r888398 - in /lucene/java/trunk: CHANGES.txt
>> contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
>> src/java/org/apache/lucene/index/DirectoryReader.java
>> src/java/org/apache/lucene/index/MultiReader.java
>>
>> Mike,
>>
>> the test for RegEx was correct, it uses getEnum() not getTermsEnum()! So
>> the
>> first term returned must be null, because the enum must be positioned on
>> the
>> first term (which was the case for old enums). If that is not the case
>> such
>> a query would at least hit one term. So in trunk this test is perfectly
>> legal and important!
>>
>> -----
>> Uwe Schindler
>> H.-H.-Meier-Allee 63, D-28213 Bremen
>> http://www.thetaphi.de
>> eMail: [hidden email]
>>
>>
>> > -----Original Message-----
>> > From: [hidden email] [mailto:[hidden email]]
>> > Sent: Tuesday, December 08, 2009 2:47 PM
>> > To: [hidden email]
>> > Subject: svn commit: r888398 - in /lucene/java/trunk: CHANGES.txt
>> >
>> contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
>> > src/java/org/apache/lucene/index/DirectoryReader.java
>> > src/java/org/apache/lucene/index/MultiReader.java
>> >
>> > Author: mikemccand
>> > Date: Tue Dec  8 13:47:20 2009
>> > New Revision: 888398
>> >
>> > URL: http://svn.apache.org/viewvc?rev=888398&view=rev
>> > Log:
>> > LUCENE-2136: optimization: if Multi/DirectoryReader only has a single
>> > reader, delegate enums to it
>> >
>> > Modified:
>> >     lucene/java/trunk/CHANGES.txt
>> >
>> >
>> lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/Te
>> > stRegexQuery.java
>> >
>> > lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
>> >     lucene/java/trunk/src/java/org/apache/lucene/index/MultiReader.java
>> >
>> > Modified: lucene/java/trunk/CHANGES.txt
>> > URL:
>> >
>> http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=888398&r1=8
>> > 88397&r2=888398&view=diff
>> >
>> ==========================================================================
>> > ====
>> > --- lucene/java/trunk/CHANGES.txt (original)
>> > +++ lucene/java/trunk/CHANGES.txt Tue Dec  8 13:47:20 2009
>> > @@ -70,6 +70,11 @@
>> >    lots of seeking (Mike McCandless, Uwe Schindler, Robert Muir, Yonik
>> >    Seeley)
>> >
>> > +* LUCENE-2136: If the multi reader (DirectoryReader or MultiReader)
>> > +  only has a single sub-reader, delegate all enum requests to it.
>> > +  This avoid the overhead of using a PQ unecessarily.  (Mike
>> > +  McCandless)
>> > +
>> >  Build
>> >
>> >  Test Cases
>> >
>> > Modified:
>> >
>> lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/Te
>> > stRegexQuery.java
>> > URL:
>> >
>> http://svn.apache.org/viewvc/lucene/java/trunk/contrib/regex/src/test/org/
>> >
>> apache/lucene/search/regex/TestRegexQuery.java?rev=888398&r1=888397&r2=888
>> > 398&view=diff
>> >
>> ==========================================================================
>> > ====
>> > ---
>> >
>> lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/Te
>> > stRegexQuery.java (original)
>> > +++
>> >
>> lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/Te
>> > stRegexQuery.java Tue Dec  8 13:47:20 2009
>> > @@ -83,7 +83,6 @@
>> >    public void testMatchAll() throws Exception {
>> >      TermEnum terms = new RegexQuery(new Term(FN,
>> > "jum.")).getEnum(searcher.getIndexReader());
>> >      // no term should match
>> > -    assertNull(terms.term());
>> >      assertFalse(terms.next());
>> >    }
>> >
>> >
>> > Modified:
>> > lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
>> > URL:
>> >
>> http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/
>> > index/DirectoryReader.java?rev=888398&r1=888397&r2=888398&view=diff
>> >
>> ==========================================================================
>> > ====
>> > ---
>> > lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
>> > (original)
>> > +++
>> > lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
>> > Tue Dec  8 13:47:20 2009
>> > @@ -627,13 +627,23 @@
>> >    @Override
>> >    public TermEnum terms() throws IOException {
>> >      ensureOpen();
>> > -    return new MultiTermEnum(this, subReaders, starts, null);
>> > +    if (subReaders.length == 1) {
>> > +      // Optimize single segment case:
>> > +      return subReaders[0].terms();
>> > +    } else {
>> > +      return new MultiTermEnum(this, subReaders, starts, null);
>> > +    }
>> >    }
>> >
>> >    @Override
>> >    public TermEnum terms(Term term) throws IOException {
>> >      ensureOpen();
>> > -    return new MultiTermEnum(this, subReaders, starts, term);
>> > +    if (subReaders.length == 1) {
>> > +      // Optimize single segment case:
>> > +      return subReaders[0].terms(term);
>> > +    } else {
>> > +      return new MultiTermEnum(this, subReaders, starts, term);
>> > +    }
>> >    }
>> >
>> >    @Override
>> > @@ -648,13 +658,34 @@
>> >    @Override
>> >    public TermDocs termDocs() throws IOException {
>> >      ensureOpen();
>> > -    return new MultiTermDocs(this, subReaders, starts);
>> > +    if (subReaders.length == 1) {
>> > +      // Optimize single segment case:
>> > +      return subReaders[0].termDocs();
>> > +    } else {
>> > +      return new MultiTermDocs(this, subReaders, starts);
>> > +    }
>> > +  }
>> > +
>> > +  @Override
>> > +  public TermDocs termDocs(Term term) throws IOException {
>> > +    ensureOpen();
>> > +    if (subReaders.length == 1) {
>> > +      // Optimize single segment case:
>> > +      return subReaders[0].termDocs(term);
>> > +    } else {
>> > +      return super.termDocs(term);
>> > +    }
>> >    }
>> >
>> >    @Override
>> >    public TermPositions termPositions() throws IOException {
>> >      ensureOpen();
>> > -    return new MultiTermPositions(this, subReaders, starts);
>> > +    if (subReaders.length == 1) {
>> > +      // Optimize single segment case:
>> > +      return subReaders[0].termPositions();
>> > +    } else {
>> > +      return new MultiTermPositions(this, subReaders, starts);
>> > +    }
>> >    }
>> >
>> >    /**
>> >
>> > Modified:
>> > lucene/java/trunk/src/java/org/apache/lucene/index/MultiReader.java
>> > URL:
>> >
>> http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/
>> > index/MultiReader.java?rev=888398&r1=888397&r2=888398&view=diff
>> >
>> ==========================================================================
>> > ====
>> > --- lucene/java/trunk/src/java/org/apache/lucene/index/MultiReader.java
>> > (original)
>> > +++ lucene/java/trunk/src/java/org/apache/lucene/index/MultiReader.java
>> > Tue Dec  8 13:47:20 2009
>> > @@ -339,13 +339,23 @@
>> >    @Override
>> >    public TermEnum terms() throws IOException {
>> >      ensureOpen();
>> > -    return new MultiTermEnum(this, subReaders, starts, null);
>> > +    if (subReaders.length == 1) {
>> > +      // Optimize single segment case:
>> > +      return subReaders[0].terms();
>> > +    } else {
>> > +      return new MultiTermEnum(this, subReaders, starts, null);
>> > +    }
>> >    }
>> >
>> >    @Override
>> >    public TermEnum terms(Term term) throws IOException {
>> >      ensureOpen();
>> > -    return new MultiTermEnum(this, subReaders, starts, term);
>> > +    if (subReaders.length == 1) {
>> > +      // Optimize single segment case:
>> > +      return subReaders[0].terms(term);
>> > +    } else {
>> > +      return new MultiTermEnum(this, subReaders, starts, term);
>> > +    }
>> >    }
>> >
>> >    @Override
>> > @@ -360,13 +370,34 @@
>> >    @Override
>> >    public TermDocs termDocs() throws IOException {
>> >      ensureOpen();
>> > -    return new MultiTermDocs(this, subReaders, starts);
>> > +    if (subReaders.length == 1) {
>> > +      // Optimize single segment case:
>> > +      return subReaders[0].termDocs();
>> > +    } else {
>> > +      return new MultiTermDocs(this, subReaders, starts);
>> > +    }
>> > +  }
>> > +
>> > +  @Override
>> > +  public TermDocs termDocs(Term term) throws IOException {
>> > +    ensureOpen();
>> > +    if (subReaders.length == 1) {
>> > +      // Optimize single segment case:
>> > +      return subReaders[0].termDocs(term);
>> > +    } else {
>> > +      return super.termDocs(term);
>> > +    }
>> >    }
>> >
>> >    @Override
>> >    public TermPositions termPositions() throws IOException {
>> >      ensureOpen();
>> > -    return new MultiTermPositions(this, subReaders, starts);
>> > +    if (subReaders.length == 1) {
>> > +      // Optimize single segment case:
>> > +      return subReaders[0].termPositions();
>> > +    } else {
>> > +      return new MultiTermPositions(this, subReaders, starts);
>> > +    }
>> >    }
>> >
>> >    @Override
>> >
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: svn commit: r888398 - in /lucene/java/trunk: CHANGES.txt contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java src/java/org/apache/lucene/index/DirectoryReader.java src/java/org/apache/lucene/index/MultiReader.java

Uwe Schindler
It is defined to be null.

Because the enums in trunk are positioned on the first term (because
IR.terms(Term) positions the enum on the first term, if the term does not
exist, it must be null, else you cannot detect that the enum is empty).
Because of that you have the do-while loops in trunk!

In flex, the enum is unpositioned and you always have to call next() first.
In flex it behaves as it should, but in trunk its not intuitive.

See e.g. FieldCache or MTQ in trunk, the loops are different!

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: [hidden email]


> -----Original Message-----
> From: Michael McCandless [mailto:[hidden email]]
> Sent: Tuesday, December 08, 2009 4:25 PM
> To: [hidden email]
> Subject: Re: svn commit: r888398 - in /lucene/java/trunk: CHANGES.txt
> contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
> src/java/org/apache/lucene/index/DirectoryReader.java
> src/java/org/apache/lucene/index/MultiReader.java
>
> Sorry, right, test passed on trunk, but it's still not valid even on
> trunk (I think?).  Ie TermEnum.term() is undefined until you've called
> next?
>
> Mike
>
> On Tue, Dec 8, 2009 at 10:18 AM, Uwe Schindler <[hidden email]> wrote:
> > Mike I checked,
> >
> > it seems that you simply copied the code from flex, where the test must
> be
> > removed.
> >
> > In trunk, I'll revert, test passes correctly. I was a little bit
> confused,
> > why it should not pass.
> >
> > -----
> > Uwe Schindler
> > H.-H.-Meier-Allee 63, D-28213 Bremen
> > http://www.thetaphi.de
> > eMail: [hidden email]
> >
> >
> >> -----Original Message-----
> >> From: Uwe Schindler [mailto:[hidden email]]
> >> Sent: Tuesday, December 08, 2009 4:00 PM
> >> To: [hidden email]
> >> Subject: RE: svn commit: r888398 - in /lucene/java/trunk: CHANGES.txt
> >>
> contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
> >> src/java/org/apache/lucene/index/DirectoryReader.java
> >> src/java/org/apache/lucene/index/MultiReader.java
> >>
> >> Mike,
> >>
> >> the test for RegEx was correct, it uses getEnum() not getTermsEnum()!
> So
> >> the
> >> first term returned must be null, because the enum must be positioned
> on
> >> the
> >> first term (which was the case for old enums). If that is not the case
> >> such
> >> a query would at least hit one term. So in trunk this test is perfectly
> >> legal and important!
> >>
> >> -----
> >> Uwe Schindler
> >> H.-H.-Meier-Allee 63, D-28213 Bremen
> >> http://www.thetaphi.de
> >> eMail: [hidden email]
> >>
> >>
> >> > -----Original Message-----
> >> > From: [hidden email] [mailto:[hidden email]]
> >> > Sent: Tuesday, December 08, 2009 2:47 PM
> >> > To: [hidden email]
> >> > Subject: svn commit: r888398 - in /lucene/java/trunk: CHANGES.txt
> >> >
> >>
> contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
> >> > src/java/org/apache/lucene/index/DirectoryReader.java
> >> > src/java/org/apache/lucene/index/MultiReader.java
> >> >
> >> > Author: mikemccand
> >> > Date: Tue Dec  8 13:47:20 2009
> >> > New Revision: 888398
> >> >
> >> > URL: http://svn.apache.org/viewvc?rev=888398&view=rev
> >> > Log:
> >> > LUCENE-2136: optimization: if Multi/DirectoryReader only has a single
> >> > reader, delegate enums to it
> >> >
> >> > Modified:
> >> >     lucene/java/trunk/CHANGES.txt
> >> >
> >> >
> >>
> lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/Te
> >> > stRegexQuery.java
> >> >
> >> >
> lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
> >> >
> lucene/java/trunk/src/java/org/apache/lucene/index/MultiReader.java
> >> >
> >> > Modified: lucene/java/trunk/CHANGES.txt
> >> > URL:
> >> >
> >>
> http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=888398&r1=8
> >> > 88397&r2=888398&view=diff
> >> >
> >>
> ==========================================================================
> >> > ====
> >> > --- lucene/java/trunk/CHANGES.txt (original)
> >> > +++ lucene/java/trunk/CHANGES.txt Tue Dec  8 13:47:20 2009
> >> > @@ -70,6 +70,11 @@
> >> >    lots of seeking (Mike McCandless, Uwe Schindler, Robert Muir,
> Yonik
> >> >    Seeley)
> >> >
> >> > +* LUCENE-2136: If the multi reader (DirectoryReader or MultiReader)
> >> > +  only has a single sub-reader, delegate all enum requests to it.
> >> > +  This avoid the overhead of using a PQ unecessarily.  (Mike
> >> > +  McCandless)
> >> > +
> >> >  Build
> >> >
> >> >  Test Cases
> >> >
> >> > Modified:
> >> >
> >>
> lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/Te
> >> > stRegexQuery.java
> >> > URL:
> >> >
> >>
> http://svn.apache.org/viewvc/lucene/java/trunk/contrib/regex/src/test/org/
> >> >
> >>
> apache/lucene/search/regex/TestRegexQuery.java?rev=888398&r1=888397&r2=888
> >> > 398&view=diff
> >> >
> >>
> ==========================================================================
> >> > ====
> >> > ---
> >> >
> >>
> lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/Te
> >> > stRegexQuery.java (original)
> >> > +++
> >> >
> >>
> lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/Te
> >> > stRegexQuery.java Tue Dec  8 13:47:20 2009
> >> > @@ -83,7 +83,6 @@
> >> >    public void testMatchAll() throws Exception {
> >> >      TermEnum terms = new RegexQuery(new Term(FN,
> >> > "jum.")).getEnum(searcher.getIndexReader());
> >> >      // no term should match
> >> > -    assertNull(terms.term());
> >> >      assertFalse(terms.next());
> >> >    }
> >> >
> >> >
> >> > Modified:
> >> >
> lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
> >> > URL:
> >> >
> >>
> http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/
> >> > index/DirectoryReader.java?rev=888398&r1=888397&r2=888398&view=diff
> >> >
> >>
> ==========================================================================
> >> > ====
> >> > ---
> >> >
> lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
> >> > (original)
> >> > +++
> >> >
> lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
> >> > Tue Dec  8 13:47:20 2009
> >> > @@ -627,13 +627,23 @@
> >> >    @Override
> >> >    public TermEnum terms() throws IOException {
> >> >      ensureOpen();
> >> > -    return new MultiTermEnum(this, subReaders, starts, null);
> >> > +    if (subReaders.length == 1) {
> >> > +      // Optimize single segment case:
> >> > +      return subReaders[0].terms();
> >> > +    } else {
> >> > +      return new MultiTermEnum(this, subReaders, starts, null);
> >> > +    }
> >> >    }
> >> >
> >> >    @Override
> >> >    public TermEnum terms(Term term) throws IOException {
> >> >      ensureOpen();
> >> > -    return new MultiTermEnum(this, subReaders, starts, term);
> >> > +    if (subReaders.length == 1) {
> >> > +      // Optimize single segment case:
> >> > +      return subReaders[0].terms(term);
> >> > +    } else {
> >> > +      return new MultiTermEnum(this, subReaders, starts, term);
> >> > +    }
> >> >    }
> >> >
> >> >    @Override
> >> > @@ -648,13 +658,34 @@
> >> >    @Override
> >> >    public TermDocs termDocs() throws IOException {
> >> >      ensureOpen();
> >> > -    return new MultiTermDocs(this, subReaders, starts);
> >> > +    if (subReaders.length == 1) {
> >> > +      // Optimize single segment case:
> >> > +      return subReaders[0].termDocs();
> >> > +    } else {
> >> > +      return new MultiTermDocs(this, subReaders, starts);
> >> > +    }
> >> > +  }
> >> > +
> >> > +  @Override
> >> > +  public TermDocs termDocs(Term term) throws IOException {
> >> > +    ensureOpen();
> >> > +    if (subReaders.length == 1) {
> >> > +      // Optimize single segment case:
> >> > +      return subReaders[0].termDocs(term);
> >> > +    } else {
> >> > +      return super.termDocs(term);
> >> > +    }
> >> >    }
> >> >
> >> >    @Override
> >> >    public TermPositions termPositions() throws IOException {
> >> >      ensureOpen();
> >> > -    return new MultiTermPositions(this, subReaders, starts);
> >> > +    if (subReaders.length == 1) {
> >> > +      // Optimize single segment case:
> >> > +      return subReaders[0].termPositions();
> >> > +    } else {
> >> > +      return new MultiTermPositions(this, subReaders, starts);
> >> > +    }
> >> >    }
> >> >
> >> >    /**
> >> >
> >> > Modified:
> >> > lucene/java/trunk/src/java/org/apache/lucene/index/MultiReader.java
> >> > URL:
> >> >
> >>
> http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/
> >> > index/MultiReader.java?rev=888398&r1=888397&r2=888398&view=diff
> >> >
> >>
> ==========================================================================
> >> > ====
> >> > ---
> lucene/java/trunk/src/java/org/apache/lucene/index/MultiReader.java
> >> > (original)
> >> > +++
> lucene/java/trunk/src/java/org/apache/lucene/index/MultiReader.java
> >> > Tue Dec  8 13:47:20 2009
> >> > @@ -339,13 +339,23 @@
> >> >    @Override
> >> >    public TermEnum terms() throws IOException {
> >> >      ensureOpen();
> >> > -    return new MultiTermEnum(this, subReaders, starts, null);
> >> > +    if (subReaders.length == 1) {
> >> > +      // Optimize single segment case:
> >> > +      return subReaders[0].terms();
> >> > +    } else {
> >> > +      return new MultiTermEnum(this, subReaders, starts, null);
> >> > +    }
> >> >    }
> >> >
> >> >    @Override
> >> >    public TermEnum terms(Term term) throws IOException {
> >> >      ensureOpen();
> >> > -    return new MultiTermEnum(this, subReaders, starts, term);
> >> > +    if (subReaders.length == 1) {
> >> > +      // Optimize single segment case:
> >> > +      return subReaders[0].terms(term);
> >> > +    } else {
> >> > +      return new MultiTermEnum(this, subReaders, starts, term);
> >> > +    }
> >> >    }
> >> >
> >> >    @Override
> >> > @@ -360,13 +370,34 @@
> >> >    @Override
> >> >    public TermDocs termDocs() throws IOException {
> >> >      ensureOpen();
> >> > -    return new MultiTermDocs(this, subReaders, starts);
> >> > +    if (subReaders.length == 1) {
> >> > +      // Optimize single segment case:
> >> > +      return subReaders[0].termDocs();
> >> > +    } else {
> >> > +      return new MultiTermDocs(this, subReaders, starts);
> >> > +    }
> >> > +  }
> >> > +
> >> > +  @Override
> >> > +  public TermDocs termDocs(Term term) throws IOException {
> >> > +    ensureOpen();
> >> > +    if (subReaders.length == 1) {
> >> > +      // Optimize single segment case:
> >> > +      return subReaders[0].termDocs(term);
> >> > +    } else {
> >> > +      return super.termDocs(term);
> >> > +    }
> >> >    }
> >> >
> >> >    @Override
> >> >    public TermPositions termPositions() throws IOException {
> >> >      ensureOpen();
> >> > -    return new MultiTermPositions(this, subReaders, starts);
> >> > +    if (subReaders.length == 1) {
> >> > +      // Optimize single segment case:
> >> > +      return subReaders[0].termPositions();
> >> > +    } else {
> >> > +      return new MultiTermPositions(this, subReaders, starts);
> >> > +    }
> >> >    }
> >> >
> >> >    @Override
> >> >
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]
> >> For additional commands, e-mail: [hidden email]
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r888398 - in /lucene/java/trunk: CHANGES.txt contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java src/java/org/apache/lucene/index/DirectoryReader.java src/java/org/apache/lucene/index/MultiReader.java

Michael McCandless-2
Aaaahh, right.  OK thanks for putting it back.  And I'll add a test
over on flex to assert this.

Mike

On Tue, Dec 8, 2009 at 10:28 AM, Uwe Schindler <[hidden email]> wrote:

> It is defined to be null.
>
> Because the enums in trunk are positioned on the first term (because
> IR.terms(Term) positions the enum on the first term, if the term does not
> exist, it must be null, else you cannot detect that the enum is empty).
> Because of that you have the do-while loops in trunk!
>
> In flex, the enum is unpositioned and you always have to call next() first.
> In flex it behaves as it should, but in trunk its not intuitive.
>
> See e.g. FieldCache or MTQ in trunk, the loops are different!
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: [hidden email]
>
>
>> -----Original Message-----
>> From: Michael McCandless [mailto:[hidden email]]
>> Sent: Tuesday, December 08, 2009 4:25 PM
>> To: [hidden email]
>> Subject: Re: svn commit: r888398 - in /lucene/java/trunk: CHANGES.txt
>> contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
>> src/java/org/apache/lucene/index/DirectoryReader.java
>> src/java/org/apache/lucene/index/MultiReader.java
>>
>> Sorry, right, test passed on trunk, but it's still not valid even on
>> trunk (I think?).  Ie TermEnum.term() is undefined until you've called
>> next?
>>
>> Mike
>>
>> On Tue, Dec 8, 2009 at 10:18 AM, Uwe Schindler <[hidden email]> wrote:
>> > Mike I checked,
>> >
>> > it seems that you simply copied the code from flex, where the test must
>> be
>> > removed.
>> >
>> > In trunk, I'll revert, test passes correctly. I was a little bit
>> confused,
>> > why it should not pass.
>> >
>> > -----
>> > Uwe Schindler
>> > H.-H.-Meier-Allee 63, D-28213 Bremen
>> > http://www.thetaphi.de
>> > eMail: [hidden email]
>> >
>> >
>> >> -----Original Message-----
>> >> From: Uwe Schindler [mailto:[hidden email]]
>> >> Sent: Tuesday, December 08, 2009 4:00 PM
>> >> To: [hidden email]
>> >> Subject: RE: svn commit: r888398 - in /lucene/java/trunk: CHANGES.txt
>> >>
>> contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
>> >> src/java/org/apache/lucene/index/DirectoryReader.java
>> >> src/java/org/apache/lucene/index/MultiReader.java
>> >>
>> >> Mike,
>> >>
>> >> the test for RegEx was correct, it uses getEnum() not getTermsEnum()!
>> So
>> >> the
>> >> first term returned must be null, because the enum must be positioned
>> on
>> >> the
>> >> first term (which was the case for old enums). If that is not the case
>> >> such
>> >> a query would at least hit one term. So in trunk this test is perfectly
>> >> legal and important!
>> >>
>> >> -----
>> >> Uwe Schindler
>> >> H.-H.-Meier-Allee 63, D-28213 Bremen
>> >> http://www.thetaphi.de
>> >> eMail: [hidden email]
>> >>
>> >>
>> >> > -----Original Message-----
>> >> > From: [hidden email] [mailto:[hidden email]]
>> >> > Sent: Tuesday, December 08, 2009 2:47 PM
>> >> > To: [hidden email]
>> >> > Subject: svn commit: r888398 - in /lucene/java/trunk: CHANGES.txt
>> >> >
>> >>
>> contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
>> >> > src/java/org/apache/lucene/index/DirectoryReader.java
>> >> > src/java/org/apache/lucene/index/MultiReader.java
>> >> >
>> >> > Author: mikemccand
>> >> > Date: Tue Dec  8 13:47:20 2009
>> >> > New Revision: 888398
>> >> >
>> >> > URL: http://svn.apache.org/viewvc?rev=888398&view=rev
>> >> > Log:
>> >> > LUCENE-2136: optimization: if Multi/DirectoryReader only has a single
>> >> > reader, delegate enums to it
>> >> >
>> >> > Modified:
>> >> >     lucene/java/trunk/CHANGES.txt
>> >> >
>> >> >
>> >>
>> lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/Te
>> >> > stRegexQuery.java
>> >> >
>> >> >
>> lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
>> >> >
>> lucene/java/trunk/src/java/org/apache/lucene/index/MultiReader.java
>> >> >
>> >> > Modified: lucene/java/trunk/CHANGES.txt
>> >> > URL:
>> >> >
>> >>
>> http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=888398&r1=8
>> >> > 88397&r2=888398&view=diff
>> >> >
>> >>
>> ==========================================================================
>> >> > ====
>> >> > --- lucene/java/trunk/CHANGES.txt (original)
>> >> > +++ lucene/java/trunk/CHANGES.txt Tue Dec  8 13:47:20 2009
>> >> > @@ -70,6 +70,11 @@
>> >> >    lots of seeking (Mike McCandless, Uwe Schindler, Robert Muir,
>> Yonik
>> >> >    Seeley)
>> >> >
>> >> > +* LUCENE-2136: If the multi reader (DirectoryReader or MultiReader)
>> >> > +  only has a single sub-reader, delegate all enum requests to it.
>> >> > +  This avoid the overhead of using a PQ unecessarily.  (Mike
>> >> > +  McCandless)
>> >> > +
>> >> >  Build
>> >> >
>> >> >  Test Cases
>> >> >
>> >> > Modified:
>> >> >
>> >>
>> lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/Te
>> >> > stRegexQuery.java
>> >> > URL:
>> >> >
>> >>
>> http://svn.apache.org/viewvc/lucene/java/trunk/contrib/regex/src/test/org/
>> >> >
>> >>
>> apache/lucene/search/regex/TestRegexQuery.java?rev=888398&r1=888397&r2=888
>> >> > 398&view=diff
>> >> >
>> >>
>> ==========================================================================
>> >> > ====
>> >> > ---
>> >> >
>> >>
>> lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/Te
>> >> > stRegexQuery.java (original)
>> >> > +++
>> >> >
>> >>
>> lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/Te
>> >> > stRegexQuery.java Tue Dec  8 13:47:20 2009
>> >> > @@ -83,7 +83,6 @@
>> >> >    public void testMatchAll() throws Exception {
>> >> >      TermEnum terms = new RegexQuery(new Term(FN,
>> >> > "jum.")).getEnum(searcher.getIndexReader());
>> >> >      // no term should match
>> >> > -    assertNull(terms.term());
>> >> >      assertFalse(terms.next());
>> >> >    }
>> >> >
>> >> >
>> >> > Modified:
>> >> >
>> lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
>> >> > URL:
>> >> >
>> >>
>> http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/
>> >> > index/DirectoryReader.java?rev=888398&r1=888397&r2=888398&view=diff
>> >> >
>> >>
>> ==========================================================================
>> >> > ====
>> >> > ---
>> >> >
>> lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
>> >> > (original)
>> >> > +++
>> >> >
>> lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryReader.java
>> >> > Tue Dec  8 13:47:20 2009
>> >> > @@ -627,13 +627,23 @@
>> >> >    @Override
>> >> >    public TermEnum terms() throws IOException {
>> >> >      ensureOpen();
>> >> > -    return new MultiTermEnum(this, subReaders, starts, null);
>> >> > +    if (subReaders.length == 1) {
>> >> > +      // Optimize single segment case:
>> >> > +      return subReaders[0].terms();
>> >> > +    } else {
>> >> > +      return new MultiTermEnum(this, subReaders, starts, null);
>> >> > +    }
>> >> >    }
>> >> >
>> >> >    @Override
>> >> >    public TermEnum terms(Term term) throws IOException {
>> >> >      ensureOpen();
>> >> > -    return new MultiTermEnum(this, subReaders, starts, term);
>> >> > +    if (subReaders.length == 1) {
>> >> > +      // Optimize single segment case:
>> >> > +      return subReaders[0].terms(term);
>> >> > +    } else {
>> >> > +      return new MultiTermEnum(this, subReaders, starts, term);
>> >> > +    }
>> >> >    }
>> >> >
>> >> >    @Override
>> >> > @@ -648,13 +658,34 @@
>> >> >    @Override
>> >> >    public TermDocs termDocs() throws IOException {
>> >> >      ensureOpen();
>> >> > -    return new MultiTermDocs(this, subReaders, starts);
>> >> > +    if (subReaders.length == 1) {
>> >> > +      // Optimize single segment case:
>> >> > +      return subReaders[0].termDocs();
>> >> > +    } else {
>> >> > +      return new MultiTermDocs(this, subReaders, starts);
>> >> > +    }
>> >> > +  }
>> >> > +
>> >> > +  @Override
>> >> > +  public TermDocs termDocs(Term term) throws IOException {
>> >> > +    ensureOpen();
>> >> > +    if (subReaders.length == 1) {
>> >> > +      // Optimize single segment case:
>> >> > +      return subReaders[0].termDocs(term);
>> >> > +    } else {
>> >> > +      return super.termDocs(term);
>> >> > +    }
>> >> >    }
>> >> >
>> >> >    @Override
>> >> >    public TermPositions termPositions() throws IOException {
>> >> >      ensureOpen();
>> >> > -    return new MultiTermPositions(this, subReaders, starts);
>> >> > +    if (subReaders.length == 1) {
>> >> > +      // Optimize single segment case:
>> >> > +      return subReaders[0].termPositions();
>> >> > +    } else {
>> >> > +      return new MultiTermPositions(this, subReaders, starts);
>> >> > +    }
>> >> >    }
>> >> >
>> >> >    /**
>> >> >
>> >> > Modified:
>> >> > lucene/java/trunk/src/java/org/apache/lucene/index/MultiReader.java
>> >> > URL:
>> >> >
>> >>
>> http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/
>> >> > index/MultiReader.java?rev=888398&r1=888397&r2=888398&view=diff
>> >> >
>> >>
>> ==========================================================================
>> >> > ====
>> >> > ---
>> lucene/java/trunk/src/java/org/apache/lucene/index/MultiReader.java
>> >> > (original)
>> >> > +++
>> lucene/java/trunk/src/java/org/apache/lucene/index/MultiReader.java
>> >> > Tue Dec  8 13:47:20 2009
>> >> > @@ -339,13 +339,23 @@
>> >> >    @Override
>> >> >    public TermEnum terms() throws IOException {
>> >> >      ensureOpen();
>> >> > -    return new MultiTermEnum(this, subReaders, starts, null);
>> >> > +    if (subReaders.length == 1) {
>> >> > +      // Optimize single segment case:
>> >> > +      return subReaders[0].terms();
>> >> > +    } else {
>> >> > +      return new MultiTermEnum(this, subReaders, starts, null);
>> >> > +    }
>> >> >    }
>> >> >
>> >> >    @Override
>> >> >    public TermEnum terms(Term term) throws IOException {
>> >> >      ensureOpen();
>> >> > -    return new MultiTermEnum(this, subReaders, starts, term);
>> >> > +    if (subReaders.length == 1) {
>> >> > +      // Optimize single segment case:
>> >> > +      return subReaders[0].terms(term);
>> >> > +    } else {
>> >> > +      return new MultiTermEnum(this, subReaders, starts, term);
>> >> > +    }
>> >> >    }
>> >> >
>> >> >    @Override
>> >> > @@ -360,13 +370,34 @@
>> >> >    @Override
>> >> >    public TermDocs termDocs() throws IOException {
>> >> >      ensureOpen();
>> >> > -    return new MultiTermDocs(this, subReaders, starts);
>> >> > +    if (subReaders.length == 1) {
>> >> > +      // Optimize single segment case:
>> >> > +      return subReaders[0].termDocs();
>> >> > +    } else {
>> >> > +      return new MultiTermDocs(this, subReaders, starts);
>> >> > +    }
>> >> > +  }
>> >> > +
>> >> > +  @Override
>> >> > +  public TermDocs termDocs(Term term) throws IOException {
>> >> > +    ensureOpen();
>> >> > +    if (subReaders.length == 1) {
>> >> > +      // Optimize single segment case:
>> >> > +      return subReaders[0].termDocs(term);
>> >> > +    } else {
>> >> > +      return super.termDocs(term);
>> >> > +    }
>> >> >    }
>> >> >
>> >> >    @Override
>> >> >    public TermPositions termPositions() throws IOException {
>> >> >      ensureOpen();
>> >> > -    return new MultiTermPositions(this, subReaders, starts);
>> >> > +    if (subReaders.length == 1) {
>> >> > +      // Optimize single segment case:
>> >> > +      return subReaders[0].termPositions();
>> >> > +    } else {
>> >> > +      return new MultiTermPositions(this, subReaders, starts);
>> >> > +    }
>> >> >    }
>> >> >
>> >> >    @Override
>> >> >
>> >>
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: [hidden email]
>> >> For additional commands, e-mail: [hidden email]
>> >
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [hidden email]
>> > For additional commands, e-mail: [hidden email]
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r888398 - in /lucene/java/trunk: CHANGES.txt contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java src/java/org/apache/lucene/index/DirectoryReader.java src/java/org/apache/lucene/index/MultiReader.java

Yonik Seeley-2-2
In reply to this post by Michael McCandless-2
On Tue, Dec 8, 2009 at 10:25 AM, Michael McCandless
<[hidden email]> wrote:
> Sorry, right, test passed on trunk, but it's still not valid even on
> trunk (I think?).  Ie TermEnum.term() is undefined until you've called
> next?

You're thinking TermDocs I think - TermEnum.term() is defined to be
positioned on or after the term given during it's creation.

-Yonik
http://www.lucidimagination.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: svn commit: r888398 - in /lucene/java/trunk: CHANGES.txt contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java src/java/org/apache/lucene/index/DirectoryReader.java src/java/org/apache/lucene/index/MultiReader.java

Uwe Schindler
Yes, exactly.

The problem is that in flex we made it more intuitive and iterator-like, it
always works identical - call next() or seek() first, before that it is
undefined. So you always have to think about - is it flex or is it trunk.

We should get flex in as fast as possible :-) but we still have some
problems.

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: [hidden email]


> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf Of Yonik
> Seeley
> Sent: Tuesday, December 08, 2009 4:31 PM
> To: [hidden email]
> Subject: Re: svn commit: r888398 - in /lucene/java/trunk: CHANGES.txt
> contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
> src/java/org/apache/lucene/index/DirectoryReader.java
> src/java/org/apache/lucene/index/MultiReader.java
>
> On Tue, Dec 8, 2009 at 10:25 AM, Michael McCandless
> <[hidden email]> wrote:
> > Sorry, right, test passed on trunk, but it's still not valid even on
> > trunk (I think?).  Ie TermEnum.term() is undefined until you've called
> > next?
>
> You're thinking TermDocs I think - TermEnum.term() is defined to be
> positioned on or after the term given during it's creation.
>
> -Yonik
> http://www.lucidimagination.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r888398 - in /lucene/java/trunk: CHANGES.txt contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java src/java/org/apache/lucene/index/DirectoryReader.java src/java/org/apache/lucene/index/MultiReader.java

Michael McCandless-2
In reply to this post by Yonik Seeley-2-2
On Tue, Dec 8, 2009 at 10:31 AM, Yonik Seeley
<[hidden email]> wrote:
> On Tue, Dec 8, 2009 at 10:25 AM, Michael McCandless
> <[hidden email]> wrote:
>> Sorry, right, test passed on trunk, but it's still not valid even on
>> trunk (I think?).  Ie TermEnum.term() is undefined until you've called
>> next?
>
> You're thinking TermDocs I think - TermEnum.term() is defined to be
> positioned on or after the term given during it's creation.

Right, and if that term was beyond the end of all terms, .term() must
return null in the TermEnum returned to you.

Flipping between flex & not is getting tricky :)

Mike

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]