Skip to content

index: expose index names, columns and types - #90

Merged
Xuanwo merged 10 commits into
mainfrom
xuanwo/add-c-rich-index-listing
Nov 21, 2026
Merged

Xuanwo merged 10 commits into
mainfrom
xuanwo/add-c-rich-index-listing

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Summary

Add a rich index listing for the Go GetAllIndexes migration while keeping the existing names-only call unchanged.

  • LanceDBIndexInfo { name, columns, num_columns, index_type }
  • lancedb_table_list_indices_info() backed by the SDK's Table::list_indices / IndexConfig
  • lancedb_free_index_info() releases the owned strings and array

index_type is IndexType::to_string() from the SDK, so types the C enum does not know (including future or custom values) survive. An empty table returns count = 0 and a NULL array. If column-array allocation fails or a string contains an interior NUL, the call drops partial results, leaves the outputs NULL/0, and returns LANCEDB_UNKNOWN. Rust allocations follow the library’s normal out-of-memory behavior.

Scope: rich stats, loss, creation options, prewarm (#83), wait (#85), enum validation (#75) and index optimization (#74) stay out.

SDK compatibility

Checked IndexConfig and list_indices() in pinned lancedb 0.33.0 and target v0.42.0-beta.21: both expose name: String, columns: Vec<String>, index_type: IndexType, and IndexType: Display. The test observes the BTREE and BITMAP type strings.

Validation

  • cargo fmt --check
  • cargo check --lib
  • cargo clippy --lib -- -D warnings
  • GCC C17 and G++ C++20 -fsyntax-only against the public header
  • g++ -std=c++20 -fsyntax-only tests/test_index_info.cpp with the system Arrow/Catch2 headers
  • Hosted CI runs lancedb_index_tests under valgrind; the regression creates BTREE on key and BITMAP on category, verifies both metadata entries, the distinct SDK-assigned names (key_idx, category_idx), their types, and that the names-only list is unchanged.

A local heavy C/C++ build and valgrind run was not started because C #75 held the host build lease at dispatch time.

Integration

Add lancedb_table_list_indices_info() and LanceDBIndexInfo, backed by the SDK's Table::list_indices and IndexConfig. The new call returns the full index name, the ordered column list and the SDK index type string, while lancedb_table_list_indices() keeps returning names only.

The result owns every string and the column array and is released with lancedb_free_index_info(). Empty listings return a NULL array and count zero; allocation and UTF-8 conversion failures release the partial result and report LANCEDB_OTHER.

The C++ regression creates BTREE and BITMAP indices on distinct columns, checks both metadata entries against the SDK-assigned names and types, and verifies the names-only list is unchanged.

Signed-off-by: Xuanwo <[email protected]>
Convert the index name, type and columns into Rust-owned CString values before building the C result. This removes the partially initialized C struct and its per-field null checks; a failure now only has to free the entries completed before the failing one. The column array is always allocated, so every returned entry has one freeable array even when the SDK reports no columns.

Signed-off-by: Xuanwo <[email protected]>
Build each LanceDBIndexInfo only after all of its strings are converted, let Drop release the owned strings and column array, and free the returned slice through Box. A conversion failure now drops the already built entries, so the listing no longer needs a manual partial-result cleanup path. The public free function still accepts a NULL pointer.

Signed-off-by: Xuanwo <[email protected]>
Keep the pointers and count that Drop trusts private on the Rust side, and make the C view const at every level: the returned object array, the name and type strings, the nested column pointers and the column count. The free operation accepts the same const view. This prevents ordinary C callers from replacing an owned pointer or changing a length before the matching free, without changing the repr(C) layout or calling ABI.

Signed-off-by: Xuanwo <[email protected]>
Xuanwo dropped Intel macOS support. Remove only the x86_64-apple-darwin matrix entry so a fresh push does not launch macos-15-intel. The packaging script and documentation cleanup ships separately.

Signed-off-by: Xuanwo <[email protected]>
@Xuanwo
Xuanwo merged commit 7bd514f into main Nov 21, 2026
12 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