# Refinement

> USearch for Go

`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:

```go
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.

```go
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.

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

`import "github.com/unum-cloud/USearch/golang"`

## DenseAbsorbConfig

DenseAbsorbConfig carries the optional settings of Absorb.

```go
type DenseAbsorbConfig struct {
    Progress ProgressCallback
    ProgressSteps uint
}
```

- `Progress` `ProgressCallback`: Progress reports the donors absorbed and stops between them wherever it says to.
- `ProgressSteps` `uint`: ProgressSteps bounds the reports Progress hears, the last at completion; zero derives to ten.

## DenseRefineConfig

DenseRefineConfig carries the optional settings of Refine.

```go
type DenseRefineConfig struct {
    ExpansionFactor uint
    Progress ProgressCallback
    ProgressSteps uint
    Stats *DenseTraversalStats
}
```

A zero value derives every setting.

- `ExpansionFactor` `uint`: ExpansionFactor is the breadth of the candidates the re-selection walk explores; zero derives it from the geometry.
- `Progress` `ProgressCallback`: Progress reports the nodes swept and stops wherever it says to.
- `ProgressSteps` `uint`: ProgressSteps bounds the reports Progress hears, the last at completion; zero derives to ten.
- `Stats` `*DenseTraversalStats`: Stats is where the traversal telemetry lands, overwritten by the call.

## DenseRefineReport

DenseRefineReport is what one Refine, Absorb or Split did to the graph.

```go
type DenseRefineReport struct {
    Reselected uint
    Changed uint
    IslandsFound uint
    IslandsReconnected uint
    Reachability DenseReachability
}
```

- `Reselected` `uint`: Reselected counts the entries whose neighbors were selected again, the islands of every heal round included.
- `Changed` `uint`: Changed counts those whose neighbor set gained a member it lacked; zero means settled.
- `IslandsFound` `uint`: IslandsFound counts the entries the first audit found not reached both ways.
- `IslandsReconnected` `uint`: IslandsReconnected counts the links written between an island and a reached entry.
- `Reachability` `DenseReachability`: Reachability is the audit closing the heal, as a fresh Health right after would take it.

## DenseSplitConfig

DenseSplitConfig carries the optional settings of Split.

```go
type DenseSplitConfig struct {
    Seed uint64
    ExpansionFactor uint
    Progress ProgressCallback
    ProgressSteps uint
    Stats *DenseTraversalStats
}
```

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

