Skip to content

Commit 102b74a

Browse files
committed
Use the new value if it is the most competitive.
1 parent 2b50cf1 commit 102b74a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

server/src/main/java/org/elasticsearch/index/codec/vectors/cluster/NeighborQueue.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,16 @@ public long popRaw() {
142142
return heap.pop();
143143
}
144144

145-
/** Removes the top element, returns it and adds the new encoded element */
145+
/**
146+
* if the new element is the new top then return its node id. Otherwise,
147+
* removes the current top element, returns its node id and adds the new element
148+
* to the queue.
149+
* */
146150
public int popAndAddRaw(long raw) {
147151
long top = heap.top();
152+
if (raw < top) {
153+
return decodeNodeId(raw);
154+
}
148155
heap.updateTop(raw);
149156
return decodeNodeId(top);
150157
}

0 commit comments

Comments
 (0)