Skip to content

Bind stable vector handles during planning#19

Merged
anoop-narang merged 2 commits intomainfrom
prepare-stable-vector-handle
Apr 6, 2026
Merged

Bind stable vector handles during planning#19
anoop-narang merged 2 commits intomainfrom
prepare-stable-vector-handle

Conversation

@anoop-narang
Copy link
Copy Markdown
Collaborator

Summary

This changes the vector resolver contract from ensure_loaded() to prepare(),
and binds a stable Arc<RegisteredTable> during planning.

Why

Previously the planner and executor could re-resolve the registry entry in
separate steps, which left a handoff gap if the active vector index changed
mid-query.

With this change:

  • the planner prepares the loaded table once
  • execution uses that exact prepared handle
  • in-flight queries keep using the same registered table even if a newer one is loaded later

Changes

  • replace async resolver method ensure_loaded() with prepare()
  • make prepare() return Arc<RegisteredTable>
  • update USearchExecPlanner to bind the prepared table during planning
  • remove the execute-time resolver reload path
  • update UDTF docs to reflect the new contract

Validation

  • cargo test

claude[bot]
claude Bot previously approved these changes Apr 6, 2026
Comment thread src/planner.rs
Comment on lines 241 to 257
@@ -261,6 +256,24 @@ struct SearchParams {
provider_scan: Option<Arc<dyn ExecutionPlan>>,
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that registered is stored directly in SearchParams, the four fields schema, key_col, scalar_kind, and brute_force_threshold are redundant copies of registered.schema, registered.key_col, registered.scalar_kind, and registered.config.brute_force_selectivity_threshold. Since RegisteredTable is immutable after construction there's no correctness risk, but it doubles the storage for these values and means future readers have to wonder whether they might diverge.

Suggestion: remove the four flat fields and access them via params.registered.* at the call sites. The only call site that needs schema independently of registered is USearchExec::new (for PlanProperties) and RecordBatchStreamAdapter::new — both can use params.registered.schema.clone() directly.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 85a83a6 — removed the four redundant flat fields from SearchParams and access them via params.registered.* at all call sites.

Access schema, key_col, scalar_kind, and brute_force_threshold
through params.registered.* instead of duplicating them as flat
fields on SearchParams.
@anoop-narang anoop-narang merged commit f21e8a4 into main Apr 6, 2026
5 checks passed
@anoop-narang anoop-narang deleted the prepare-stable-vector-handle branch April 6, 2026 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant