lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simon Willnauer" <simon.willna...@googlemail.com>
Subject Re: How to tell if IndexSearcher/IndexReader was closed?
Date Tue, 26 Sep 2006 10:51:05 GMT
I guess there are many possibilities to implement some control
structure to track the references to your searcher / reader. As it is
best practice to have one single searcher open you can track the
reference to the searcher while one reference is hold by the class you
request your searcher from. If you close your searcher you decrement
the reference which is hold by the, I will call it "controller", class
and create a new searcher. If no reference to the searcher is
remaining you close the searcher and it will get garbage collected.

If you use this kind of pattern you might have more than one searcher
open for a short time. but if the last "search client" has decremented
the reference the searcher will be closed. You don't have to care
whether the searcher is closed or not, you won't get a reference to a
closed searcher instance.

Solr and GData Server uses this kind of reference tracking for this purpose.

have a look at http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/utils/ReferenceCounter.java?view=markup


best regards Simon
On 9/26/06, Frank Kunemann <frank.kunemann@innosystec.de> wrote:
> Hi all,
>
> after I delete some entries from the index, I close the IndexSearcher to
> ensure that the changes are done.
> But after this I couldn't figure out a way to tell if the searcher is closed
> or not.
> Any ideas?
>
>
> Regards
> Frank
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

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


Mime
View raw message