lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <luc...@mikemccandless.com>
Subject Re: Is there a way to share IndexReader data sensibly across independent callers?
Date Tue, 09 Feb 2016 16:17:26 GMT
Why do you need to close the Directory?  It should be light weight.
But if you really do need it, can't you subclass ReaderManager and
override afterClose to close the directory?

So you essentially need to "lazy close" your ReaderManager, when there
are no searches currently needing it?

Why not have a sync'd block, with a reference to the ReaderManager.
Inside that block, if the reference is null, that means it's closed,
and you open a new one.  Else, use the existing one.  Won't that do
what you need w/o requiring full fledged reference counts?  Yes, it is
a sync'd block around acquire/release, but I don't see how that can be
avoided, and it'd be fast when the ReaderManager is already opened.

Mike McCandless

http://blog.mikemccandless.com


On Tue, Feb 9, 2016 at 6:39 AM, Trejkaz <trejkaz@trypticon.org> wrote:
> On Tue, Feb 9, 2016 at 7:59 PM, Michael McCandless
> <lucene@mikemccandless.com> wrote:
>> Can't you just call ReaderManager.close?
>>
>> All in-flight operations with that RM will keep working, and the
>> underlying reader will only finally close once they have all finished.
>
> I guess that has the caveat that it would be possible to have two
> readers open on the same directory, which is mostly what I was trying
> to avoid. My current solution absolutely prevents that, at the cost of
> having to synchronise when acquiring or releasing, although I can
> probably use double-checked locking to reduce the impact of that.
>
> Really what would be handy is something that resembles ReaderManager
> but takes Path for every method and also opens and closes the
> Directory...
>
> TX
>
> ---------------------------------------------------------------------
> 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