Skip to content

index: wait for named indices with a bounded timeout - #85

Merged
Xuanwo merged 8 commits into
mainfrom
xuanwo/add-named-index-wait
Nov 22, 2026
Merged

Xuanwo merged 8 commits into
mainfrom
xuanwo/add-named-index-wait

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

The C API can create, list and drop indices, but not wait for one. lancedb-go needs that operation for its WaitForIndex(ctx, names, timeout) contract, which today is implemented in its own cgo FFI, and a C consumer that starts an index build has no way to learn when the build has committed.

This adds lancedb_table_wait_for_index(table, index_names, num_index_names, timeout_ms, error_message), which binds the SDK's Table::wait_for_index. It blocks until every named index reports no unindexed rows, and returns LANCEDB_TIMEOUT when the budget no longer allows another polling round. The SDK's own error code and message reach the caller for everything else.

The budget is the SDK's polling budget, not a wall-clock bound: the SDK checks it between rounds, so the listing and statistics requests of a round, and the diagnostics it reads after the last one, complete after the budget has run out. The binding does not interrupt them.

The operation is deliberately narrow because the SDK is:

  • Every name is explicit and at least one is required. The SDK treats an empty slice as an immediate success after listing, so forwarding one would claim to have waited for every index when nothing was waited for.
  • The budget must be positive. The SDK turns a zero budget into an immediate timeout, which a caller cannot tell apart from a real timeout; a zero is a missing value, not an indefinite wait.
  • The maximum budget stays in the SDK. A budget above its two-hour cap is passed through, and its InvalidInput and message reach the caller, so the binding does not carry a second copy of the limit.
  • Waiting does not build or extend an index. An index built before new rows were added never becomes fully indexed by waiting; the header and docs/index.rst point at index creation and optimization instead.

Integration with the runtime rework: this branch is based on main and calls get_runtime(), which #76 replaces with run_blocking. A clean merge of the two therefore leaves the new wait call uncompilable, and the branch that lands second must move it onto run_blocking with an owned Table clone and owned names, because the spawned future must be 'static. Nothing else needs adapting, and no ordering is required: either branch can land first.

Verification: cargo fmt --check, cargo check and cargo clippy pass; the public header compiles as C, and the test translation unit compiles against it. The new cases in tests/test_index.cpp run in the existing lancedb_index_tests target on hosted CI, which is where the C++ suite runs for this change: the successful named wait, a missing index that times out, the SDK's rejection of an over-cap budget, and the invalid pointer, length, UTF-8 and zero-budget inputs, without long sleeps.

Expose the SDK's `Table::wait_for_index` so a caller can block until the
indices it names report no unindexed rows. The call takes explicit names
and a positive millisecond budget; the poll interval and the maximum
budget stay SDK behavior, and its errors, including the rejection of a
too-large budget, reach the caller unchanged. Waiting does not build an
index, so wait-all, zero and indefinite budgets are rejected instead of
being reinterpreted.
The SDK checks its budget between polling rounds, so the listing and
statistics requests of a round, and the diagnostics of the last round,
finish after the budget has run out. The binding does not interrupt them
and cannot promise a wall-clock bound.
Intel macOS is no longer a supported platform, so the matrix must not
launch the macos-15-intel runner. Package script and documentation
references are removed by the standalone packaging change.
…x-wait

# Conflicts:
#	include/lancedb.h
#	src/index.rs
@Xuanwo
Xuanwo merged commit 3a029ea into main Nov 22, 2026
15 checks passed
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