Zig · Residency

Residency

const usearch = @import("usearch");const Residency = @import("usearch").Residency; 3.0.0-rc.1 · 4c3e5023

Where the payload lives is the constructor’s name, as in the C lifecycle verbs, so a residency an index lacks has no constructor to call. Each names the hardware its shards are placed across, one shard per memory domain, device or path, and an empty slice derives one from the machine.

// One graph per socket.
var in_memory = try usearch.DenseIndex.initRam(.{ .dimensions = 768 }, &.{ 0, 1 });
// Sharded across the devices, never replicated.
var on_device = try usearch.DenseIndex.initVram(.{ .dimensions = 768 }, &.{ 0, 1 });
// Served in place, read-only, and sized past RAM.
var on_disk = try usearch.DenseIndex.viewNvme("index.safegraphs.json", .{
    .executor = nvme_executor,
    .paths = &.{.of("/mnt/nvme0")},
});

An NVMe index is never initialized, only viewed in place, and it is read-only, so every mutating verb on it fails with Error.ReadOnly. Until NVMe checkpoints carry keys, viewNvme answers Error.Unsupported.

API

Types

DenseReserveOne DenseIndex.reserve, as a Deferred holds it.
pub const DenseReserve = struct

Fields

capacityusize
outcomeOutcome
DenseClearOne DenseIndex.clear, as a Deferred holds it.
pub const DenseClear = struct

Fields

outcomeOutcome
EnumResidencyWhere an index's payload lives and which engine traverses it - the vocabulary the lifecycle verbs spell in their names, as DenseIndex.initVram does.2
types.zig:358 ↗
pub const Residency = enum(c_int)

Kept for its name table.

Values

ram1Volatile-memory index traversed by CPU threads.
vram2Accelerator-memory index traversed by GPU warps.
nvme3Persisted index traversed through pluggable I/O engines.
nameThe canonical spelling, as .ram spells "ram".
types.zig:367 ↗
pub fn name(self: Residency) [:0]const u8

Calls usearch_residency_name.

fromNameReads a spelling back, or null when no residency spells it.
types.zig:372 ↗
pub fn fromName(text: []const u8) ?Residency

Calls usearch_residency_from_name.