lhotari commented on code in PR #26010:
URL: https://github.com/apache/pulsar/pull/26010#discussion_r3406684251
##########
pulsar-common/src/main/java/org/apache/pulsar/common/util/collections/TripleLongPriorityQueue.java:
##########
@@ -188,81 +196,99 @@ private void shrinkCapacity() {
}
}
- private void siftUp(long tupleIdx) {
+ private void siftUp(long tupleIdx, long n1, long n2, long n3) {
+ long idx = tupleIdx * ITEMS_COUNT;
+
while (tupleIdx > 0) {
- long parentIdx = (tupleIdx - 1) / 2;
- if (compare(tupleIdx, parentIdx) >= 0) {
+ long parentIdx = (tupleIdx - 1) >>> 1;
+ long parentBase = parentIdx * ITEMS_COUNT;
+
+ long p0 = array.readLong(parentBase);
+ long p1 = array.readLong(parentBase + 1);
+ long p2 = array.readLong(parentBase + 2);
+
+ if (compareTuple(n1, n2, n3, p0, p1, p2) >= 0) {
break;
}
- swap(tupleIdx, parentIdx);
+ array.writeLong(idx, p0);
+ array.writeLong(idx + 1, p1);
+ array.writeLong(idx + 2, p2);
Review Comment:
just wondering how swapping would work in this case, if it's done outside of
the loop, it's not a swap
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]