You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Uwe Schindler (JIRA)" <ji...@apache.org> on 2009/10/01 15:31:25 UTC

[jira] Created: (LUCENE-1935) Generify PriorityQueue

Generify PriorityQueue
----------------------

                 Key: LUCENE-1935
                 URL: https://issues.apache.org/jira/browse/LUCENE-1935
             Project: Lucene - Java
          Issue Type: Task
          Components: Other
    Affects Versions: 2.9
            Reporter: Uwe Schindler
            Assignee: Uwe Schindler
             Fix For: 3.0


Priority Queue should use generics like all other Java 5 Collection API classes. This very simple, but makes code more readable.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Issue Comment Edited: (LUCENE-1935) Generify PriorityQueue

Posted by "Uwe Schindler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761229#action_12761229 ] 

Uwe Schindler edited comment on LUCENE-1935 at 10/1/09 7:39 AM:
----------------------------------------------------------------

Patch for Priority Queue. The usage is not yet generified, but the class itsself is. Now it works like a standard Java 5 Collection (and can for sure be used conventionally).

(I also removed the tabs/whitespace in the test).

      was (Author: thetaphi):
    Patch for Priority Queue. The usage is not yet generified, but the class itsself is. Now it works like a standard Java 5 Collection (and can for sure be used conventionally).
  
> Generify PriorityQueue
> ----------------------
>
>                 Key: LUCENE-1935
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1935
>             Project: Lucene - Java
>          Issue Type: Task
>          Components: Other
>    Affects Versions: 2.9
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 3.0
>
>         Attachments: LUCENE-1935.patch
>
>
> Priority Queue should use generics like all other Java 5 Collection API classes. This very simple, but makes code more readable.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Commented: (LUCENE-1935) Generify PriorityQueue

Posted by "Mark Miller (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761423#action_12761423 ] 

Mark Miller commented on LUCENE-1935:
-------------------------------------

bq. I thought I would regret asking

Why? Now a bunch of us know a bit more than we did. Information sharing is sweet.

> Generify PriorityQueue
> ----------------------
>
>                 Key: LUCENE-1935
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1935
>             Project: Lucene - Java
>          Issue Type: Task
>          Components: Other
>    Affects Versions: 2.9
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 3.0
>
>         Attachments: LUCENE-1935.patch
>
>
> Priority Queue should use generics like all other Java 5 Collection API classes. This very simple, but makes code more readable.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Commented: (LUCENE-1935) Generify PriorityQueue

Posted by "Uwe Schindler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761387#action_12761387 ] 

Uwe Schindler commented on LUCENE-1935:
---------------------------------------

By the way, the covariant overload is optimized away by the compiler (not the JVM), if an anonymous or private (and therefore final) class is used. This is the code from the test:

{code}
private static class IntegerQueue extends PriorityQueue<Integer> {
    public IntegerQueue(int count) {
        super();
        initialize(count);
    }

    protected boolean lessThan(Integer a, Integer b) {
        return (a < b);
    }
}
{code}

Is compiled to the following code by Java 1.5 javac:

{code}
private static class TestPriorityQueue$IntegerQueue extends PriorityQueue {

    protected boolean lessThan(Object a, Object b) {
        return ((Integer)a).intValue() < ((Integer)b).intValue();
    }

    public TestPriorityQueue$IntegerQueue(int count) {
        initialize(count);
    }
}
{code}

So normal usage in Lucene would have no impact (would be the same as before). Only if you override a generified PQ with a lessThan method not final or somehow accessible, the compiler has to add the wrapper.

> Generify PriorityQueue
> ----------------------
>
>                 Key: LUCENE-1935
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1935
>             Project: Lucene - Java
>          Issue Type: Task
>          Components: Other
>    Affects Versions: 2.9
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 3.0
>
>         Attachments: LUCENE-1935.patch
>
>
> Priority Queue should use generics like all other Java 5 Collection API classes. This very simple, but makes code more readable.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Resolved: (LUCENE-1935) Generify PriorityQueue

Posted by "Uwe Schindler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-1935?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Uwe Schindler resolved LUCENE-1935.
-----------------------------------

    Resolution: Fixed

Committed revision: 821104

> Generify PriorityQueue
> ----------------------
>
>                 Key: LUCENE-1935
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1935
>             Project: Lucene - Java
>          Issue Type: Task
>          Components: Other
>    Affects Versions: 2.9
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 3.0
>
>         Attachments: LUCENE-1935.patch
>
>
> Priority Queue should use generics like all other Java 5 Collection API classes. This very simple, but makes code more readable.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Updated: (LUCENE-1935) Generify PriorityQueue

Posted by "Uwe Schindler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-1935?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Uwe Schindler updated LUCENE-1935:
----------------------------------

    Attachment: HitQueue.jad

Just for reference: Here is the generated class (by javac) when overriding lessThan (as example HitQueue), decompiled from the resulting class file by JAD.

> Generify PriorityQueue
> ----------------------
>
>                 Key: LUCENE-1935
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1935
>             Project: Lucene - Java
>          Issue Type: Task
>          Components: Other
>    Affects Versions: 2.9
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 3.0
>
>         Attachments: HitQueue.jad, LUCENE-1935.patch
>
>
> Priority Queue should use generics like all other Java 5 Collection API classes. This very simple, but makes code more readable.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Commented: (LUCENE-1935) Generify PriorityQueue

Posted by "Paul Elschot (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761367#action_12761367 ] 

Paul Elschot commented on LUCENE-1935:
--------------------------------------

Uwe, could you take a look at ScorerDocQueue?

I derived that one from PriorityQueue in 2005 to avoid casts, but now such code duplication may not be necessary anymore.

In case you think ScorerDocQueue could indeed be removed by using generics instead, I'd gladly try and provide a patch for that.


> Generify PriorityQueue
> ----------------------
>
>                 Key: LUCENE-1935
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1935
>             Project: Lucene - Java
>          Issue Type: Task
>          Components: Other
>    Affects Versions: 2.9
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 3.0
>
>         Attachments: LUCENE-1935.patch
>
>
> Priority Queue should use generics like all other Java 5 Collection API classes. This very simple, but makes code more readable.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Commented: (LUCENE-1935) Generify PriorityQueue

Posted by "Paul Smith (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761395#action_12761395 ] 

Paul Smith commented on LUCENE-1935:
------------------------------------

I shall perhaps regret asking this, but is there any reason not to use java.util.PriorityQueue instead? Seems like reinventing the wheel a bit there (I understand historically why Lucene has this class).

(is Lucene 2.9+ now Java 5, or is that a different discussion altogether?)

> Generify PriorityQueue
> ----------------------
>
>                 Key: LUCENE-1935
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1935
>             Project: Lucene - Java
>          Issue Type: Task
>          Components: Other
>    Affects Versions: 2.9
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 3.0
>
>         Attachments: LUCENE-1935.patch
>
>
> Priority Queue should use generics like all other Java 5 Collection API classes. This very simple, but makes code more readable.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Updated: (LUCENE-1935) Generify PriorityQueue

Posted by "Uwe Schindler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-1935?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Uwe Schindler updated LUCENE-1935:
----------------------------------

    Attachment: LUCENE-1935.patch

Patch for Priority Queue. The usage is not yet generified, but the class itsself is. Now it works like a standard Java 5 Collection (and can for sure be used conventionally).

> Generify PriorityQueue
> ----------------------
>
>                 Key: LUCENE-1935
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1935
>             Project: Lucene - Java
>          Issue Type: Task
>          Components: Other
>    Affects Versions: 2.9
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 3.0
>
>         Attachments: LUCENE-1935.patch
>
>
> Priority Queue should use generics like all other Java 5 Collection API classes. This very simple, but makes code more readable.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Commented: (LUCENE-1935) Generify PriorityQueue

Posted by "Paul Smith (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761408#action_12761408 ] 

Paul Smith commented on LUCENE-1935:
------------------------------------

thanks Uwe, I thought I would regret asking, good points there.  Shame the JDK doesn't have a fixed size PriorityQueue implementation, that seems a bit of a glaring omission. 

> Generify PriorityQueue
> ----------------------
>
>                 Key: LUCENE-1935
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1935
>             Project: Lucene - Java
>          Issue Type: Task
>          Components: Other
>    Affects Versions: 2.9
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 3.0
>
>         Attachments: LUCENE-1935.patch
>
>
> Priority Queue should use generics like all other Java 5 Collection API classes. This very simple, but makes code more readable.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Issue Comment Edited: (LUCENE-1935) Generify PriorityQueue

Posted by "Uwe Schindler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761387#action_12761387 ] 

Uwe Schindler edited comment on LUCENE-1935 at 10/1/09 4:16 PM:
----------------------------------------------------------------

By the way, the covariant overload is optimized away by the compiler (not the JVM), if an anonymous or private (and therefore final) class is used. This is the code from the test:

{code}
private static class IntegerQueue extends PriorityQueue<Integer> {
    public IntegerQueue(int count) {
        super();
        initialize(count);
    }

    protected boolean lessThan(Integer a, Integer b) {
        return (a < b);
    }
}
{code}

Is compiled to the following code by Java 1.5 javac:

{code}
private static class TestPriorityQueue$IntegerQueue extends PriorityQueue {

    protected boolean lessThan(Object a, Object b) {
        return ((Integer)a).intValue() < ((Integer)b).intValue();
    }

    public TestPriorityQueue$IntegerQueue(int count) {
        initialize(count);
    }
}
{code}

So normal usage in Lucene would have no impact (would be the same as before). Only if you override a generified PQ with a lessThan method not final or somehow accessible, the compiler has to add the wrapper.

*edit:*

If you want to see, what I mean with "wrapper", look into [https://issues.apache.org/jira/secure/attachment/12418140/AttributeSource.jad] and there in getAttributeImplIterator(). The inline Iterator overrides next(), but the return type is generic -> compiler adds a "volatile" method (how JAD identifies it).

      was (Author: thetaphi):
    By the way, the covariant overload is optimized away by the compiler (not the JVM), if an anonymous or private (and therefore final) class is used. This is the code from the test:

{code}
private static class IntegerQueue extends PriorityQueue<Integer> {
    public IntegerQueue(int count) {
        super();
        initialize(count);
    }

    protected boolean lessThan(Integer a, Integer b) {
        return (a < b);
    }
}
{code}

Is compiled to the following code by Java 1.5 javac:

{code}
private static class TestPriorityQueue$IntegerQueue extends PriorityQueue {

    protected boolean lessThan(Object a, Object b) {
        return ((Integer)a).intValue() < ((Integer)b).intValue();
    }

    public TestPriorityQueue$IntegerQueue(int count) {
        initialize(count);
    }
}
{code}

So normal usage in Lucene would have no impact (would be the same as before). Only if you override a generified PQ with a lessThan method not final or somehow accessible, the compiler has to add the wrapper.
  
> Generify PriorityQueue
> ----------------------
>
>                 Key: LUCENE-1935
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1935
>             Project: Lucene - Java
>          Issue Type: Task
>          Components: Other
>    Affects Versions: 2.9
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 3.0
>
>         Attachments: LUCENE-1935.patch
>
>
> Priority Queue should use generics like all other Java 5 Collection API classes. This very simple, but makes code more readable.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Issue Comment Edited: (LUCENE-1935) Generify PriorityQueue

Posted by "Uwe Schindler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761409#action_12761409 ] 

Uwe Schindler edited comment on LUCENE-1935 at 10/1/09 4:45 PM:
----------------------------------------------------------------

Paul Elschot: Do you want to provide a patch for ScorerDocQueue that it subclasses PQ<HeapedScorerDoc>?

      was (Author: thetaphi):
    Paul: Do you want to provide a patch for ScorerDocQueue that it subclasses PQ<HeapedScorerDoc>?
  
> Generify PriorityQueue
> ----------------------
>
>                 Key: LUCENE-1935
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1935
>             Project: Lucene - Java
>          Issue Type: Task
>          Components: Other
>    Affects Versions: 2.9
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 3.0
>
>         Attachments: LUCENE-1935.patch
>
>
> Priority Queue should use generics like all other Java 5 Collection API classes. This very simple, but makes code more readable.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Commented: (LUCENE-1935) Generify PriorityQueue

Posted by "Uwe Schindler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761372#action_12761372 ] 

Uwe Schindler commented on LUCENE-1935:
---------------------------------------

Was it to avoid a perforance impact of casting or only for cleaner code? Because the generic version of PQ does noch change anything, the resulting byte code is identical (you can compare that with a decompilation using JAD). The casts are added by the Java Compiler automatically.
The lessThan method is covariant overloaded (passed through) by javac: lessThan(Integer, Integer) will appear as such in the class byte code, but javac will add lessThan(Object, Object) that delgates around (which may be a small perf impact), as it is called by the compiled code of PQ (PQ does not know anything about generics in its byte code).

> Generify PriorityQueue
> ----------------------
>
>                 Key: LUCENE-1935
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1935
>             Project: Lucene - Java
>          Issue Type: Task
>          Components: Other
>    Affects Versions: 2.9
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 3.0
>
>         Attachments: LUCENE-1935.patch
>
>
> Priority Queue should use generics like all other Java 5 Collection API classes. This very simple, but makes code more readable.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Commented: (LUCENE-1935) Generify PriorityQueue

Posted by "Paul Elschot (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761374#action_12761374 ] 

Paul Elschot commented on LUCENE-1935:
--------------------------------------

It was to avoid the performance impact of casting, however I don't remember how big the performance impact was.
I would hope that nowadays the added casts are optimized away by the JIT.


> Generify PriorityQueue
> ----------------------
>
>                 Key: LUCENE-1935
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1935
>             Project: Lucene - Java
>          Issue Type: Task
>          Components: Other
>    Affects Versions: 2.9
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 3.0
>
>         Attachments: LUCENE-1935.patch
>
>
> Priority Queue should use generics like all other Java 5 Collection API classes. This very simple, but makes code more readable.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Commented: (LUCENE-1935) Generify PriorityQueue

Posted by "Uwe Schindler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761399#action_12761399 ] 

Uwe Schindler commented on LUCENE-1935:
---------------------------------------

The implementation of Lucene's PriorityQueue is a little bit different and also its API. Would be some work to rewrite the collectors.

The biggest problem of Java's PQ: It does not let elements fall out when a higher prio entry is inserted and the list is full (no upper limit on list length). The Java list grows like a ArrayList.

> Generify PriorityQueue
> ----------------------
>
>                 Key: LUCENE-1935
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1935
>             Project: Lucene - Java
>          Issue Type: Task
>          Components: Other
>    Affects Versions: 2.9
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 3.0
>
>         Attachments: LUCENE-1935.patch
>
>
> Priority Queue should use generics like all other Java 5 Collection API classes. This very simple, but makes code more readable.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Commented: (LUCENE-1935) Generify PriorityQueue

Posted by "Paul Elschot (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761492#action_12761492 ] 

Paul Elschot commented on LUCENE-1935:
--------------------------------------

> Do you want to provide a patch for ScorerDocQueue that it subclasses PQ<HeapedScorerDoc>?

Yes, however that could also be done at a separate issue.
Thanks for reminding me of the topSkipToAndAdjustElsePop method.
At the time the JIT was not able to fully optimize two method calls to a ScorerDocQueue object, so I added that method to the class.

Btw. ScorerDocQueue is used in disjunction queries when the docs should be scored in order, so it is sensitive to query performance, see LUCENE-365 .

> Generify PriorityQueue
> ----------------------
>
>                 Key: LUCENE-1935
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1935
>             Project: Lucene - Java
>          Issue Type: Task
>          Components: Other
>    Affects Versions: 2.9
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 3.0
>
>         Attachments: LUCENE-1935.patch
>
>
> Priority Queue should use generics like all other Java 5 Collection API classes. This very simple, but makes code more readable.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Commented: (LUCENE-1935) Generify PriorityQueue

Posted by "Uwe Schindler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761381#action_12761381 ] 

Uwe Schindler commented on LUCENE-1935:
---------------------------------------

I think it could be rewritten and the missing functionality with the funny name "topSkipToAndAdjustElsePop" added somewhere. The simpliest would be a subclass:

{code}
public class ScorerDocQueue extends PriorityQueue<HeapedScorerDoc> {...}
{code}

I do not know how big the perf impact would be (if there is one). As mentioned before, there is a small oerhead, because the overriden abstract method lessThan(HeapedScorerDoc, HeapedScorerDoc) would be wrapped by javac as lessThan(Object, Object) - a small added cost (do not know how big or jvm optimizes away, which I hope)

> Generify PriorityQueue
> ----------------------
>
>                 Key: LUCENE-1935
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1935
>             Project: Lucene - Java
>          Issue Type: Task
>          Components: Other
>    Affects Versions: 2.9
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 3.0
>
>         Attachments: LUCENE-1935.patch
>
>
> Priority Queue should use generics like all other Java 5 Collection API classes. This very simple, but makes code more readable.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Commented: (LUCENE-1935) Generify PriorityQueue

Posted by "Uwe Schindler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761409#action_12761409 ] 

Uwe Schindler commented on LUCENE-1935:
---------------------------------------

Paul: Do you want to provide a patch for ScorerDocQueue that it subclasses PQ<HeapedScorerDoc>?

> Generify PriorityQueue
> ----------------------
>
>                 Key: LUCENE-1935
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1935
>             Project: Lucene - Java
>          Issue Type: Task
>          Components: Other
>    Affects Versions: 2.9
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 3.0
>
>         Attachments: LUCENE-1935.patch
>
>
> Priority Queue should use generics like all other Java 5 Collection API classes. This very simple, but makes code more readable.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Issue Comment Edited: (LUCENE-1935) Generify PriorityQueue

Posted by "Mark Miller (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761389#action_12761389 ] 

Mark Miller edited comment on LUCENE-1935 at 10/1/09 4:07 PM:
--------------------------------------------------------------

Ive tried custom PQ's for use in sorting to avoid the casting not too long ago - I both mirco benched and used a profiler. I didn't see no win. Big fat waste of my time ;)

*edit*

actually non sorting too - tried em both. 

      was (Author: markrmiller@gmail.com):
    Ive tried custom PQ's for use in sorting to avoid the casting not too long ago - I both mirco benched and used a profiler. I didn't see no win. Big fat waste of my time ;)
  
> Generify PriorityQueue
> ----------------------
>
>                 Key: LUCENE-1935
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1935
>             Project: Lucene - Java
>          Issue Type: Task
>          Components: Other
>    Affects Versions: 2.9
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 3.0
>
>         Attachments: LUCENE-1935.patch
>
>
> Priority Queue should use generics like all other Java 5 Collection API classes. This very simple, but makes code more readable.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Commented: (LUCENE-1935) Generify PriorityQueue

Posted by "Mark Miller (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761389#action_12761389 ] 

Mark Miller commented on LUCENE-1935:
-------------------------------------

Ive tried custom PQ's for use in sorting to avoid the casting not too long ago - I both mirco benched and used a profiler. I didn't see no win. Big fat waste of my time ;)

> Generify PriorityQueue
> ----------------------
>
>                 Key: LUCENE-1935
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1935
>             Project: Lucene - Java
>          Issue Type: Task
>          Components: Other
>    Affects Versions: 2.9
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 3.0
>
>         Attachments: LUCENE-1935.patch
>
>
> Priority Queue should use generics like all other Java 5 Collection API classes. This very simple, but makes code more readable.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Issue Comment Edited: (LUCENE-1935) Generify PriorityQueue

Posted by "Uwe Schindler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761372#action_12761372 ] 

Uwe Schindler edited comment on LUCENE-1935 at 10/1/09 3:31 PM:
----------------------------------------------------------------

Was it to avoid a perforance impact of casting or only for cleaner code? Because the generic version of PQ does noch change anything, the resulting byte code is identical (you can compare that with a decompilation using JAD). The casts are added by the Java Compiler automatically.
The lessThan method is covariant overloaded (passed through) in subclasses by javac (like in the test): lessThan(Integer, Integer) will appear as such in the class byte code of the subclass, but javac will add lessThan(Object, Object) that delgates to the covariant overload (which may be a small perf impact). It is called by the compiled code of PQ using the (Object, Object) signature (PQ does not know anything about generics in its byte code).

      was (Author: thetaphi):
    Was it to avoid a perforance impact of casting or only for cleaner code? Because the generic version of PQ does noch change anything, the resulting byte code is identical (you can compare that with a decompilation using JAD). The casts are added by the Java Compiler automatically.
The lessThan method is covariant overloaded (passed through) by javac: lessThan(Integer, Integer) will appear as such in the class byte code, but javac will add lessThan(Object, Object) that delgates around (which may be a small perf impact), as it is called by the compiled code of PQ (PQ does not know anything about generics in its byte code).
  
> Generify PriorityQueue
> ----------------------
>
>                 Key: LUCENE-1935
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1935
>             Project: Lucene - Java
>          Issue Type: Task
>          Components: Other
>    Affects Versions: 2.9
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 3.0
>
>         Attachments: LUCENE-1935.patch
>
>
> Priority Queue should use generics like all other Java 5 Collection API classes. This very simple, but makes code more readable.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Commented: (LUCENE-1935) Generify PriorityQueue

Posted by "Uwe Schindler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761653#action_12761653 ] 

Uwe Schindler commented on LUCENE-1935:
---------------------------------------

Hi Paul Elschot: I opened LUCENE-1940 for the refactoring

> Generify PriorityQueue
> ----------------------
>
>                 Key: LUCENE-1935
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1935
>             Project: Lucene - Java
>          Issue Type: Task
>          Components: Other
>    Affects Versions: 2.9
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: 3.0
>
>         Attachments: LUCENE-1935.patch
>
>
> Priority Queue should use generics like all other Java 5 Collection API classes. This very simple, but makes code more readable.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org