1717
1818package org .apache .lucene .util .hnsw ;
1919
20- import org .apache .lucene .util .LongHeap ;
2120import org .apache .lucene .util .NumericUtils ;
21+ import org .apache .lucene .util .TernaryLongHeap ;
2222
2323/**
24- * NeighborQueue uses a {@link LongHeap } to store lists of arcs in an HNSW graph, represented as a
25- * neighbor node id with an associated score packed together as a sortable long, which is sorted
26- * primarily by score. The queue provides both fixed-size and unbounded operations via {@link
24+ * NeighborQueue uses a {@link TernaryLongHeap } to store lists of arcs in an HNSW graph, represented
25+ * as a neighbor node id with an associated score packed together as a sortable long, which is
26+ * sorted primarily by score. The queue provides both fixed-size and unbounded operations via {@link
2727 * #insertWithOverflow(int, float)} and {@link #add(int, float)}, and provides MIN and MAX heap
2828 * subclasses.
2929 */
@@ -48,7 +48,7 @@ long apply(long v) {
4848 abstract long apply (long v );
4949 }
5050
51- private final LongHeap heap ;
51+ private final TernaryLongHeap heap ;
5252 private final Order order ;
5353
5454 // Used to track the number of neighbors visited during a single graph traversal
@@ -57,7 +57,7 @@ long apply(long v) {
5757 private boolean incomplete ;
5858
5959 public NeighborQueue (int initialSize , boolean maxHeap ) {
60- this .heap = new LongHeap (initialSize );
60+ this .heap = new TernaryLongHeap (initialSize );
6161 this .order = maxHeap ? Order .MAX_HEAP : Order .MIN_HEAP ;
6262 }
6363
0 commit comments