You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Mike Streeton <mi...@ardentiasearch.com> on 2007/11/05 13:42:23 UTC

Reuse TermDocs

Can TermDocs be reused i.e. can you do.

TermDocs docs = reader.termDocs();
docs.seek(term1);
int i = 0;
while (docs.next()) {
        i++;
}
docs.seek(term2);
int j = 0;
while (docs.next()) {
        j++;
}

Reuse does seem to work but I get ArrayIndexOutOfBoundsExceptions from BitVector it I reuse the same one over a period of time.

Many Thanks

Mike

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Reuse TermDocs

Posted by Yonik Seeley <yo...@apache.org>.
On 11/5/07, Mike Streeton <mi...@ardentiasearch.com> wrote:
> Can TermDocs be reused i.e. can you do.
>
> TermDocs docs = reader.termDocs();
> docs.seek(term1);
> int i = 0;
> while (docs.next()) {
>         i++;
> }
> docs.seek(term2);
> int j = 0;
> while (docs.next()) {
>         j++;
> }
>
> Reuse does seem to work but I get ArrayIndexOutOfBoundsExceptions from BitVector it I reuse the same one over a period of time.

That shouldn't happen... your reuse looks fine.
TermDocs instances are not thread safe - I assume you are only reusing
it from a single thread?
Is it possible for you to create a test case that reproduces this?

-Yonik

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org