msokolov commented on code in PR #873: URL: https://github.com/apache/lucene/pull/873#discussion_r881581848
########## lucene/core/src/java/org/apache/lucene/util/hnsw/NeighborQueue.java: ########## @@ -90,26 +92,34 @@ public boolean insertWithOverflow(int newNode, float newScore) { } private long encode(int node, float score) { - return order.apply((((long) NumericUtils.floatToSortableInt(score)) << 32) | node); + int nodeReverse = reversed ? node : Integer.MAX_VALUE - node; + return order.apply((((long) NumericUtils.floatToSortableInt(score)) << 32) | nodeReverse); } /** Removes the top element and returns its node id. */ public int pop() { - return (int) order.apply(heap.pop()); + return reversed Review Comment: can we move this logic into `Order.apply`? If we do that we can avoid a conditional in this hot spot -- 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: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org