[ https://issues.apache.org/jira/browse/LUCENE-4546?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13492445#comment-13492445 ]
Uwe Schindler commented on LUCENE-4546: --------------------------------------- Hi, I think the problem is your test case: The SorterTemplate in your test does not handle the pivot value correctly - The setPivot() and comparePivot() methods get the index to compare with, but setPivot must store the actual value of the pivot, not the index of the pivot. Your code just stores the pivot index. You can fix this by correctly implementing setPivot: this.pivot = x[i] and implement comparePivot accordingly. See ArrayUtil for an example. > SorterTemplate.quicksort incorrect > ---------------------------------- > > Key: LUCENE-4546 > URL: https://issues.apache.org/jira/browse/LUCENE-4546 > Project: Lucene - Core > Issue Type: Bug > Components: core/other > Affects Versions: 3.6.1, 4.0, 4.1 > Reporter: Stefan Pohl > Labels: patch > Fix For: 3.6.1, 4.0, 4.1 > > Attachments: SorterTemplate.java.patch, TestSorterTemplate.java > > > On trying to use the very useful o.a.l.utils.SorterTemplate, I stumbled upon > inconsistent sorting behaviour, of course, only a randomized test caught > this;) > Because SorterTemplate.quicksort is used in several places in the code > (directly BytesRefList, ArrayUtil, BytesRefHash, CollectionUtil and > transitively index and search), I'm a bit puzzled that this either hasn't > been caught by another higher-level test or that neither my test nor my > understanding of an insufficiency in the code is valid;) > If the former holds and given that the same code is released in 3.6 and 4.0, > this might even be a more critical issue requiring a higher priority than > 'major'. > So, can a second pair of eyes please have a timely look at the attached test > and patch? > Basically the current quicksort implementation seems to assume that luckily > always the median is chosen as pivot element by grabbing the mid element, not > handling the case where the initially chosen pivot ends up not in the middle. > Hope this and the test helps to understand the issue. > Reproducible, currently failing test and a patch attached. -- 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