Repository navigation
Description
The 3.0 release candidate on main is insert-only: clear, refine, absorb, split and compact reshape an index, but nothing removes individual entries.
The 2.x removal marked nodes as deleted and reused their slots in place, which leaked memory, stranded neighbors and raced with concurrent inserts, as the issues and PRs below show.
Proposed Semantics
Removal becomes an exclusive, whole-index operation in the spirit of usearch_dense_clear, rather than a per-entry tombstone.
- It takes a batch of keys and drops every entry stored under them, all of them for a key holding several, skipping absent keys.
- It holds the handle exclusively: any call in flight refuses it with
usearch_status_contended_k, and calls arriving meanwhile are refused the same way. - It renumbers the survivors densely within each shard, so the 32-bit node IDs stay compact, and reclaims the memory of removed entries.
- It re-links every survivor that pointed at a removed entry and any island left behind; a caller wanting a broader re-selection follows with
usearch_dense_refine. - An NVMe view refuses it with
usearch_status_read_only_k, like every other mutating verb.
Keys are passed explicitly rather than chosen by a predicate.
A caller wanting predicate-driven removal pulls keys with a cursor, filters them on its own side, and passes the batch.
Proposed C API
/** The arguments of @c usearch_dense_remove. */
typedef struct usearch_dense_remove_t {
/** The handle to remove entries from. */
usearch_dense_index_t index;
/** The executor to fan out over; its kind must match the residency. */
usearch_executor_t executor;
/** Output for the outcome, final once its status leaves @c usearch_status_deferred_k. */
usearch_outcome_t* outcome;
/** Blocking, the default, or deferred. */
usearch_completion_t completion;
/** Keys to remove - the batch axis of @c keys. */
size_t count;
/** The identities whose entries are removed. */
usearch_keys_view_t keys;
/** The @b optional output for the entries removed; @c NULL skips reporting. */
size_t* removed;
} usearch_dense_remove_t;
/**
* @brief Removes every entry stored under the given keys, renumbering the survivors densely,
* reclaiming their memory and re-linking the graph around the gaps.
*/
USEARCH_EXPORT void usearch_dense_remove(usearch_dense_remove_t* arguments);Related
This issue replaces the 2.x removal reports and fixes: #835, #726, #700, #562, #396 and #323, and PRs #838, #841, #844, #821 and #801.
Activity