Return-Path: Mailing-List: contact lucene-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list lucene-dev@jakarta.apache.org Received: (qmail 60550 invoked from network); 15 Sep 2003 14:27:29 -0000 Received: from unknown (HELO c000.snv.cp.net) (209.228.32.65) by daedalus.apache.org with SMTP; 15 Sep 2003 14:27:29 -0000 Received: (cpmta 17104 invoked from network); 15 Sep 2003 07:27:28 -0700 Received: from 68.232.145.115 (HELO ehatchersolutions.com) by smtp.hatcher.net (209.228.32.65) with SMTP; 15 Sep 2003 07:27:28 -0700 X-Sent: 15 Sep 2003 14:27:28 GMT Date: Mon, 15 Sep 2003 10:27:27 -0400 Subject: Re: RE : DateFilter.Before/After Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v552) From: Erik Hatcher To: "Lucene Developers List" Content-Transfer-Encoding: 7bit In-Reply-To: <3F65C294.5030008@jivesoftware.com> Message-Id: X-Mailer: Apple Mail (2.552) X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N On Monday, September 15, 2003, at 09:45 AM, Bruce Ritchie wrote: > I would suggest *not* using caching inside of filters provided by > lucene but rather provide a wrapper to do the caching. The reason is > that some applications really don't want the libraries they use to be > a source of concern for memory usage. i.e. if I search for a string > using 10,000 different date filters (an extreme example, but possible) > I want the ability to control how those bitsets are going to be > cached. In the case of QueryFilter, simply construct a new one to avoid caching rather than reuse the same instance. So you have control there as well. The only thing that is cached is a BitSet, so it should be much of a memory usage concern. > public class CachedFilter extends Filter { > BitSet bits; > Filter filter; > > public CachedFilter(Filter filter) { > this.filter = filter; > this.bits = null; > } > > public BitSet bits(IndexReader reader) throws IOException { > if (bits != null) { > return bits; > } > > bits = filter.bits(reader); > return bits; > } > } You would have problems if you searched a different index or different instance of IndexReader even with your caching here. You should cache like QueryFilter does to avoid a potential mismatch with IndexReader instances. But you're implementation is exactly what I was envisioning with the added WeakHashMap of QueryFilter. Erik