Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 26176 invoked from network); 12 Nov 2009 09:42:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 12 Nov 2009 09:42:45 -0000 Received: (qmail 62755 invoked by uid 500); 12 Nov 2009 09:42:43 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 62672 invoked by uid 500); 12 Nov 2009 09:42:42 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 62662 invoked by uid 99); 12 Nov 2009 09:42:41 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Nov 2009 09:42:41 +0000 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.211.183] (HELO mail-yw0-f183.google.com) (209.85.211.183) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Nov 2009 09:42:31 +0000 Received: by ywh13 with SMTP id 13so2308893ywh.29 for ; Thu, 12 Nov 2009 01:42:10 -0800 (PST) MIME-Version: 1.0 Received: by 10.150.26.5 with SMTP id 5mr4816904ybz.228.1258018929904; Thu, 12 Nov 2009 01:42:09 -0800 (PST) In-Reply-To: <6EE19AEC-1763-413D-BE80-6B4E2D932E12@unimelb.edu.au> References: <359a92830911111453o1adfd89cy5a2bc3fd9e62273a@mail.gmail.com> <6EE19AEC-1763-413D-BE80-6B4E2D932E12@unimelb.edu.au> Date: Thu, 12 Nov 2009 04:42:09 -0500 Message-ID: <9ac0c6aa0911120142l4bf00ef6tda78d6448a0284a4@mail.gmail.com> Subject: Re: Wrapping IndexSearcher so that it is safe? From: Michael McCandless To: java-user@lucene.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On Wed, Nov 11, 2009 at 7:33 PM, Jacob Rhoden wrot= e: > The source code for SearcherManager is even downloadable for free: > =A0 http://www.manning.com/hatcher3/LIAsourcecode.zip > > The example source code does some things that is beyond my level of > understanding > of lucene. ie: > 1) To me it looks like an IndexSearcher never gets closed. It's true that IndexSearcher isn't closed, but it turns out (for now, at least), it's not necessary to close IndexSearcher if you had passed it an already open IndexReader. > 2) I don't understand what happens if the indexreader is reopened while a > thread > =A0 =A0in the middle of a search using an indexsearcher. 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. > 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. > > If a thread wants to close the "SafeIndexSearcher" , the close is deferre= d > until all threads > have called release(): 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? Also, how will you handle reopening (if that's needed in your app)? Mike --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org