[ 
https://issues.apache.org/jira/browse/MAHOUT-881?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13149111#comment-13149111
 ] 

Yonik Seeley commented on MAHOUT-881:
-------------------------------------

bq. Why are there fewer operations? Both seem to do an insert if the new item 
is known to be among the new top-N, and not otherwise.

Assuming a full priority queue, you have an add() and a poll() per competitive 
entry (I don't think there's a way to get around that using Java's PQ).  
Lucene's PQ can rebalance the heap once per competitive entry.

bq. I have an unfounded suspicion that the implicit heap sort here is slower in 
practice here than a simple quicksort, since that is generally the case.

Heapsort is generally slower than quicksort... but since we already have a 
built heap, we're only doing half-a-heapsort?
                
> Refactor TopItems to use Lucene's PriorityQueue and remove excessive sorting
> ----------------------------------------------------------------------------
>
>                 Key: MAHOUT-881
>                 URL: https://issues.apache.org/jira/browse/MAHOUT-881
>             Project: Mahout
>          Issue Type: Improvement
>    Affects Versions: 0.6
>            Reporter: Grant Ingersoll
>            Assignee: Grant Ingersoll
>            Priority: Minor
>         Attachments: MAHOUT-881.patch
>
>
> TopItems.getTop*() all do a fair number of excessive operations that can be 
> replaced by switching to using Lucene's PriorityQueue implementation, which 
> is more efficient and faster than Java's built in PQ implementation.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to