Lenin MookiahandLenin Mookiah 787ad381bf docs(rust): document and test num_threads for index optimization (#5359)
This PR fixes [issue
#4960](https://github.com/lancedb/lancedb/issues/4960).

Fixes #4960

The issue asks for a `num_threads` option on `OptimizeOptions`, like
`CompactionOptions::num_threads`, so index optimization can be held to a
CPU budget. LanceDB re-exports `OptimizeOptions` from `lance-index`, and
Lance added `OptimizeOptions::num_threads` / `with_num_threads` in
lance-format/lance#11154. The bump to Lance v16.0.0-beta.7 (#5352)
brought it in, and `OptimizeAction::Index(options)` already hands the
options through to `Dataset::optimize_indices` unchanged. So the Rust
option works today, but nothing in LanceDB says so or checks it.

This PR:

- documents the option on `OptimizeAction::Index`, with a
compile-checked example
(`OptimizeOptions::default().with_num_threads(2)`), what it limits
(compute stages of index optimization, not a process-wide thread cap),
that zero is rejected, and that index optimization runs on LanceDB
Embedded tables only;
- adds `test_optimize_index_with_num_threads`: on a table with 100
indexed and 100 unindexed rows, `with_num_threads(0)` returns an error
naming `num_threads` and leaves the index untouched, and
`with_num_threads(1)` then indexes all 200 rows.

No code paths change.

Possible SDK parity gap: the Python and TypeScript `optimize()`
convenience methods run the index step with default `OptimizeOptions`,
so they don't expose this limit yet. That would be a separate binding
change; I left it out of this PR.

## Testing

On macOS arm64, Rust 1.100.0 stable:

```
cargo test --profile ci -p lancedb --lib table::optimize::tests     # 24 passed, incl. test_optimize_index_with_num_threads
cargo test --profile ci -p lancedb --doc OptimizeAction             # 2 passed, incl. the new OptimizeAction::Index example
cargo fmt --all -- --check                                          # clean
```

As a check that the test exercises the pass-through, I temporarily made
`optimize_indices` ignore the caller's options and use
`OptimizeOptions::default()`; `test_optimize_index_with_num_threads`
then fails at the zero-value assertion. The test can't observe the
thread count itself, so the `with_num_threads(1)` case only shows a
limited run completes and indexes every row.

`cargo clippy -p lancedb --tests` on Rust 1.100 reports dead-code and
`if`-guard lints in other files (`job/profile.rs`, `table/add_data.rs`,
`table/write_progress.rs`, `table/query.rs`,
`table/computed_columns.rs`) with the default features; none in
`table/optimize.rs`.

Co-authored-by: Lenin Mookiah <2639584+leninworld@users.noreply.github.com>
2026-12-02 15:09:00 +00:00
2023-03-17 18:15:19 -07:00
2025-03-10 09:01:23 -07:00

Reverie LanceDB Website Blog Discord Twitter LinkedIn

LanceDB

The Multimodal Lakehouse for AI

How to Install ✦ Detailed Documentation ✦ Tutorials and Recipes ✦ Contributors

The ultimate multimodal data platform for AI/ML applications.

LanceDB is designed for fast, scalable, and production-ready vector search. It is built on top of the Lance columnar format. You can store, index, and search over petabytes of multimodal data and vectors with ease. LanceDB is a central location where developers can build, train and analyze their AI workloads.


Demo: Multimodal Search by Keyword, Vector or with SQL

LanceDB Multimodal Search

Star LanceDB to get updates!

⭐ Click here ⭐ to see how fast we're growing!

Key Features:

  • Fast Vector Search: Search billions of vectors in milliseconds with state-of-the-art indexing.
  • Comprehensive Search: Support for vector similarity search, full-text search and SQL.
  • Multimodal Support: Store, query and filter vectors, metadata and multimodal data (text, images, videos, point clouds, and more).
  • Advanced Features: Zero-copy, automatic versioning, manage versions of your data without needing extra infrastructure. GPU support in building vector index.

Products:

  • LanceDB Embedded (open source): 100% open source, runs in your application's process; your data can live on local disk or in object storage. No vendor lock-in.
  • LanceDB Enterprise: Production-scale distributed search, indexing, and maintenance. Plus, complete data sovereignty and security.

Ecosystem:

  • Columnar Storage: Built on the Lance columnar format for efficient storage and analytics.
  • Seamless Integration: Python, Node.js, Rust, and REST APIs for easy integration. Native Python and Javascript/Typescript support.
  • Rich Ecosystem: Integrations with LangChain 🦜️🔗, LlamaIndex 🦙, Apache-Arrow, Pandas, Polars, DuckDB and more on the way.

How to Install:

Follow the Quickstart doc to set up LanceDB locally.

API & SDK: We also support Python, Typescript and Rust SDKs

Interface Documentation
Python SDK https://lancedb.github.io/lancedb/python/python/
Typescript SDK https://lancedb.github.io/lancedb/js/globals/
Rust SDK https://docs.rs/lancedb/latest/lancedb/index.html
REST API https://docs.lancedb.com/api-reference/rest

Join Us and Contribute

We welcome contributions from everyone! Whether you're a developer, researcher, or just someone who wants to help out.

If you have any suggestions or feature requests, please feel free to open an issue on GitHub or discuss it on our Discord server.

Check out the GitHub Issues if you would like to work on the features that are planned for the future. If you have any suggestions or feature requests, please feel free to open an issue on GitHub.

Contributors

Stay in Touch With Us


Website Blog Discord Twitter LinkedIn

License

See LICENSE for the project license.

S
Description
Developer-friendly OSS embedded retrieval library for multimodal AI. Search More; Manage Less.
Readme Apache-2.0
128 MiB
Languages
Rust 53.9%
Python 35.8%
TypeScript 9.4%
Java 0.6%
Shell 0.2%