Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lucene/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ Optimizations
---------------------
* GITHUB#15140: Optimize TopScoreDocCollector with TernaryLongHeap for improved performance over Binary-LongHeap. (Ramakrishna Chilaka)

* GITHUB#15163: Use TernaryLongHeap in NeighborQueue for faster vector search performance. (Ramakrishna Chilaka)

* GITHUB#14998: Speed up flushing of live docs. (Adrien Grand)

Bug Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

package org.apache.lucene.util.hnsw;

import org.apache.lucene.util.LongHeap;
import org.apache.lucene.util.NumericUtils;
import org.apache.lucene.util.TernaryLongHeap;

/**
* NeighborQueue uses a {@link LongHeap} to store lists of arcs in an HNSW graph, represented as a
* neighbor node id with an associated score packed together as a sortable long, which is sorted
* primarily by score. The queue provides both fixed-size and unbounded operations via {@link
* NeighborQueue uses a {@link TernaryLongHeap} to store lists of arcs in an HNSW graph, represented
* as a neighbor node id with an associated score packed together as a sortable long, which is
* sorted primarily by score. The queue provides both fixed-size and unbounded operations via {@link
* #insertWithOverflow(int, float)} and {@link #add(int, float)}, and provides MIN and MAX heap
* subclasses.
*/
Expand All @@ -48,7 +48,7 @@ long apply(long v) {
abstract long apply(long v);
}

private final LongHeap heap;
private final TernaryLongHeap heap;
private final Order order;

// Used to track the number of neighbors visited during a single graph traversal
Expand All @@ -57,7 +57,7 @@ long apply(long v) {
private boolean incomplete;

public NeighborQueue(int initialSize, boolean maxHeap) {
this.heap = new LongHeap(initialSize);
this.heap = new TernaryLongHeap(initialSize);
this.order = maxHeap ? Order.MAX_HEAP : Order.MIN_HEAP;
}

Expand Down
Loading