Mojo · Introspection

Introspection

from usearch import DenseReachability, DenseIndexDescription, Library, … 3.0.0-rc.1 · 4c3e5023

var description = index.describe()
print(description.size, description.memory_usage, library.cpu_class_name(description.cpu_class))  # the class dispatch picked
print(index.count(Key(integer=42)))  # entries sharing one key

var reachability = index.health()
print(reachability.reachable, "of", reachability.audited, "entries reachable")
print(library.version_name(), library.capabilities_available())

health audits how much of the graph a search reaches from its landmarks; entries it misses stay unfound until a refine re-links them.

API

StructDenseReachabilityOne reachability audit - usearch_reachability_t: the population it judged, and how much of it a search reaches.1
struct DenseReachability

Fields

auditedc_size_tEntries published when the audit started; compare reachable against this, never a later size.
reachablec_size_tOf those, the entries a search reaches; the rest no search finds until a refine re-links them.
sweepsc_size_tLevels the sweep took to converge.
back_sweepsc_size_tLevels the sweep back toward the entry point took, where an audit sweeps both ways.

Conforms to

Copyable, Defaultable, Deinitable, ImplicitlyCopyable, Movable
__init__Zeroes the audit, which is what a failed call leaves.
def __init__(out self)
StructDenseIndexDescriptionusearch_dense_index_description_t: a live index's frozen metadata and current counters.
struct DenseIndexDescription

Each counter is read once, so under concurrent insertions they may come from slightly different moments.

Fields

metadataDenseMetadataThe frozen metric, quantization, dimensions and connectivity, as a checkpoint reports them.
sizec_size_tStored entries.
capacityc_size_tEntries hosted without growing again.
memory_usagec_size_tBytes the handle holds; traversal scratch is the executor's.
cpu_classCpuClassThe CPU class dispatch picked on this machine; UNKNOWN for a device index.
gpu_classGpuClassThe GPU class dispatch picked on the index's devices; UNKNOWN for a host index.
shards_countc_size_tLive shards.

Conforms to

Copyable, Deinitable, Movable
StructLibraryA reference to the loaded engine, cheap to copy and shared by everything it creates.19
struct Library

Every handle carries one, which is what keeps the shared object mapped for as long as anything can still call into it. It is a loader reference and nothing more: an executor never retains an index, and an index never retains an executor.

Fields

sharedArcPointer[_Loaded]The handle and its symbols, refcounted so the last holder unmaps the object.

Conforms to

Copyable, Deinitable, ImplicitlyCopyable, Movable
__init__Opens the shared object and resolves it, which every handle then shares.
def __init__(out self)

Raises

With LIBRARY_MISSING, when nothing is on the loader path, with VERSION_MISMATCH when what loaded is another major version, or with SYMBOL_MISSING when it does not export an entry point the binding needs.
symbolsThe resolved entry points, borrowed rather than copied on every call.
def symbols(self) -> ref[self.shared.symbols] Symbols

Returns

A reference that stays valid for as long as this Library is held.
version_nameThe loaded engine's own version, which is also the cheapest check that loading worked. Calls usearch_version_name.
def version_name(self) -> String

Returns

The version string the shared object reports for itself.
capabilities_compiledThe hardware capabilities this build of the engine was compiled with. Calls usearch_capabilities_compiled.
def capabilities_compiled(self) -> String

Returns

A comma-separated list of capability names.
capabilities_availableThe hardware capabilities this machine offers now, which the build does not imply. Calls usearch_capabilities_available.
def capabilities_available(self) -> String

Returns

A comma-separated list of capability names.
status_nameThe engine's spelling of a status, "unrecognized" for a code it does not name. Calls usearch_status_name.
def status_name(self, status: Status) -> String
status_from_nameReads a spelling back; INVALID_ARGUMENT when unrecognized. Calls usearch_status_from_name.
def status_from_name(self, name: StringSpan) -> Status
scalar_nameThe engine's spelling of a scalar kind, as F32 spells "f32". Calls usearch_scalar_name.
def scalar_name(self, scalar: ScalarKind) -> String
scalar_from_nameReads a spelling back; UNKNOWN when unrecognized. Calls usearch_scalar_from_name.
def scalar_from_name(self, name: StringSpan) -> ScalarKind
residency_nameThe engine's spelling of a residency, as RAM spells "ram". Calls usearch_residency_name.
def residency_name(self, residency: Residency) -> String
residency_from_nameReads a spelling back; RAM when unrecognized. Calls usearch_residency_from_name.
def residency_from_name(self, name: StringSpan) -> Residency
traversal_nameThe engine's spelling of a traversal, as SCAN spells "scan". Calls usearch_traversal_name.
def traversal_name(self, traversal: Traversal) -> String
traversal_from_nameReads a spelling back; WALK when unrecognized. Calls usearch_traversal_from_name.
def traversal_from_name(self, name: StringSpan) -> Traversal
cpu_class_nameThe engine's spelling of a CPU class, as dispatch reports it. Calls usearch_cpu_class_name.
def cpu_class_name(self, cpu_class: CpuClass) -> String
gpu_class_nameThe engine's spelling of a GPU class, as dispatch reports it. Calls usearch_gpu_class_name.
def gpu_class_name(self, gpu_class: GpuClass) -> String
mood_nameThe engine's spelling of a mood, as PARKED spells "parked". Calls usearch_mood_name.
def mood_name(self, mood: Mood) -> String
mood_from_nameReads a spelling back; PARKED when unrecognized. Calls usearch_mood_from_name.
def mood_from_name(self, name: StringSpan) -> Mood
dense_metric_nameThe engine's spelling of a metric kind, as INNER spells "inner". Calls usearch_dense_metric_name.
def dense_metric_name(self, metric: DenseMetric) -> String
dense_metric_from_nameReads a spelling back; UNKNOWN when unrecognized. Calls usearch_dense_metric_from_name.
def dense_metric_from_name(self, name: StringSpan) -> DenseMetric
StructCpuClassThe CPU family dispatch picks, or a placement pins - usearch_cpu_class_t.
struct CpuClass

Fields

codec_intThe raw usearch_cpu_class_t value the ABI exchanges.

Values

UNKNOWNCpuClass(Int32(0))Derives the CPU's own class.

Conforms to

Copyable, Deinitable, Equatable, ImplicitlyCopyable, Movable, RegisterPassable, TrivialRegisterPassable
StructGpuClassThe GPU family dispatch picks, or a placement pins - usearch_gpu_class_t.
struct GpuClass

Fields

codec_intThe raw usearch_gpu_class_t value the ABI exchanges.

Values

UNKNOWNGpuClass(Int32(0))Derives the devices' own class.

Conforms to

Copyable, Deinitable, Equatable, ImplicitlyCopyable, Movable, RegisterPassable, TrivialRegisterPassable
StructNvmeClassThe NVMe I/O engine family an executor drives - usearch_nvme_class_t.
struct NvmeClass

Fields

codec_intThe raw usearch_nvme_class_t value the ABI exchanges.

Values

UNKNOWNNvmeClass(Int32(0))Derives the devices' own class.

Conforms to

Copyable, Deinitable, Equatable, ImplicitlyCopyable, Movable, RegisterPassable, TrivialRegisterPassable