You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Related PR : #5691
The result of TopKSelector may be wrong when trim() is invoked and quiksort fallback to Arrasys.sort(). Because Arrasys.sort() is been used by mistake there.
Following test case can trigger this bug.
{
int n = 10000;
int k = 10000;
int testIteration = 10;
Random random = new Random(System.currentTimeMillis());
for (int iter = 0; iter < testIteration; iter ++) {
// target array to be sorted using TopKSelector
List<Integer> target = new ArrayList<>();
for (int i = 0; i < 9; i++) {
List<Integer> sortedArray = new ArrayList();
for (int j = 0; j < n; j++) {
sortedArray.add(random.nextInt());
}
sortedArray.sort(Integer::compareTo);
target.addAll(sortedArray);
}
TopKSelector<Integer> top = TopKSelector.least(k, Integer::compareTo);
for (int value : target) {
top.offer(value);
}
target.sort(Integer::compareTo);
assertEquals(top.topK(), target.subList(0, k));
}
}
The text was updated successfully, but these errors were encountered:
Hi ! @Liulietong ,
I am a new open source contributor and I would love to fix the issue, could you please provide some more reference to help me understand better? Is this issue open for contribution ?
netdpb
changed the title
Fix bug that result of TopKSelector is unstable when quicksort fallback to Arrays.sort.
TopKSelector is unstable when quicksort fallback to Arrays.sort.
Aug 23, 2021
Related PR : #5691
The result of
TopKSelector
may be wrong whentrim()
is invoked and quiksort fallback toArrasys.sort()
. BecauseArrasys.sort()
is been used by mistake there.Following test case can trigger this bug.
The text was updated successfully, but these errors were encountered: