Github user ggevay commented on a diff in the pull request: https://github.com/apache/flink/pull/2628#discussion_r84248344 --- Diff: flink-runtime/src/main/java/org/apache/flink/runtime/operators/sort/QuickSort.java --- @@ -49,20 +49,40 @@ protected static int getMaxDepth(int x) { * then switch to {@link HeapSort}. */ public void sort(final IndexedSortable s, int p, int r) { - sortInternal(s, p, r, getMaxDepth(r - p)); + int recordsPerSegment = s.recordsPerSegment(); + int recordSize = s.recordSize(); + + int maxOffset = recordSize * (recordsPerSegment - 1); + + int size = s.size(); + int sizeN = size / recordsPerSegment; + int sizeO = (size % recordsPerSegment) * recordSize; + + sortInternal(s, recordsPerSegment, recordSize, maxOffset, 0, 0, 0, size, sizeN, sizeO, getMaxDepth(r - p)); } public void sort(IndexedSortable s) { sort(s, 0, s.size()); } - private static void sortInternal(final IndexedSortable s, int p, int r, int depth) { + private static void sortInternal(final IndexedSortable s, int recordsPerSegment, int recordSize, int maxOffset, + int p, int pN, int pO, int r, int rN, int rO, int depth) { --- End diff -- Could you please add a comment that explains all these parameters? (I understand them only because I know the original code and also what you are trying to achieve, but for someone who sees the code for the first time this will be quite scary.)
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---