lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luke Francl <luke.fra...@stellent.com>
Subject Re: Index File
Date Mon, 15 Nov 2004 17:18:54 GMT
As long as you are closing your IndexSearchers when you are done with
them you should not have problems with file handles. When using Lucene
1.2 (pre-compound file format) on Windows, I ran into this problem
because Windows only lets an application open something like 1000 file
handles. On Unix the number is larger.

To calculate the cost of creating a new IndexSearcher for each search,
just put a timing statement around your call to IndexSearcher.open and
IndexSearcher.close. Your performance cost is the time used when opening
and closing unnecessarily.

Here is a description of the scheme I used to manage this issue:

"Creating a new IndexSearcher for every request opens too many
files. Searchers are thread-safe, so it is good to keep only one
Searcher open at a time. However, we must create a new Searcher if
the index has changed, and it is not safe to close a Searcher while
it is still in use by a thread. The SearcherManager handles these
cases.

The SearcherManager keeps a list of the Searchers which are
currently in use and returns the the current one, or a new one if
necessary. The SearcherManager uses a reference counting scheme to
keep track of which Searchers are still being used. Callers must
return their Searcher to the SearcherManager when done using it so
the Searcher can be closed (releasing its filehandles) if no other
threads are using it and the index has changed."


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


Mime
View raw message