lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jean-Francois Halleux" <halleux...@skynet.be>
Subject RE: [Patch] Constructor instead of initialize in PriorityQueue implementations
Date Fri, 23 Jan 2004 16:40:40 GMT
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 <liujiboy@hotmail.com> 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" <jfhalleux@signant.com>
> >Reply-To: <jfhalleux@signant.com>
> >To: <lucene-dev@jakarta.apache.org>
> >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


Mime
View raw message