Go · Refinement

Refinement

import "github.com/unum-cloud/USearch/golang" 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 can be brought up to the quality of a slower build afterwards, and Changed reaching zero is what settled looks like:

for {
	report, err := index.On(executor).Refine(&usearch.DenseRefineConfig{ExpansionFactor: 128})
	if err != nil {
		log.Fatal(err)
}
	if report.Changed == 0 {
		break
}
}

§ Absorbing

Absorb moves donor indexes into one, one after another, keeping their graphs rather than re-inserting their vectors, then refines every shard that took one across the appended part. A donor must share the index’s residency, scalar, metric and geometry, or the call answers StatusConfigMismatch. Each absorbed donor is consumed, and every later verb on it reports StatusUninitialized; a stop between donors, or a failure, leaves the rest live, still yours to close.

report, err := index.On(executor).Absorb([]*usearch.DenseIndex{first, second}, nil)

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.

report, err := index.On(executor).Split([]*usearch.DenseIndex{left, right}, &usearch.DenseSplitConfig{Seed: 42})

API

Types

DenseAbsorbConfigDenseAbsorbConfig carries the optional settings of Absorb.
types.go:461 ↗
type DenseAbsorbConfig struct {
    Progress ProgressCallback
    ProgressSteps uint
}

Fields

ProgressProgressCallbackProgress reports the donors absorbed and stops between them wherever it says to.
ProgressStepsuintProgressSteps bounds the reports Progress hears, the last at completion; zero derives to ten.
DenseRefineConfigDenseRefineConfig carries the optional settings of Refine.
types.go:373 ↗
type DenseRefineConfig struct {
    ExpansionFactor uint
    Progress ProgressCallback
    ProgressSteps uint
    Stats *DenseTraversalStats
}

A zero value derives every setting.

Fields

ExpansionFactoruintExpansionFactor is the breadth of the candidates the re-selection walk explores; zero derives it from the geometry.
ProgressProgressCallbackProgress reports the nodes swept and stops wherever it says to.
ProgressStepsuintProgressSteps bounds the reports Progress hears, the last at completion; zero derives to ten.
Stats*DenseTraversalStatsStats is where the traversal telemetry lands, overwritten by the call.
DenseRefineReportDenseRefineReport is what one Refine, Absorb or Split did to the graph.
types.go:218 ↗
type DenseRefineReport struct {
    Reselected uint
    Changed uint
    IslandsFound uint
    IslandsReconnected uint
    Reachability DenseReachability
}

Fields

ReselecteduintReselected counts the entries whose neighbors were selected again, the islands of every heal round included.
ChangeduintChanged counts those whose neighbor set gained a member it lacked; zero means settled.
IslandsFounduintIslandsFound counts the entries the first audit found not reached both ways.
IslandsReconnecteduintIslandsReconnected counts the links written between an island and a reached entry.
ReachabilityDenseReachabilityReachability is the audit closing the heal, as a fresh Health right after would take it.
DenseSplitConfigDenseSplitConfig carries the optional settings of Split.
types.go:469 ↗
type DenseSplitConfig struct {
    Seed uint64
    ExpansionFactor uint
    Progress ProgressCallback
    ProgressSteps uint
    Stats *DenseTraversalStats
}

Fields

Seeduint64Seed picks the part roots: equal seeds over an unchanged index split equally.
ExpansionFactoruintExpansionFactor is the breadth of the candidates of the closing refines' walks; zero derives.
ProgressProgressCallbackProgress reports the nodes the closing refines re-selected; a stop never undoes a move.
ProgressStepsuintProgressSteps bounds the reports Progress hears, the last at completion; zero derives to ten.
Stats*DenseTraversalStatsStats is where the traversal telemetry lands, overwritten by the call.