Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 35670 invoked from network); 15 Oct 2008 17:48:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Oct 2008 17:48:59 -0000 Received: (qmail 99741 invoked by uid 500); 15 Oct 2008 17:48:53 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 99712 invoked by uid 500); 15 Oct 2008 17:48:53 -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 99700 invoked by uid 99); 15 Oct 2008 17:48:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Oct 2008 10:48:53 -0700 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [66.249.82.226] (HELO wx-out-0506.google.com) (66.249.82.226) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Oct 2008 17:47:46 +0000 Received: by wx-out-0506.google.com with SMTP id h28so904445wxd.20 for ; Wed, 15 Oct 2008 10:48:22 -0700 (PDT) Received: by 10.70.113.12 with SMTP id l12mr1421815wxc.24.1224092902280; Wed, 15 Oct 2008 10:48:22 -0700 (PDT) Received: from ?10.17.4.4? (pool-96-237-252-30.bstnma.fios.verizon.net [96.237.252.30]) by mx.google.com with ESMTPS id i18sm44779wxd.24.2008.10.15.10.48.20 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 15 Oct 2008 10:48:20 -0700 (PDT) Message-Id: <68C36A6A-9107-48A6-9DCC-74CA92B9CF0E@mikemccandless.com> From: Michael McCandless To: java-user@lucene.apache.org In-Reply-To: <6d6cf45b0810151029w192c16f5kf869d267f3194c17@mail.gmail.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v929.2) Subject: Re: Closing Index Reader Date: Wed, 15 Oct 2008 13:48:19 -0400 References: <6d6cf45b0810141935j4d7fb29cj6e323b40a39d8381@mail.gmail.com> <01c701c92ea4$0c063f20$330bc30a@sv.us.sonicwall.com> <3499CAC1-6382-4EDE-BDCC-9A952A39A742@mikemccandless.com> <01cf01c92ead$566131c0$330bc30a@sv.us.sonicwall.com> <6d6cf45b0810151029w192c16f5kf869d267f3194c17@mail.gmail.com> X-Mailer: Apple Mail (2.929.2) X-Virus-Checked: Checked by ClamAV on apache.org That is correct, as long as you incRef the reader before starting each query, and decRef the reader after finishing each query. If you call close() during this time, the reader is not actually closed until decRef is called for all previous incRefs. Be certain that once you close() a reader there is no way a new query can grab that reader. That would be a thread hazard that could result in using an already closed reader. Also be certain you always decRef, eg in a finally clause. Mike Khawaja Shams wrote: > Hello, Thank you for your ideas. While these look promising, it > seems like > there are many places within Lucene's codebase that are invoking the > incRef > and decRef methods. Upon a shallow analysis of the code, it seems > like I > can call close, and the doClose method does not get called until > refCount is > 0. Can anyone correct or confirm my assumption that you can call > close and > any query in progress as you call close will succeed because the > reader > won't be closed until the refCount is 0. Thanks again! > > On Wed, Oct 15, 2008 at 3:10 AM, Michael McCandless < > lucene@mikemccandless.com> wrote: > >> >> As of 2.4.0 they are public. >> >> Mike >> >> >> Ganesh wrote: >> >> incRef/decRef methods are protected. Is there any other way to use >> these >>> methods without extending it? >>> >>> Regards >>> Ganesh >>> >>> ----- Original Message ----- From: "Michael McCandless" < >>> lucene@mikemccandless.com> >>> To: >>> Sent: Wednesday, October 15, 2008 2:31 PM >>> Subject: Re: Closing Index Reader >>> >>> >>> >>>> Ganesh wrote: >>>> >>>> Yes. Once the Indexreader is closed, you should not do make any >>>> calls >>>>> with that object. >>>>> Extend the IndexReader to add support for reference count. Close >>>>> the >>>>> reader once the count is zero. >>>>> >>>> >>>> Actually you can just use the [expert] incRef/decRef methods on >>>> IndexReader to track in-flight searches still using it. You >>>> shouldn't have >>>> to extend it. >>>> >>>> Mike >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org >>>> For additional commands, e-mail: java-user-help@lucene.apache.org >>>> >>> >>> Send instant messages to your online friends >>> http://in.messenger.yahoo.com >>> --------------------------------------------------------------------- >>> 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 >> >> --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org