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

Adrien Grand commented on LUCENE-4946:
--------------------------------------

bq. Its also useful for other projects, so its maybe a good idea to make a 
Apache Commons projects out of it.

Why not. Or maybe use an already existing commons project such as commons 
collections? I'll dig that...

bq. I found some code duplication

I'll fix that. The reason is that I modified ArrayUtil and CollectionUtil which 
have their own private Sorter implementations and then I added tests which 
required me to have concrete implementations in src/test. I'll merge them.

bq. We should remove the following from NOTICE.txt

I'll fix that too.

bq. Perhaps the best way to change it would be to give (startIndex, 
elementsCount) which still reads (0, array.length) in most cases and does not 
have the problems mentioned above...

I have no strong opinion about that. I think the reason I like the (from,to) 
option better is that List.subList and Arrays.copyOfRange have the same 
arguments. For example someone who wants to sort a sub-list with the JDK would 
do {{Collections.sort(list.subList(from,to))}}. So I think it'd be nice to make 
directly translatable to {{new InPlaceMergeSorter() \{ compare/swap 
\}.sort(from, to)}}.

                
> Refactor SorterTemplate
> -----------------------
>
>                 Key: LUCENE-4946
>                 URL: https://issues.apache.org/jira/browse/LUCENE-4946
>             Project: Lucene - Core
>          Issue Type: Improvement
>            Reporter: Adrien Grand
>            Assignee: Adrien Grand
>            Priority: Trivial
>         Attachments: LUCENE-4946.patch, LUCENE-4946.patch
>
>
> When working on TimSort (LUCENE-4839), I was a little frustrated of not being 
> able to add galloping support because it would have required to add new 
> primitive operations in addition to compare and swap.
> I started working on a prototype that uses inheritance to allow some sorting 
> algorithms to rely on additional primitive operations. You can have a look at 
> https://github.com/jpountz/sorts/tree/master/src/java/net/jpountz/sorts (but 
> beware it is a prototype and still misses proper documentation and good 
> tests).
> I think it would offer several advantages:
>  - no more need to implement setPivot and comparePivot when using in-place 
> merge sort or insertion sort,
>  - the ability to use faster stable sorting algorithms at the cost of some 
> memory overhead (our in-place merge sort is very slow),
>  - the ability to implement properly algorithms that are useful on specific 
> datasets but require different primitive operations (such as TimSort for 
> partially-sorted data).
> If you are interested in comparing these implementations with Arrays.sort, 
> there is a Benchmark class in src/examples.
> What do you think?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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

Reply via email to