Mojo · Refinement

Refinement

from usearch import DenseRefineReport, DenseRefineConfig 3.0.0-rc.1 · 4c3e5023

refine re-runs the neighbor selection over entries already in the graph, returning a DenseRefineReport: the entries re-selected and changed, the islands found and reconnected, and the closing audit. A batch built at a low expansion factor reaches the quality of a slower build afterwards, and changed reaching zero is what settled looks like:

while index.on(executor).refine(DenseRefineConfig(expansion_factor=128)).changed != 0:
    pass

§ Absorbing & Splitting

Bigger indexes come from absorbing, never mutating: absorb takes its donors by value, appends each one’s entries with its graph, then refines across the appended part, and the engine frees each donor it absorbs. split is the inverse: it hands graph-local parts of the index to empty receivers of the same configuration, one part each, keeping their edges and leaving the index empty but live. Both report the closing refines as refine does.

var donors = List[DenseIndex]()
donors.append(shard^)
_ = index.on(executor).absorb(donors^)
_ = index.on(executor).split(receivers, seed=42)

API

StructDenseRefineReportWhat one refine, absorb or split did to the graph - usearch_refine_report_t.1
struct DenseRefineReport

Fields

reselectedc_size_tEntries whose neighbors were selected again, the islands of every heal round included.
changedc_size_tOf those, the entries whose neighbor set gained a member it lacked; zero means settled.
islands_foundc_size_tEntries the first audit found not reached both ways.
islands_reconnectedc_size_tLinks written between an island and an entry the audit reached both ways.
reachabilityDenseReachabilityThe audit closing the heal, as a fresh health right after would take it.

Conforms to

Copyable, Defaultable, Deinitable, ImplicitlyCopyable, Movable
__init__Zeroes the report, which is what a failed call leaves.
def __init__(out self)
StructDenseRefineConfigThe knobs of usearch_dense_refine_t; zeroed or absent ones derive what the C interface derives.1
struct DenseRefineConfig[stats_origin: MutOrigin = MutUntrackedOrigin]

Parameters

stats_originMutOrigincomptimeThe lent telemetry slot's origin, inferred where one is lent.

Fields

expansion_factorIntThe breadth of the candidates the re-selection walk explores; zero derives.
statsOptional[Pointer[DenseTraversalStats, stats_origin]]Receives this call's traversal telemetry, fully overwritten; absent skips reporting.

Conforms to

Copyable, Deinitable, ImplicitlyCopyable, Movable
__init__Names only the knobs that differ from the derived ones.
def __init__(
    out self,
    *,
    expansion_factor: Int = Int(0),
    stats: Optional[Pointer[DenseTraversalStats, stats_origin]] = Optional()
)

Parameters

expansion_factorIntThe breadth of the candidates the re-selection walk explores; zero derives.
statsOptional[Pointer[DenseTraversalStats, stats_origin]]Receives this call's traversal telemetry; absent skips reporting.