lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vanlerberghe, Luc" <>
Subject RE: Renewing IndexSearcher on index change.
Date Tue, 04 Oct 2005 18:28:28 GMT
I've just posted the solution I use as a jira attachment.


It was designed to be used in a multithread environment (tomcat)
It contains javadoc to explain the usage.

It extends IndexSearcher since that is the object that searches are
executed against.

So an application module that needs to execute a search does:
IndexSearcher searcher=searcherFactory.createSearch();;
... handle results

The factory actually returns the same DelayCloseIndexSearcher over and
over until it determines the index has changed.  It then calls
closeWhenDone() and initialises a new instance.  (In my application, a
separate thread does this, the old instance still gets used until the
new one is fully initialised)

Feedback would be much appreciated!



P.s.: finalize() should not be relied on since ther's no way to know
when it will be called (if ever).  it could be used to detect bugs, but
even just adding a finalize() method actually creates some overhead (at
least in the sun VM) and may keep objects in memory longer than they
would without it.

-----Original Message-----
From: Olivier Jaquemet [] 
Sent: dinsdag 4 oktober 2005 18:39
Subject: Re: Renewing IndexSearcher on index change.

Volodymyr Bychkoviak wrote:

> I'm using following code during program startup 


> but this method should be used if you are running only one instance of

> such program (because one program can unlock index locked by another 
> program for indexing for example)
Okay this perfect for our application as only one instance can be 
launched at the same time. thank you very much.

In every case I think I will use this to prevent any problem but why 
nobody uses finalize methods? is it somehow bad to try to close things 
correctly that way?


To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message