From d6ed90d5eb3c7ebaf87129030ad2497eefd75ff1 Mon Sep 17 00:00:00 2001 From: Viswanath Kuchibhotla Date: Wed, 18 Dec 2024 23:13:33 +0530 Subject: [PATCH] Add only components with non zero nodes --- .../core/src/java/org/apache/lucene/util/hnsw/HnswUtil.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lucene/core/src/java/org/apache/lucene/util/hnsw/HnswUtil.java b/lucene/core/src/java/org/apache/lucene/util/hnsw/HnswUtil.java index 313301e1345..7028a81808d 100644 --- a/lucene/core/src/java/org/apache/lucene/util/hnsw/HnswUtil.java +++ b/lucene/core/src/java/org/apache/lucene/util/hnsw/HnswUtil.java @@ -106,7 +106,9 @@ public class HnswUtil { } else { entryPoint = connectedNodes.nextSetBit(0); } - components.add(new Component(entryPoint, total)); + if (total > 0) { + components.add(new Component(entryPoint, total)); + } if (level == 0) { int nextClear = nextClearBit(connectedNodes, 0); while (nextClear != NO_MORE_DOCS) {