C# · Retrieval and Streaming

Retrieval and Streaming

3.0.0-rc.1 · 4c3e5023

DenseVectors vectors = index.On(pool).Get(key, arena, Scalar.F32);  // Every entry under the key, zero-copy
ReadOnlySpan<float> first = vectors.Row<float>(0);                  // As wide as vectors.Columns

using DenseCursor cursor = index.On(pool).Cursor();    // Each entry once, in storage order; `Cursor([key])` walks out from a key
for (DenseBatch batch = cursor.Next(128, arena); batch.Count != 0; batch = cursor.Next(128, arena))
{
    ReadOnlySpan<Key> page = batch.Keys;               // Pass `links: true` for `batch.Links(entry)`; vectors come from `Get`
}

using DenseSearchStream stream = index.On(pool).SearchStream(RowsView.RowsOf<float>(vector, dimensions: 3));
QueryMatches nearer = stream.Next(8, arena);             // Resumable nearest-neighbor stream

A cursor or stream keeps walk state rather than a thread, pulls on the executor of the receiver that opened it, and keeps its index alive until disposed. Every pull takes its arena, so one arena serves a scan and any other verb between pulls, and a drained pull answers an empty view.

§ Sampling

Sample drawn = index.On(pool).Sample(
    256, arena, new DenseSampleConfig { Shown = shown, ShownCoordinates = shownXyz, Focus = near, Seed = 42 });

Sample draws keys around a focus, each hanging from a shown or earlier draw, and places them in three dimensions beside the keys already shown, so a view grows one connected sample as it zooms. Its Keys, EntryOrdinals, Parents and Coordinates read in place from the arena.