On 12/11/2009, at 8:42 PM, Michael McCandless wrote:

On Wed, Nov 11, 2009 at 7:33 PM, Jacob Rhoden <jrho...@unimelb.edu.au> wrote:
The source code for SearcherManager is even downloadable for free:
  http://www.manning.com/hatcher3/LIAsourcecode.zip

The example source code does some things that is beyond my level of
understanding

After staring it it a bit longer, it mostly makes sense to me now, the example for book
was only hard to read because I don't understand completely what both
IndexWriter.IndexReaderWarmer() and searcher.getIndexReader().decRef()
are supposed to do. (Which I assume can be learnt from the book)

Any already in-flight searches will continue to use the old
IndexSearcher, while new ones use the new IndexSearcher.  Once all
in-flight searches are done against the old IndexSearcher, its
underlying IndexReader is closed.

To test I understand this correctly, the index reader getting closed automatically is achieved by the release() method calling searcher.getIndexReader().decRef()?

So I am going for something a bit simpler:

If a thread wants to use the "SafeIndexSearcher", it first calls retain()
and then calls
release() when its done.

I think this will work, but you need a central place that has called
retain() and is holding onto the searcher, until it's time to reopen
right?  Either that, or your retainCount begins life at 1 instead of
0?

In my version, the "SafeIndexSearcher" is a static variable, the retain
count starts at 0. Being at zero simply indicates the object is not being
used and can safely be closed.

Also, how will you handle reopening (if that's needed in your app)?


Another thread runs in the background and handles deciding when to do
an index rebuild, at which point it
1) swaps in a new "SafeIndexSearcher"
2) calls close on the old "SafeIndexSearcher" (which will safely close once the retain count=0)

Thanks,
Jacob

____________________________________
Information Technology Services,
The University of Melbourne

Email: jrho...@unimelb.edu.au
Phone: +61 3 8344 2884
Mobile: +61 4 1095 7575


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

Reply via email to