Skip to content

index: create indexes with names, waits and tuning options - #103

Merged
Xuanwo merged 13 commits into
mainfrom
xuanwo/add-c-index-creation-options
Nov 21, 2026
Merged

Xuanwo merged 13 commits into
mainfrom
xuanwo/add-c-index-creation-options

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

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, builder wait_timeout) and per-type tuning for vector, scalar and FTS indexes.

Existing lancedb_table_create_{vector,scalar,fts}_index signatures 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

LanceDBIndexOptions keeps omission distinct from explicit values:

  • numeric tuning fields use -1 for unset, so 0 is explicit;
  • boolean fields use -1 for unset, 0/1 for false/true;
  • strings use NULL for unset;
  • name is NULL/empty for the SDK default;
  • wait_timeout_ms is 0 for no wait and positive for the SDK polling budget.

Numeric fields are int64_t so every uint32_t value and the sentinel fit without truncation. Raw index and distance enum inputs are validated before conversion. LANCEDB_INDEX_AUTO remains the SDK Auto index rather than the Go Auto-to-IVF-PQ mapping.

wait_timeout_ms is 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 current num_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_tests and lancedb_vector_index_tests cover:

  • a name distinct from the column, and explicit replace=false versus true;
  • full FTS and ngram options;
  • IVF, PQ and HNSW tuning accepted and visible through the custom index name;
  • a deterministic 4-row fixture where L2 and cosine winners are far apart, querying without a metric so the SDK uses the built index metric; dropping the creation distance_type changes the result and fails the cosine assertion;
  • null pointers, zero columns, invalid UTF-8, out-of-range distance/bool/numeric values, and width overflow.

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.

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
Xuanwo merged commit c970c99 into main Nov 21, 2026
14 checks passed
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.
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.
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