Wrong Reader ;)

- Mark

http://www.lucidimagination.com (mobile)

On Sep 26, 2009, at 11:14 PM, John Wang <john.w...@gmail.com> wrote:

AFAIK, application has always assume the responsibility of closing IndexReader instances.

However, with 2.9, this is the first time, IndexReader can be instantiated via a getter from IndexWriter.

Previously, IndexReaders are usually constructed via IndexReader.open factory method. Having a getter on an IndexWriter makes it unclear from the API point of view.

IndexReader instances are encapsulated inside IndexWriters, and IndexWriters sort of own the IndexReaders, which can be a good thing: IndexWriter may want to pool these IndexReader instances etc.

Of course, this is nothing some simple JavaDoc can't fix :)

My $0.02

-John

On Fri, Sep 25, 2009 at 11:41 PM, Daniel Shane <sha...@lexum.umontreal.ca > wrote: Thanks Mark for the pointer, I thought somehow that lucene closed them as a convenience, I don't know if it did that in previous releases (aka 2.4.1) but I'll close them myself from now on.

Daniel Shane


Mark Miller wrote:
Standard convention is that you close our own readers, not the methods
you pass them into.

Daniel Shane wrote:

I'm trying to track a bug in my application using Lucene rc5, its
regarding Readers. I've noticed that when I index, not every reader
gets closed, so I eventually run out of avail. fd's.

Before trying to reproduce this problem using the smallest code
possible, I'd like to know if lucene is supposed to close every reader
in a Document after the IndexWriter.updateDocument(Term, Document) has
been called?

Is there a path where lucene may "wait" before closing the readers?
Maybe after it indexes some other documents?

In my case, I am using one Reader in my field and it is a
BufferedReader(), but I don't think that should make any difference
(I'll re-try with a standard reader).

Can someone confirm that after an updateDocument all readers in the
document should be closed by lucene?

Daniel Shane



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







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


Reply via email to