Repository navigation
index: create indexes with names, waits and tuning options - #103
Merged
Merged
Conversation
Add lancedb_table_create_index, a single additive entry point that covers the SDK's common index creation options and the per-type tuning required by the published and current Go index APIs. The new LanceDBIndexOptions keeps omission distinct from explicit values: numeric fields use -1 for unset, boolean fields use -1 for unset and 0/1 for false/true, and strings use NULL for unset. This lets callers leave one FTS flag at the SDK default while explicitly setting another to false, which the existing per-type config structs cannot express. Numeric parameters are carried as int64 so every uint32 value and the -1 sentinel fit without truncation. The entry point also exposes the SDK index name, replace choice and builder-level wait_timeout. The wait is a polling budget, not a wall-clock bound, and native tables ignore it. LANCEDB_INDEX_AUTO remains the SDK Auto index rather than the Go Auto-to-IVF-PQ mapping. Raw index and distance enums are validated before conversion. Invalid ranges, invalid UTF-8, unsupported index types and SDK errors are returned with their messages. Existing create signatures, defaults and Go code are unchanged. Consumer tests cover a name distinct from the column, explicit replace false versus true, FTS and ngram options, vector IVF/PQ/HNSW tuning, cosine versus L2 changing a real query result, and invalid input ranges.
Replace the nearly collinear 256-row fixture with four controlled vectors whose L2 and cosine winners are far apart. Query without setting a metric, so the SDK uses the metric of the built index. The cosine case fails and returns row_0 if the creation option is dropped. Also document the actual remote create wait: servers that return a job ID use the SDK timeout on that job, legacy servers fall back to polling the named index, and reaching the budget does not cancel the submitted build. Native tables remain synchronous and ignore the option.
Reuse the checked enum conversions added by #86: LanceDBIndexType::from_c_int for the create index type and LanceDBDistanceType::from_c_int behind the optional -1 distance marker. Add a C17 helper for lancedb_table_create_index so the out-of-range index value stays an ordinary C integer, then assert the call is rejected and leaves the index list empty. The other generic-create and index-list cases are unchanged.
…eation-options # Conflicts: # tests/test_index.cpp
Xuanwo
added a commit
that referenced
this pull request
Nov 21, 2026
Run the declaration check against the host and the Windows MSVC LLP64 Clang target so LP64-equivalent spellings cannot hide an LLP64 ABI break. The target check uses Clang resource headers and a temporary empty stdlib.h shim, without building a Windows Rust library. Compare enumerator names as well as values, canonicalizing Rust variant names to the public LANCEDB_* spelling while ignoring declaration order. Make every checked c_int allowance name its expected C enum, including the #103 create-index API, and reject a wrong enum. Prove the layout comparison independently with an _Alignas-only fixture and require the exact offset diagnostic. Add a long-return fixture that passes on LP64 and fails on LLP64.
This was referenced Nov 21, 2026
Xuanwo
added a commit
that referenced
this pull request
Nov 22, 2026
* abi: verify public declarations against the Rust FFI Add a check-abi target that generates declarations from the production Rust FFI with pinned cbindgen and compares them with the hand-written header using clang ASTs and record layouts. It checks extern function names, return types, ordered arguments, pointer indirection, callback signatures, public struct layout and enum values, with narrow exceptions for checked c_int inputs and read-only result views. Run the check on the shared Ubuntu CI build and include temporary signature and layout drift fixtures so a parser or comparison regression is visible. Refs #99 * abi: record the read-only index statistics string view LanceDBIndexStatistics exposes borrowed const C strings while Rust keeps the owned pointers private for Drop, the same deliberate const view already recorded for LanceDBIndexInfo. The object layout and calling ABI are unchanged. * abi: cover the Windows data model and tighten drift fixtures Run the declaration check against the host and the Windows MSVC LLP64 Clang target so LP64-equivalent spellings cannot hide an LLP64 ABI break. The target check uses Clang resource headers and a temporary empty stdlib.h shim, without building a Windows Rust library. Compare enumerator names as well as values, canonicalizing Rust variant names to the public LANCEDB_* spelling while ignoring declaration order. Make every checked c_int allowance name its expected C enum, including the #103 create-index API, and reject a wrong enum. Prove the layout comparison independently with an _Alignas-only fixture and require the exact offset diagnostic. Add a long-return fixture that passes on LP64 and fails on LLP64.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
lancedb_table_create_index, a single additive entry point for the index creation options the published and current Go API need. It covers the SDK's common options (name,replace, builderwait_timeout) and per-type tuning for vector, scalar and FTS indexes.Existing
lancedb_table_create_{vector,scalar,fts}_indexsignatures and defaults are unchanged. Go is untouched.The branch merges #94's Windows short Cargo path and removes the retired Intel macOS package matrix entry so a fresh push does not launch
macos-15-intel. The standalone packaging PR owns the remaining script/docs references.Contract
LanceDBIndexOptionskeeps omission distinct from explicit values:-1for unset, so0is explicit;-1for unset,0/1for false/true;NULLfor unset;nameis NULL/empty for the SDK default;wait_timeout_msis 0 for no wait and positive for the SDK polling budget.Numeric fields are
int64_tso everyuint32_tvalue and the sentinel fit without truncation. Raw index and distance enum inputs are validated before conversion.LANCEDB_INDEX_AUTOremains the SDK Auto index rather than the Go Auto-to-IVF-PQ mapping.wait_timeout_msis documented for actual SDK behavior: native builds are synchronous and ignore it; remote servers returning a job ID wait on that job with the SDK timeout; a timeout does not cancel the submitted build. Legacy servers without a job ID poll the index's currentnum_unindexed_rows, so concurrent writes can extend the wait and a same-name prior index can satisfy it. The SDK submits the create/replace request before checking its two-hour budget cap, so an over-cap error can arrive after submission. Waiting does not cover rows added after creation.Verification
Consumer tests in the existing
lancedb_index_testsandlancedb_vector_index_testscover:replace=falseversustrue;distance_typechanges the result and fails the cosine assertion;Raw out-of-range index enum input remains covered by the C17 regression when #86 lands; the C++ suite no longer forms an out-of-range enumerator, which is not portable for an enum without a fixed underlying type.
Local light checks passed:
cargo fmt --check, public header as C17 with-Wall -Wextra -Werror, C++ test translation units with-fsyntax-only,git diff --check, and the packaging fixture tests. Hosted cargo/C++ jobs are the validation gate.