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

Sean Owen commented on MAHOUT-881:
----------------------------------

(See my comments on dev@ too)

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.

Both versions allocate the ArrayList. I think you're quite right about the 
addAll() and sort() though. Even if that's an implementation detail, it's real. 
Those are a few extra arrays of size 10-ish on average, so I would imagine it's 
not significant. But I also don't like the idea.

On the other hand, 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.

I would be surprised if this was not all but identical in performance. We could 
also make some micro-wins here in other ways to avoid these couple extra 
allocations. or we can use the Lucene-based queue and avoid heap sort. I have a 
very slight aversion to changing to something equal but different, replacing 
very standard java.util.PriorityQueue with merely "standard" Lucene 
PriorityQueue.

If I'm wrong that this isn't equal -- I support it. If we all concludes it's 
equal, or barely slower, I'm -0 on the change and really not fussed about it.
                
> 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