JavaScript · Refinement

Refinement

import * as usearch from 'usearch'; 3.0.0-rc.1 · 4c3e5023

A cheap insertion pass followed by one refinement reaches a better graph, in less total time, than a single expensive insertion pass:

const pool = index.on(executor);
pool.insert(keys, vectors, { expansionFactor: 32 });
while (pool.refine({ expansionFactor: 128 }).changed > vectors.rows / 100) {}

Each call answers a DenseRefineReport: the entries re-selected and changed, the islands found and reconnected, and the closing reachability audit.

Refinement is a build step rather than a repair. It adds and removes nothing, and searches may run throughout.

§ Absorbing & Splitting

Bigger indexes come from absorbing, never mutating: absorb appends every donor in turn, keeping its graph and linking it in across the appended part, and a donor the library consumed refuses every later verb with Status.Uninitialized. A donor it did not absorb, like one of another scalar refused with Status.ConfigMismatch, stays a live index you still own, though its entries may already have moved. A deferred absorb holds its donors until it is final, so meanwhile they refuse every verb and no other absorb can name them.

index.on(executor).absorb([shard]);

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 answer the closing refines’ report, as refine does.

index.on(executor).split([left, right], { seed: 42 });

API

Types

DenseRefineConfigOptional per-call settings of the refinement pass that follows an insertion.
usearch.ts:99 ↗
interface DenseRefineConfig

Fields

expansionFactor?numberBreadth of the candidates the re-selection walk explores; absent lets the engine derive it.
stats?DenseTraversalStatsThe reading this call overwrites with its own telemetry; absent skips reporting.
DenseSplitConfigOptional per-call settings of a split.
usearch.ts:107 ↗
interface DenseSplitConfig

Fields

seed?number | bigintPicks the part roots: equal seeds over an unchanged index split equally.
expansionFactor?numberBreadth of the candidates of the closing refines' walks; absent lets the engine derive it.
DenseRefineReportWhat one refine, absorb or split did to the graph.
usearch.ts:316 ↗
interface DenseRefineReport

Fields

reselectednumberEntries whose neighbors were selected again, the islands of every heal round included.
changednumberOf those, the entries whose neighbor set gained a member it lacked; zero means settled.
islandsFoundnumberEntries the first audit found not reached both ways.
islandsReconnectednumberLinks 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.