Swift

USearch for Swift

USEARCH_SWIFT_ARTIFACT=build_swift/USearchC.xcframework swift build 3.0.0-rc.1 · 4c3e5023

It requires Swift 6.4 or newer, on macOS 15, iOS 18, tvOS 18, watchOS 11, visionOS 2, or Linux, and takes its matrix views and low-precision scalars from NumKong. It exposes dense indexes; sequence, matrix and geospatial indexes follow as the C library ships them.

Topics

InstallationThe package compiles the Swift surface only, and depends on NumKong as a source package.
QuickstartEvery verb is a batch over a RowsView: a base pointer, a row count, the values per row, the byte pitch between consecutive rows, and the scalar kind they hold.
Executors38An index says where its payload lives; an Executor says who walks it.
Keys8A key is sixteen opaque bytes, rendered as a lowercase dashed UUID.
Inputs and Outputs92Every output whose length only the call knows, such as matches, rows, products, monoliths and cursor or stream batches, lands in an Arena you pass, and the verb answers a view over it without copying.
Metrics52A DenseIndex holds equidimensional vectors under keys, and its verbs below take every receiver above.
Residency6Where 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.
Serialization53Checkpoints ride the SafeGraphs interchange format, and the path extension picks the layout: a .safegraphs monolith, or a .safegraphs.json manifest beside its shards.
Filtered Search2The predicate runs on the executor's threads, so it must be @Sendable and safe for concurrent use; an error it throws rejects that key.
Refinement23refine re-selects the neighbors of every stored entry against the finished graph and returns a DenseRefineReport: the entries re-selected and changed, the islands found and reconnected, and the closing audit.
Linear Algebra35Three verbs, multiply, maxsim and attend, treat the index as a sparse operand rather than as a kNN store, each folding its arithmetic into the graph walk instead of materializing a match list.
Retrieval and Streaming42get lands every vector stored under a key in its arena, one row per entry sharing the key, converted to the scalar kind as: names.
Introspection52health audits how much of the graph a search reaches from its landmarks; entries it misses stay unfound until a refine re-links them.
Errors27USearchError is the only error the SDK throws, and every method says so with throws(USearchError), so a catch reads error.status with no cast.
Platform Notes