Mojo · Keys

Keys

from usearch import Key 3.0.0-rc.1 · 4c3e5023

A key is 128 bits of opaque identity, rendered as a lowercase dashed UUID. Keys need not be unique: several entries may share one, and count reports how many.

var key = Key(integer=42)
print(key)                     # 00000000-0000-0000-0000-00000000002a
print(key.as_integer().value()) # 42

API

StructKeyThe sixteen opaque bytes naming one entry - usearch_key_t, in two words.3
struct Key

Mojo cannot put a UInt8 array in a register-passable struct, and a 16-lane SIMD would take an argument class the C ABI never gives a byte array, so the bytes cross as the two integers they occupy. Keys need not be unique: several entries may share one, which is what values_per_key and the late-interaction verb are for.

Fields

leadingUInt64Bytes 0 through 7, zero for an integer identity.
trailingUInt64Bytes 8 through 15, holding an integer identity big-endian.

Conforms to

Copyable, Deinitable, Equatable, ImplicitlyCopyable, Movable, RegisterPassable, TrivialRegisterPassable, Writable
__init__Builds the key an integer identity names, with the leading bytes zeroed.
def __init__(*, integer: UInt64) -> Self

Parameters

integerUInt64The identity to park in bytes 8 through 15, most significant byte first.
as_integerThe integer identity in bytes 8 through 15, and nothing when the leading ones are set.
def as_integer(self) -> Optional[UInt64]

Returns

The trailing word read big-endian, or None for a key whose leading bytes carry identity of their own and so has no 64-bit one.
write_toWrites the key as the lowercase dashed UUID the C header calls canonical. Binding-only.
def write_to(self, mut writer: T)

Parameters

writerTmutThe sink the key is appended to.