from usearch import DenseVectors, DenseBatch, DenseDraws, …3.0.0-rc.1 · 4c3e5023
get exports every entry stored under one key, one row per entry in insertion order, as DenseVectors, whose every row is exactly columns() values wide, as the engine reported them, however far apart the engine laid the rows.
var stored = index.get[DType.float32](Key(integer=42), arena) # empty when the key is absent
A cursor walks the contents, writing each batch in the arena; next_keys walks the key column alone, and next_links lands the keys each entry links to beside it, while the vectors come from get.
Without start keys it yields every entry as stored; cursor(starts) yields the starts’ own entries first, then the entries those link to breadth-first, each once.
var cursor = index.on(executor).cursor()while True: var batch = cursor.next_links(1024, arena) # empty once exhausted if len(batch) == 0: break print(batch.keys()[0], len(batch.links(0)))
A search stream is a resumable best-first traversal, so callers that post-filter aggressively pull until satisfied instead of guessing “k” upfront.
No residency of the engine implements the stream yet, so it answers Status.UNSUPPORTED.
var stream = index.on(executor).search_stream(RowsView.of(query, 768))while True: var pulled = stream.next(16, arena) # one query of Matches, empty once drained if len(pulled.query_keys(0)) == 0: break
Cursors and streams open on the blocking receivers alone, the index and index.on(executor), and every pull blocks.
Both borrow the index and the executor, so neither can be released while a cursor or a stream lives, and a drained one answers an empty view rather than raising.
sample draws keys around focus, or across the whole index, each hanging from a shown or earlier draw and placed in three dimensions beside the shown keys already on screen, so a view grows one connected sample as it zooms.
Equal seeds, shown keys and focus draw equally, and a larger wanted draws a superset.
StructDenseDrawsThe draws sample wrote into its arena, read in place: each draw's key, which of that key's entries it is, the shown or earlier draw it hangs from, and where it is placed.5
struct DenseDraws[origin: MutOrigin]
Parameters
originMutOrigin
comptime
The arena the draws live in, which this result borrows.
The start keys at starts; zero walks every entry as stored.
startsInt
The first start key, or NULL_ADDRESS for none.
Raises
Error if the residency has no cursor, as VRAM does not.
__deinit__Releases the cursor. Calls usearch_dense_cursor_free.
def __deinit__(deinit self)
The loader reference is surrendered only after the call: reading the entry point is the
last use of library, so without the trailing move Mojo drops the last reference - and
dlcloses the engine - between the load and the branch to it.
next_keysCopies up to wanted next keys into a lent arena, skipping their links. Calls usearch_dense_cursor_next.
Best-first traversal is naturally pausable, so the stream keeps the walk's frontier and visited
set between pulls. Callers that post-filter aggressively pull until satisfied instead of
guessing "k" upfront. Ordering beyond the expansion horizon is best-effort nearest rather than
globally exact.
Parameters
originImmOrigin
comptime
The index, the executor, and the query row, which the stream borrows.
The breadth of the candidates the walk explores; zero derives.
Raises
Error with UNSUPPORTED while no residency implements the stream.
__deinit__Releases the stream and the walk state it keeps. Calls usearch_dense_search_stream_free.
def __deinit__(deinit self)
The loader reference is surrendered only after the call: reading the entry point is the
last use of library, so without the trailing move Mojo drops the last reference - and
dlcloses the engine - between the load and the branch to it.
nextPulls up to wanted next-nearest matches into a lent arena, as the one query of a search. Calls usearch_dense_search_stream_next.