Table of Contents

Internal classSealedInternal HnswSearchScratch

Namespace
Rowles.LeanLucene.Codecs.Hnsw
Assembly
Rowles.LeanLucene.dll

Reusable scratch buffers for one HNSW SearchLayer traversal. Borrow via Borrow(), dispose to return. A single instance per thread is held in System.ThreadStaticAttribute storage so steady-state queries avoid repeated System.Collections.Generic.HashSet`1 and System.Collections.Generic.PriorityQueue`2 allocations. Concurrent searches on the same thread (e.g. nested calls) fall back to a fresh allocation; only the outermost borrow uses the cached instance.

internal sealed class HnswSearchScratch : IDisposable
HnswSearchScratch

Fields

Private fieldStaticPrivate t_cached

Properties

Public propertyRead-only Frontier

Min-heap of frontier candidates by distance ascending.

Public propertyRead-only Results

Max-heap of result candidates by distance descending, capped at ef.

Public propertyRead-only Visited

Visited node set, cleared on borrow.

Methods

Public methodStatic Borrow()

Borrow the per-thread scratch. If it is already in use (a nested search on the same thread), a fresh instance is returned that bypasses the cache slot.

Public method Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.