zhaih commented on code in PR #12910:
URL: https://github.com/apache/lucene/pull/12910#discussion_r1424036233
##########
lucene/core/src/java/org/apache/lucene/util/hnsw/NeighborArray.java:
##########
@@ -51,45 +51,61 @@ public NeighborArray(int maxSize, boolean descOrder) {
*/
public void addInOrder(int newNode, float newScore) {
assert size == sortedNodeSize : "cannot call addInOrder after
addOutOfOrder";
- if (size == node.length) {
- node = ArrayUtil.grow(node);
- score = ArrayUtil.growExact(score, node.length);
+ if (size == nodes.length) {
+ throw new IllegalStateException("No growth is allowed");
}
if (size > 0) {
- float previousScore = score[size - 1];
+ float previousScore = scores[size - 1];
assert ((scoresDescOrder && (previousScore >= newScore))
|| (scoresDescOrder == false && (previousScore <= newScore)))
: "Nodes are added in the incorrect order! Comparing "
+ newScore
+ " to "
- + Arrays.toString(ArrayUtil.copyOfSubArray(score, 0, size));
+ + Arrays.toString(ArrayUtil.copyOfSubArray(scores, 0, size));
}
- node[size] = newNode;
- score[size] = newScore;
+ nodes[size] = newNode;
+ scores[size] = newScore;
++size;
++sortedNodeSize;
}
/** Add node and newScore but do not insert as sorted */
public void addOutOfOrder(int newNode, float newScore) {
- if (size == node.length) {
Review Comment:
This will be used by `InitializedHnswGraphBuilder`, so altho it's still can
be package-private, but contract-wise it's more like a public method to me.
(Being exposed to external classes)
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]