Return-Path: Delivered-To: apmail-jakarta-lucene-dev-archive@www.apache.org Received: (qmail 64590 invoked from network); 23 Jan 2004 16:43:00 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 23 Jan 2004 16:43:00 -0000 Received: (qmail 69991 invoked by uid 500); 23 Jan 2004 16:42:25 -0000 Delivered-To: apmail-jakarta-lucene-dev-archive@jakarta.apache.org Received: (qmail 69975 invoked by uid 500); 23 Jan 2004 16:42:25 -0000 Mailing-List: contact lucene-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Lucene Developers List" Reply-To: "Lucene Developers List" Delivered-To: mailing list lucene-dev@jakarta.apache.org Received: (qmail 69912 invoked from network); 23 Jan 2004 16:42:24 -0000 Received: from unknown (HELO tsunami.skynet.be) (195.238.2.85) by daedalus.apache.org with SMTP; 23 Jan 2004 16:42:24 -0000 Received: from DELLLAT1L34N0J (194-189.240.81.adsl.skynet.be [81.240.189.194]) by tsunami.skynet.be (8.12.9/8.12.9/Skynet-OUT-2.21) with SMTP id i0NGgOm4010003 for ; Fri, 23 Jan 2004 17:42:24 +0100 (envelope-from ) Reply-To: From: "Jean-Francois Halleux" To: "Lucene Developers List" Subject: RE: [Patch] Constructor instead of initialize in PriorityQueue implementations Date: Fri, 23 Jan 2004 17:40:40 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) Importance: Normal In-Reply-To: <20040123160749.9901.qmail@web12708.mail.yahoo.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-RAVMilter-Version: 8.4.3(snapshot 20030212) (tsunami.skynet.be) X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Your call, it is not crucial anyway. Looking through the archives, there was a suggestion to use the comparable interface instead of the lessThan method of the PQ. This is cleaner and closer to the "normal" java collections and allows to remove 2 or three PQ implementation classes. I tried it for HitQueue with ScoreDoc and it worked well locally :) What do you think? I noticed also that quite an extensive use of PQ is made throughout the code. Could it be possible to have an O(1) insertion by "bucketting" the documents, for example based on their score or a function of their score and document number? KR, Jean-Francois Halleux -----Original Message----- From: Otis Gospodnetic [mailto:otis_gospodnetic@yahoo.com] Sent: vendredi 23 janvier 2004 17:08 To: Lucene Developers List Subject: RE: [Patch] Constructor instead of initialize in PriorityQueue implementations Hello, I'm not sure if anyone followed up on this. It looks like me that initialize(int) is the right thing to call. I also don't even see q PriorityQueue constructor that takes an int parameter, so I am not sure if the code would compile after this patch. Otis --- liu ji wrote: > I quite agree with you.The document said subclass constructors must > call > initialize.And initialize is a protected method. > It seems initialize method can't be accessed by other method except > the > subclass constructor. > I don't think it is necessary to initialize a queue after the queue > is > constructed. > Is there any queue need a method which reinitialize the queue? > > > > >From: "Jean-Francois Halleux" > >Reply-To: > >To: > >Subject: [Patch] Constructor instead of initialize in PriorityQueue > implementations > >Date: Sat, 27 Dec 2003 21:30:06 +0100 > > > >Hello, > > > > I believe it would be preferable to use a call to super in the > subclass > of > >PriorityQueue. > > > >Patch follows. > > > >KR, > > > >Jean-Frangois Halleux > > > >---- > > > >Index: java/org/apache/lucene/index/MultipleTermPositions.java > >=================================================================== > >RCS file: > >/home/cvspublic/jakarta-lucene/src/java/org/apache/lucene/index/MultipleTer m > > >Positions.java,v > >retrieving revision 1.3 > >diff -u -r1.3 MultipleTermPositions.java > >--- java/org/apache/lucene/index/MultipleTermPositions.java 21 Oct > 2003 > >17:59:16 -0000 1.3 > >+++ java/org/apache/lucene/index/MultipleTermPositions.java 27 Dec > 2003 > >20:26:14 -0000 > >@@ -78,7 +78,7 @@ > > TermPositionsQueue(List termPositions) > > throws IOException > > { > >- initialize(termPositions.size()); > >+ super(termPositions.size()); > > > > Iterator i = termPositions.iterator(); > > while (i.hasNext()) > >Index: java/org/apache/lucene/index/SegmentMergeQueue.java > >=================================================================== > >RCS file: > >/home/cvspublic/jakarta-lucene/src/java/org/apache/lucene/index/SegmentMerg e > > >Queue.java,v > >retrieving revision 1.1.1.1 > >diff -u -r1.1.1.1 SegmentMergeQueue.java > >--- java/org/apache/lucene/index/SegmentMergeQueue.java 18 Sep 2001 > >16:29:53 -0000 1.1.1.1 > >+++ java/org/apache/lucene/index/SegmentMergeQueue.java 27 Dec 2003 > >20:26:14 -0000 > >@@ -59,7 +59,7 @@ > > > > final class SegmentMergeQueue extends PriorityQueue { > > SegmentMergeQueue(int size) { > >- initialize(size); > >+ super(size); > > } > > > > protected final boolean lessThan(Object a, Object b) { > >Index: java/org/apache/lucene/search/HitQueue.java > >=================================================================== > >RCS file: > >/home/cvspublic/jakarta-lucene/src/java/org/apache/lucene/search/HitQueue.j a > > >va,v > >retrieving revision 1.1.1.1 > >diff -u -r1.1.1.1 HitQueue.java > >--- java/org/apache/lucene/search/HitQueue.java 18 Sep 2001 16:29:56 > -0000 > >1.1.1.1 > >+++ java/org/apache/lucene/search/HitQueue.java 27 Dec 2003 20:26:14 > -0000 > >@@ -58,7 +58,7 @@ > > > > final class HitQueue extends PriorityQueue { > > HitQueue(int size) { > >- initialize(size); > >+ super(size); > > } > > > > protected final boolean lessThan(Object a, Object b) { > >Index: java/org/apache/lucene/search/PhraseQueue.java > >=================================================================== > >RCS file: > >/home/cvspublic/jakarta-lucene/src/java/org/apache/lucene/search/PhraseQueu e > > >.java,v > >retrieving revision 1.1.1.1 > >diff -u -r1.1.1.1 PhraseQueue.java > >--- java/org/apache/lucene/search/PhraseQueue.java 18 Sep 2001 > >16:29:57 -0000 1.1.1.1 > >+++ java/org/apache/lucene/search/PhraseQueue.java 27 Dec 2003 > >20:26:15 -0000 > >@@ -58,7 +58,7 @@ > > > > final class PhraseQueue extends PriorityQueue { > > PhraseQueue(int size) { > >- initialize(size); > >+ super(size); > > } > > > > protected final boolean lessThan(Object o1, Object o2) { > >Index: java/org/apache/lucene/util/PriorityQueue.java > >=================================================================== > >RCS file: > >/home/cvspublic/jakarta-lucene/src/java/org/apache/lucene/util/PriorityQueu e > > >.java,v > >retrieving revision 1.5 > >diff -u -r1.5 PriorityQueue.java > >--- java/org/apache/lucene/util/PriorityQueue.java 20 Sep 2003 > >14:06:47 -0000 1.5 > >+++ java/org/apache/lucene/util/PriorityQueue.java 27 Dec 2003 > >20:26:15 -0000 > >@@ -67,7 +67,7 @@ > > protected abstract boolean lessThan(Object a, Object b); > > > > /** Subclass constructors must call this. */ > >- protected final void initialize(int maxSize) { > >+ protected PriorityQueue(int maxSize) { > > size = 0; > > int heapSize = maxSize + 1; > > heap = new Object[heapSize]; > >Index: test/org/apache/lucene/util/TestPriorityQueue.java > >=================================================================== > >RCS file: > >/home/cvspublic/jakarta-lucene/src/test/org/apache/lucene/util/TestPriority Q > > >ueue.java,v > >retrieving revision 1.4 > >diff -u -r1.4 TestPriorityQueue.java > >--- test/org/apache/lucene/util/TestPriorityQueue.java 11 Sep 2003 > >12:15:30 -0000 1.4 > >+++ test/org/apache/lucene/util/TestPriorityQueue.java 27 Dec 2003 > >20:26:16 -0000 > >@@ -71,8 +71,7 @@ > > { > > public IntegerQueue(int count) > > { > >- super(); > >- initialize(count); > >+ super(count); > > } > > > > protected boolean lessThan(Object a, Object b) > > > > > >--------------------------------------------------------------------- > >To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org > >For additional commands, e-mail: lucene-dev-help@jakarta.apache.org > > > > _________________________________________________________________ > SkA*;z5DEsSQ=xPP=;Aw#,GkJ9SC MSN Messenger: > http://messenger.msn.com/cn > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org > For additional commands, e-mail: lucene-dev-help@jakarta.apache.org > __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/ --------------------------------------------------------------------- To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: lucene-dev-help@jakarta.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: lucene-dev-help@jakarta.apache.org