jpountz commented on a change in pull request #1263: LUCENE-9228: Sort dv
updates by terms by applying
URL: https://github.com/apache/lucene-solr/pull/1263#discussion_r380377204
##########
File path: lucene/core/src/java/org/apache/lucene/util/BytesRefArray.java
##########
@@ -136,22 +138,28 @@ protected int compare(int i, int j) {
final int idx1 = orderedEntries[i], idx2 = orderedEntries[j];
setBytesRef(scratch1, scratchBytes1, idx1);
setBytesRef(scratch2, scratchBytes2, idx2);
- return comp.compare(scratchBytes1, scratchBytes2);
+ return compare(idx1, scratchBytes1, idx2, scratchBytes2);
}
@Override
protected void setPivot(int i) {
- final int index = orderedEntries[i];
- setBytesRef(pivotBuilder, pivot, index);
+ pivotIndex = orderedEntries[i];
+ setBytesRef(pivotBuilder, pivot, pivotIndex);
}
@Override
protected int comparePivot(int j) {
final int index = orderedEntries[j];
setBytesRef(scratch2, scratchBytes2, index);
- return comp.compare(pivot, scratchBytes2);
+ return compare(pivotIndex, pivot, index, scratchBytes2);
}
+ private int compare(int i1, BytesRef b1, int i2, BytesRef b2) {
+ int res = comp.compare(b1, b2);
+ return res == 0 ? tieComparator.applyAsInt(i1, i2): res;
Review comment:
nit
```suggestion
return res == 0 ? tieComparator.applyAsInt(i1, i2) : res;
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]