Re: Optimization of memory usage in PriorityQueue

2009-06-23 Thread Simon Willnauer
? > Thanks! > > >> Date: Tue, 23 Jun 2009 06:49:00 -0400 >> Subject: Re: Optimization of memory usage in PriorityQueue >> From: luc...@mikemccandless.com >> To: java-dev@lucene.apache.org >> >> OK I've added a NOTE to the javadocs for this... >> &

RE: Optimization of memory usage in PriorityQueue

2009-06-23 Thread Claudio .
ate: Tue, 23 Jun 2009 06:49:00 -0400 > Subject: Re: Optimization of memory usage in PriorityQueue > From: luc...@mikemccandless.com > To: java-dev@lucene.apache.org > > OK I've added a NOTE to the javadocs for this... > > Mike > > On Mon, Jun 22, 2009 at 8:57 PM,

Re: Optimization of memory usage in PriorityQueue

2009-06-23 Thread Michael McCandless
OK I've added a NOTE to the javadocs for this... Mike On Mon, Jun 22, 2009 at 8:57 PM, Claudio . wrote: >>> I think the common use case of TopScoreDocCollector is to request 10 >>> results, then ask for 20 and so on. You ask for N results because you want >>> to display them, or manipulate them i

RE: Optimization of memory usage in PriorityQueue

2009-06-22 Thread Claudio .
>> I think the common use case of TopScoreDocCollector is to request 10 results, then ask for 20 and so on. You ask for N results because you want to display them, or manipulate them in some way. >> However, if we do add this to the base PQ, it means an extra check for every put() call. We've tri

Re: Optimization of memory usage in PriorityQueue

2009-06-22 Thread Yonik Seeley
On Mon, Jun 22, 2009 at 10:29 AM, Shai Erera wrote: > You mean that if we add it to Collector all developers will need to impl it? > You're right, therefore I'm not sure it's such a good idea. Also, a unlike > PQ, a Collector seems less reusable, as it doesn't declare to hold any data > structures

Re: Optimization of memory usage in PriorityQueue

2009-06-22 Thread Shai Erera
You mean that if we add it to Collector all developers will need to impl it? You're right, therefore I'm not sure it's such a good idea. Also, a unlike PQ, a Collector seems less reusable, as it doesn't declare to hold any data structures that can/should be reused. What about PQ? Shai On Mon, Ju

Re: Optimization of memory usage in PriorityQueue

2009-06-22 Thread Yonik Seeley
On Mon, Jun 22, 2009 at 10:05 AM, Michael McCandless wrote: > On Mon, Jun 22, 2009 at 9:40 AM, Shai Erera wrote: >> Do you think it's worth it? If so, should we also add reset() to Collector? > > Seems like it'd be good to have the option?  But it's certainly a very > expert thing since it's presum

Re: Optimization of memory usage in PriorityQueue

2009-06-22 Thread Shai Erera
Agreed. I'll see if I can patch it sometime soon. Shai On Mon, Jun 22, 2009 at 5:05 PM, Michael McCandless < luc...@mikemccandless.com> wrote: > On Mon, Jun 22, 2009 at 9:40 AM, Shai Erera wrote: > >> Though, are Lucene's core collectors reusable? If you did really want > >> say 100K results ou

Re: Optimization of memory usage in PriorityQueue

2009-06-22 Thread Michael McCandless
On Mon, Jun 22, 2009 at 9:40 AM, Shai Erera wrote: >> Though, are Lucene's core collectors reusable?  If you did really want >> say 100K results out of each search (very unusual), it'd be nice to >> not have to throw away the Collector/PQ each time. > > PQ has clear(), but it does not really allow

Re: Optimization of memory usage in PriorityQueue

2009-06-22 Thread Shai Erera
> > Though, are Lucene's core collectors reusable? If you did really want > say 100K results out of each search (very unusual), it'd be nice to > not have to throw away the Collector/PQ each time. > PQ has clear(), but it does not really allow you to reuse it, it just removes all the elements. So

Re: Optimization of memory usage in PriorityQueue

2009-06-22 Thread Michael McCandless
On Mon, Jun 22, 2009 at 3:25 AM, Shai Erera wrote: > Or ... we can do nothing, and say that one can write his own Collector, and > use Sun's PQ (or any other), if one has a case like "I need 10K results, but > I don't know how many are there, and specifically I want to optimize for the > case of 1

Re: Optimization of memory usage in PriorityQueue

2009-06-22 Thread Shai Erera
I think the common use case of TopScoreDocCollector is to request 10 results, then ask for 20 and so on. You ask for N results because you want to display them, or manipulate them in some way. However, if we do add this to the base PQ, it means an extra check for every put() call. We've tried very

Optimization of memory usage in PriorityQueue

2009-06-21 Thread Claudio .
Hi, The PriorityQueue used in TopDocCollector does not optimize the memory usage. If I do this search: TopDocs topDocs = searcher.search(query, null, 1); And only 1 document is returned. The PriorityQueue will create an Object[] of size 1 + 1, but only one position of the