### Example Directory Structure Source: https://docs.rs/lancedb/latest/lancedb/database/listing/struct.ListingDatabase.html?search=u32+-%3E+bool A representation of how directory names map to table names in a ListingDatabase. ```text /data /table1.lance /table2.lance ``` -------------------------------- ### Arc clone_from_ref Example Source: https://docs.rs/lancedb/latest/lancedb/table/write_progress/type.ProgressCallback.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates constructing an Arc from a reference using the nightly-only experimental API. ```rust #![feature(clone_from_ref)] use std::sync::Arc; let hello: Arc = Arc::clone_from_ref("hello"); ``` -------------------------------- ### Configure Progress Tracking Source: https://docs.rs/lancedb/latest/lancedb/table/struct.AddDataBuilder.html?search= Example of using the progress method to monitor the status of an add operation via a callback. ```rust let batch = arrow_array::record_batch!(("id", Int32, [1, 2, 3])).unwrap(); table.add(batch) .progress(|p| println!("{}/{:?} rows", p.output_rows(), p.total_rows())) .execute() .await?; ``` -------------------------------- ### Open a Table with Branch and Version Source: https://docs.rs/lancedb/latest/lancedb/connection/struct.OpenTableBuilder.html?search= Example of opening a table scoped to a specific branch and pinned to a specific version. ```rust let table = conn.open_table("t").branch("exp").version(3).execute().await?; ``` -------------------------------- ### Construct Pin with new Source: https://docs.rs/lancedb/latest/lancedb/arrow/type.SendableRecordBatchStream.html Example of creating a Pin using the new method for Unpin types. ```rust use std::pin::Pin; let mut val: u8 = 5; // Since `val` doesn't care about being moved, we can safely create a "facade" `Pin` // which will allow `val` to participate in `Pin`-bound apis without checking that // pinning guarantees are actually upheld. let mut pinned: Pin<&mut u8> = Pin::new(&mut val); ``` -------------------------------- ### SQL Filter Examples Source: https://docs.rs/lancedb/latest/lancedb/query/trait.QueryBase.html?search= Examples of SQL query strings used with the only_if method. ```sql x > 10 y > 0 AND y < 100 x > 5 OR y = 'test' ``` -------------------------------- ### Demonstrating ambiguous Pin conversion Source: https://docs.rs/lancedb/latest/lancedb/arrow/type.BoxedRecordBatchReader.html?search= An example of an discouraged implementation of From for Pin that introduces ambiguity. ```rust struct Foo; // A type defined in this crate. impl From> for Pin { fn from(_: Box<()>) -> Pin { Pin::new(Foo) } } ``` -------------------------------- ### Convert Box to Raw Pointer Source: https://docs.rs/lancedb/latest/lancedb/arrow/type.BoxedRecordBatchReader.html?search= Examples demonstrating how to consume a Box into a raw pointer and perform cleanup. ```rust let x = Box::new(String::from("Hello")); let ptr = Box::into_raw(x); let x = unsafe { Box::from_raw(ptr) }; ``` ```rust use std::alloc::{dealloc, Layout}; use std::ptr; let x = Box::new(String::from("Hello")); let ptr = Box::into_raw(x); unsafe { ptr::drop_in_place(ptr); dealloc(ptr as *mut u8, Layout::new::()); } ``` ```rust let x = Box::new(String::from("Hello")); let ptr = Box::into_raw(x); unsafe { drop(Box::from_raw(ptr)); } ``` -------------------------------- ### Arc try_clone_from_ref Example Source: https://docs.rs/lancedb/latest/lancedb/table/write_progress/type.ProgressCallback.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates constructing an Arc from a reference with error handling for allocation failures. ```rust #![feature(clone_from_ref)] #![feature(allocator_api)] use std::sync::Arc; let hello: Arc = Arc::try_clone_from_ref("hello")?; ``` -------------------------------- ### Clone Arc from Reference Source: https://docs.rs/lancedb/latest/lancedb/table/write_progress/type.ProgressCallback.html?search= Examples demonstrating the use of nightly-only experimental APIs for cloning Arc references. ```rust #![feature(clone_from_ref)] use std::sync::Arc; let hello: Arc = Arc::clone_from_ref("hello"); ``` ```rust #![feature(clone_from_ref)] #![feature(allocator_api)] use std::sync::Arc; let hello: Arc = Arc::try_clone_from_ref("hello")?; ``` -------------------------------- ### pub async fn uri(&self) -> Result Source: https://docs.rs/lancedb/latest/lancedb/table/struct.Table.html Get the table URI (storage location). ```APIDOC ## pub async fn uri(&self) -> Result ### Description Get the table URI (storage location). Returns the full storage location of the table. ``` -------------------------------- ### Convert Box to raw pointer with allocator Source: https://docs.rs/lancedb/latest/lancedb/arrow/type.BoxedRecordBatchReader.html?search= Demonstrates consuming a Box into a raw pointer and allocator, with examples for automatic and manual memory cleanup. ```rust #![feature(allocator_api)] use std::alloc::System; let x = Box::new_in(String::from("Hello"), System); let (ptr, alloc) = Box::into_raw_with_allocator(x); let x = unsafe { Box::from_raw_in(ptr, alloc) }; ``` ```rust #![feature(allocator_api)] use std::alloc::{Allocator, Layout, System}; use std::ptr::{self, NonNull}; let x = Box::new_in(String::from("Hello"), System); let (ptr, alloc) = Box::into_raw_with_allocator(x); unsafe { ptr::drop_in_place(ptr); let non_null = NonNull::new_unchecked(ptr); alloc.deallocate(non_null.cast(), Layout::new::()); } ``` -------------------------------- ### connect_with_options Source: https://docs.rs/lancedb/latest/lancedb/database/listing/struct.ListingDatabase.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Connects to a listing database located at a specified URI path. The URI should point to a directory containing the tables. ```APIDOC ## pub async fn connect_with_options(request: &ConnectRequest) -> Result ### Description Connects to a listing database. The URI provided in the request should be a path to a directory where the tables are stored. ### Parameters - **request** (&ConnectRequest) - Required - The connection request containing the URI and storage options. ``` -------------------------------- ### set_lsm_write_spec Source: https://docs.rs/lancedb/latest/lancedb/table/struct.Table.html Install an LsmWriteSpec on this table. ```APIDOC ## pub async fn set_lsm_write_spec(&self, spec: LsmWriteSpec) -> Result<()> ### Description Install an LsmWriteSpec on this table, selecting Lance’s MemWAL LSM-style write path for future merge_insert calls. ``` -------------------------------- ### TakeQuery Implementation Methods Source: https://docs.rs/lancedb/latest/lancedb/query/struct.TakeQuery.html?search= Methods for initializing and configuring a TakeQuery instance. ```rust pub fn from_offsets(parent: Arc, offsets: Vec) -> Self ``` ```rust pub fn from_row_ids(parent: Arc, row_ids: Vec) -> Self ``` ```rust pub fn into_request(self) -> QueryRequest ``` ```rust pub fn current_request(&self) -> &QueryRequest ``` ```rust pub fn select(self, selection: Select) -> Self ``` ```rust pub fn with_row_id(self) -> Self ``` -------------------------------- ### Create a scalar index with full configuration Source: https://docs.rs/lancedb/latest/lancedb/index/struct.IndexBuilder.html Demonstrates setting multiple options including training, naming, and replacement behavior. ```rust use lancedb::{connect, index::{Index, scalar::BitmapIndexBuilder}}; let db = connect("data/sample-lancedb").execute().await?; let table = db.open_table("my_table").execute().await?; // Create a bitmap index with full configuration table .create_index(&["status"], Index::Bitmap(BitmapIndexBuilder::default())) .name("status_bitmap_index".to_string()) .train(true) // Train the index with existing data .replace(false) // Don't replace if index already exists .execute() .await?; ``` -------------------------------- ### get Source: https://docs.rs/lancedb/latest/lancedb/table/struct.LanceTags.html Retrieves the contents of a specific tag. ```APIDOC ## pub async fn get(&self, tag: &str) -> Result ### Description Fetches the TagContents for the specified tag name. ``` -------------------------------- ### Initialize LanceNamespaceDatabase from client Source: https://docs.rs/lancedb/latest/lancedb/database/namespace/struct.LanceNamespaceDatabase.html?search=std%3A%3Avec Constructor method for creating a database instance from an existing namespace client. ```rust pub fn from_namespace_client( namespace_client: Arc, namespace_client_impl: String, namespace_client_properties: HashMap, storage_options: HashMap, read_consistency_interval: Option, session: Option>, namespace_client_pushdown_operations: HashSet, ) -> Self ``` -------------------------------- ### get() Source: https://docs.rs/lancedb/latest/lancedb/embeddings/trait.EmbeddingRegistry.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Retrieves an embedding function by its name. ```APIDOC ## fn get(&self, name: &str) -> Option> ### Description Retrieves an embedding function from the registry by its name. ### Parameters - **name** (&str) - The name of the embedding function to retrieve. ### Returns - **Option>** - Returns the embedding function if found, otherwise None. ``` -------------------------------- ### Get Tag Contents Source: https://docs.rs/lancedb/latest/lancedb/table/struct.LanceTags.html?search=std%3A%3Avec Retrieves the contents of a specific tag. ```rust pub async fn get(&self, tag: &str) -> Result ``` -------------------------------- ### connect_with_options Source: https://docs.rs/lancedb/latest/lancedb/database/listing/struct.ListingDatabase.html?search= Connects to a listing database located at a specified URI path. ```APIDOC ## pub async fn connect_with_options(request: &ConnectRequest) -> Result ### Description Connects to a listing database. The URI should be a path to a directory where the tables are stored. ### Parameters - **request** (&ConnectRequest) - Required - The connection request containing the URI and storage options. ``` -------------------------------- ### get_opts Source: https://docs.rs/lancedb/latest/lancedb/arrow/type.BoxedRecordBatchReader.html Performs a get request for an object at a specific location with options. ```APIDOC ## fn get_opts ### Description Perform a get request with options. ### Parameters - **location** (Path) - The path of the object to retrieve. - **options** (GetOptions) - Configuration options for the get operation. ``` -------------------------------- ### BoostQuery::new Source: https://docs.rs/lancedb/latest/lancedb/index/scalar/struct.BoostQuery.html?search=u32+-%3E+bool Creates a new instance of BoostQuery. ```APIDOC ## pub fn new(positive: FtsQuery, negative: FtsQuery, negative_boost: Option) -> BoostQuery ### Description Creates a new BoostQuery instance with the specified positive and negative FtsQuery components and an optional negative boost value. ### Parameters - **positive** (FtsQuery) - The positive query component. - **negative** (FtsQuery) - The negative query component. - **negative_boost** (Option) - Optional boost factor for the negative component. ``` -------------------------------- ### get_opts Source: https://docs.rs/lancedb/latest/lancedb/arrow/type.BoxedRecordBatchReader.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Performs a get request for an object at a specific location with options. ```APIDOC ## fn get_opts ### Description Perform a get request with options to retrieve an object. ### Parameters - **location** (Path) - The path of the object to retrieve. - **options** (GetOptions) - Configuration options for the retrieval. ``` -------------------------------- ### pub async fn list_versions(&self) -> Result> Source: https://docs.rs/lancedb/latest/lancedb/table/struct.Table.html List all the versions of the table. ```APIDOC ## pub async fn list_versions(&self) -> Result> ### Description List all the versions of the table. ``` -------------------------------- ### LanceNamespaceDatabase Implementation Methods Source: https://docs.rs/lancedb/latest/lancedb/database/namespace/struct.LanceNamespaceDatabase.html Methods for initializing and connecting to a LanceNamespaceDatabase instance. ```rust pub fn from_namespace_client( namespace_client: Arc, namespace_client_impl: String, namespace_client_properties: HashMap, storage_options: HashMap, read_consistency_interval: Option, session: Option>, namespace_client_pushdown_operations: HashSet, ) -> Self ``` ```rust pub async fn connect( ns_impl: &str, ns_properties: HashMap, storage_options: HashMap, read_consistency_interval: Option, session: Option>, pushdown_operations: HashSet, ) -> Result ``` -------------------------------- ### as_mut Source: https://docs.rs/lancedb/latest/lancedb/arrow/type.SendableRecordBatchStream.html?search=u32+-%3E+bool Gets a mutable reference to the pinned value this Pin points to. ```APIDOC ## pub fn as_mut(&mut self) -> Pin<&mut ::Target> ### Description Gets a mutable reference to the pinned value this `Pin` points to. This is useful when doing multiple calls to functions that consume the pinning pointer. ``` -------------------------------- ### Connect with storage options Source: https://docs.rs/lancedb/latest/lancedb/index.html?search=std%3A%3Avec Configure database connection with specific storage credentials using ConnectBuilder. ```rust let db = lancedb::connect("data/sample-lancedb") .storage_options([ ("aws_access_key_id", "some_key"), ("aws_secret_access_key", "some_secret"), ]) .execute() .await .unwrap(); ``` -------------------------------- ### as_ref Source: https://docs.rs/lancedb/latest/lancedb/arrow/type.SendableRecordBatchStream.html?search=u32+-%3E+bool Gets a shared reference to the pinned value this Pin points to. ```APIDOC ## pub fn as_ref(&self) -> Pin<&::Target> ### Description Gets a shared reference to the pinned value this `Pin` points to. This is a generic method to go from `&Pin>` to `Pin<&T>`. ``` -------------------------------- ### explain_plan Source: https://docs.rs/lancedb/latest/lancedb/query/struct.Query.html Generates an explanation of the query execution plan. ```APIDOC ## async fn explain_plan(&self, verbose: bool) -> Result ### Description Returns a string representation of the query execution plan. ### Parameters - **verbose** (bool) - Required - Whether to include detailed information in the plan explanation. ``` -------------------------------- ### Unwrap Pin with into_inner Source: https://docs.rs/lancedb/latest/lancedb/arrow/type.SendableRecordBatchStream.html Example of unwrapping a Pin to retrieve the underlying pointer. ```rust use std::pin::Pin; let mut val: u8 = 5; let pinned: Pin<&mut u8> = Pin::new(&mut val); // Unwrap the pin to get the underlying mutable reference to the value. We can do // this because `val` doesn't care about being moved, so the `Pin` was just // a "facade" anyway. let r = Pin::into_inner(pinned); assert_eq!(*r, 5); ``` -------------------------------- ### Get Tag Version Source: https://docs.rs/lancedb/latest/lancedb/table/struct.LanceTags.html?search=std%3A%3Avec Retrieves the version number associated with a specific tag. ```rust pub async fn get_version(&self, tag: &str) -> Result ``` -------------------------------- ### Get Stream Size Hint Source: https://docs.rs/lancedb/latest/lancedb/table/struct.DatasetRecordBatchStream.html?search=std%3A%3Avec Returns the bounds on the remaining length of the stream. ```rust fn size_hint(&self) -> (usize, Option) ``` -------------------------------- ### connect_with_options Source: https://docs.rs/lancedb/latest/lancedb/database/listing/struct.ListingDatabase.html?search=u32+-%3E+bool Connects to a listing database located at a specified URI path. This method requires a ConnectRequest object and returns a Result containing the ListingDatabase instance. ```APIDOC ## pub async fn connect_with_options(request: &ConnectRequest) -> Result ### Description Connect to a listing database. The URI provided in the request should be a path to a directory where the tables are stored. ### Parameters - **request** (&ConnectRequest) - Required - The connection request containing the URI and storage options. ``` -------------------------------- ### as_deref_mut Source: https://docs.rs/lancedb/latest/lancedb/arrow/type.SendableRecordBatchStream.html?search=u32+-%3E+bool Gets Pin<&mut T> to the underlying pinned value from this nested Pin-pointer. ```APIDOC ## pub fn as_deref_mut(self: Pin<&mut Pin>) -> Pin<&mut ::Target> ### Description Gets `Pin<&mut T>` to the underlying pinned value from this nested `Pin`-pointer. This is a generic method to go from `Pin<&mut Pin>>` to `Pin<&mut T>`. ``` -------------------------------- ### analyze_plan_with_options Source: https://docs.rs/lancedb/latest/lancedb/query/struct.Query.html Executes the query and returns runtime metrics. ```APIDOC ## async fn analyze_plan_with_options(&self, options: QueryExecutionOptions) -> Result ### Description Executes the query and returns a string containing runtime metrics and analysis of the execution plan. ### Parameters - **options** (QueryExecutionOptions) - Required - Configuration options for query execution. ``` -------------------------------- ### pub async fn from_path Source: https://docs.rs/lancedb/latest/lancedb/table/struct.BranchContents.html?search=std%3A%3Avec Loads the BranchContents from a given path and object store. ```APIDOC ## pub async fn from_path(path: &Path, object_store: &ObjectStore, branch_name: &str) -> Result ### Description Loads the branch contents from the specified path and object store using the provided branch name. ### Parameters - **path** (&Path) - The file system path to the branch data. - **object_store** (&ObjectStore) - The object store instance used for storage operations. - **branch_name** (&str) - The name of the branch to retrieve. ### Returns - **Result** - Returns the BranchContents struct on success, or an Error if the operation fails. ``` -------------------------------- ### Get Result references with as_ref Source: https://docs.rs/lancedb/latest/lancedb/error/type.Result.html?search= Converts a Result reference into a Result containing references. ```rust let x: Result = Ok(2); assert_eq!(x.as_ref(), Ok(&2)); let x: Result = Err("Error"); assert_eq!(x.as_ref(), Err(&"Error")); ``` -------------------------------- ### pub async fn from_path Source: https://docs.rs/lancedb/latest/lancedb/table/struct.TagContents.html?search= Loads TagContents from a given path using the provided object store. ```APIDOC ## pub async fn from_path(path: &Path, object_store: &ObjectStore) -> Result ### Description Loads the TagContents structure from the specified file path using the provided object store instance. ### Parameters - **path** (&Path) - Required - The file path to the tag contents. - **object_store** (&ObjectStore) - Required - The object store instance used to access the path. ### Returns - **Result** - Returns the loaded TagContents struct on success, or an Error if the operation fails. ``` -------------------------------- ### Alias Expressions with Metadata Source: https://docs.rs/lancedb/latest/lancedb/expr/enum.DfExpr.html?search= Examples of applying aliases to expressions while attaching optional field metadata. ```rust let metadata = HashMap::from([("key".to_string(), "value".to_string())]); let metadata = FieldMetadata::from(metadata); let expr = col("foo").alias_with_metadata("bar", Some(metadata)); ``` ```rust let metadata = HashMap::from([("key".to_string(), "value".to_string())]); let metadata = FieldMetadata::from(metadata); let expr = col("foo").alias_qualified_with_metadata(Some("tbl"), "bar", Some(metadata)); ``` -------------------------------- ### connect_with_options Source: https://docs.rs/lancedb/latest/lancedb/database/listing/struct.ListingDatabase.html Connects to a listing database located at a specified URI path. This method uses the provided ConnectRequest to configure the connection. ```APIDOC ## pub async fn connect_with_options(request: &ConnectRequest) -> Result ### Description Connects to a listing database where tables are stored as directories in the base path of the object store. The URI provided in the request should point to the directory containing the tables. ### Parameters - **request** (&ConnectRequest) - Required - The connection configuration, including the URI and storage options. ``` -------------------------------- ### Leaking Box memory Source: https://docs.rs/lancedb/latest/lancedb/arrow/type.BoxedRecordBatchReader.html?search= Examples of consuming a Box to return a mutable reference with a static lifetime. ```rust let x = Box::new(41); let static_ref: &'static mut usize = Box::leak(x); *static_ref += 1; assert_eq!(*static_ref, 42); ``` ```rust let x = vec![1, 2, 3].into_boxed_slice(); let static_ref = Box::leak(x); static_ref[0] = 4; assert_eq!(*static_ref, [4, 2, 3]); ``` -------------------------------- ### Create BlobFile instances Source: https://docs.rs/lancedb/latest/lancedb/blob/struct.BlobFile.html?search= Constructors for different blob storage types. ```rust pub fn new_inline( object_store: Arc, path: Path, position: u64, size: u64, ) -> BlobFile ``` ```rust pub fn new_dedicated( object_store: Arc, path: Path, size: u64, ) -> BlobFile ``` ```rust pub fn new_packed( object_store: Arc, path: Path, position: u64, size: u64, ) -> BlobFile ``` ```rust pub fn new_external( object_store: Arc, path: Path, uri: String, position: u64, size: u64, ) -> BlobFile ``` -------------------------------- ### connect_with_options Source: https://docs.rs/lancedb/latest/lancedb/database/listing/struct.ListingDatabase.html?search=std%3A%3Avec Connects to a listing database located at a specified directory path. This method uses the provided ConnectRequest to configure the connection. ```APIDOC ## pub async fn connect_with_options(request: &ConnectRequest) -> Result ### Description Connect to a listing database where tables are stored as directories in the base path of the object store. ### Parameters - **request** (&ConnectRequest) - Required - The connection request containing the URI path to the directory and optional storage configurations. ``` -------------------------------- ### Convert Box to NonNull Pointer Source: https://docs.rs/lancedb/latest/lancedb/arrow/type.BoxedRecordBatchReader.html?search= Examples for the nightly-only API to consume a Box into a NonNull pointer. ```rust #![feature(box_vec_non_null)] let x = Box::new(String::from("Hello")); let non_null = Box::into_non_null(x); let x = unsafe { Box::from_non_null(non_null) }; ``` ```rust #![feature(box_vec_non_null)] use std::alloc::{dealloc, Layout}; let x = Box::new(String::from("Hello")); let non_null = Box::into_non_null(x); unsafe { non_null.drop_in_place(); dealloc(non_null.as_ptr().cast::(), Layout::new::()); } ``` ```rust #![feature(box_vec_non_null)] let x = Box::new(String::from("Hello")); let non_null = Box::into_non_null(x); unsafe { drop(Box::from_non_null(non_null)); } ``` -------------------------------- ### create_namespace Source: https://docs.rs/lancedb/latest/lancedb/database/namespace/struct.LanceNamespaceDatabase.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Create a new namespace. ```APIDOC ## create_namespace(request: CreateNamespaceRequest) ### Description Create a new namespace in the database. ### Parameters - **request** (CreateNamespaceRequest) - The request object containing details for the new namespace. ### Returns - **Future>** - A future resolving to the creation result. ``` -------------------------------- ### Session::new Source: https://docs.rs/lancedb/latest/lancedb/struct.Session.html Creates a new Session instance with specified cache sizes and an object store registry. ```APIDOC ## Session::new ### Description Creates a new session with defined capacities for index and metadata caches, and a provided object store registry. ### Signature `pub fn new(index_cache_size: usize, metadata_cache_size: usize, store_registry: Arc) -> Session` ### Parameters - **index_cache_size** (usize) - The size of the index cache. - **metadata_cache_size** (usize) - The size of the metadata cache. - **store_registry** (Arc) - The object store registry to use when opening datasets. ``` -------------------------------- ### Binary Expression Representation Source: https://docs.rs/lancedb/latest/lancedb/expr/enum.DfExpr.html?search= An example showing how the logical expression 'A + 1' is represented using the BinaryExpr variant. ```rust BinaryExpr { left: Expr::Column("A"), op: Operator::Plus, right: Expr::Literal(ScalarValue::Int32(Some(1)), None) } ``` -------------------------------- ### Constructing expressions with the expression builder Source: https://docs.rs/lancedb/latest/lancedb/expr/index.html?search= Demonstrates basic usage of column references, literal values, logical operators, and arithmetic operations. ```rust use std::ops::Mul; use lancedb::expr::{col, lit}; let expr = col("age").gt(lit(18)); let expr = col("age").gt(lit(18)).and(col("status").eq(lit("active"))); let expr = col("price") * lit(1.1); ``` -------------------------------- ### Construct Box from NonNull pointer Source: https://docs.rs/lancedb/latest/lancedb/arrow/type.BoxedRecordBatchReader.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Examples of creating a Box from a NonNull pointer using Box::from_non_null. ```rust #![feature(box_vec_non_null)] let x = Box::new(5); let non_null = Box::into_non_null(x); let x = unsafe { Box::from_non_null(non_null) }; ``` ```rust #![feature(box_vec_non_null)] use std::alloc::{alloc, Layout}; use std::ptr::NonNull; unsafe { let non_null = NonNull::new(alloc(Layout::new::()).cast::()) .expect("allocation failed"); // In general .write is required to avoid attempting to destruct // the (uninitialized) previous contents of `non_null`. non_null.write(5); let x = Box::from_non_null(non_null); } ``` -------------------------------- ### pub async fn checkout(&self, version: u64) -> Result<()> Source: https://docs.rs/lancedb/latest/lancedb/table/struct.Table.html Checks out a specific version of the Table. ```APIDOC ## pub async fn checkout(&self, version: u64) -> Result<()> ### Description Checks out a specific version of the Table. Any read operation on the table will now access the data at the checked out version. This is a read-only operation. ``` -------------------------------- ### Create a basic vector index Source: https://docs.rs/lancedb/latest/lancedb/index/struct.IndexBuilder.html Initializes a vector index using default settings on a specified column. ```rust use lancedb::{connect, index::{Index, vector::IvfPqIndexBuilder}}; let db = connect("data/sample-lancedb").execute().await?; let table = db.open_table("my_table").execute().await?; // Create a vector index with default settings table .create_index(&["vector"], Index::IvfPq(IvfPqIndexBuilder::default())) .execute() .await?; ``` -------------------------------- ### pub async fn from_path Source: https://docs.rs/lancedb/latest/lancedb/table/struct.BranchContents.html Loads the BranchContents from a specified path within the object store for a given branch name. ```APIDOC ## pub async fn from_path(path: &Path, object_store: &ObjectStore, branch_name: &str) -> Result ### Description Retrieves the branch contents by reading from the provided path and object store for the specified branch name. ### Parameters - **path** (&Path) - The file system or object store path to the branch data. - **object_store** (&ObjectStore) - The object store instance used to access the data. - **branch_name** (&str) - The name of the branch to retrieve. ### Returns - **Result** - Returns the BranchContents struct on success, or an Error if the operation fails. ``` -------------------------------- ### Get Result mutable references with as_mut Source: https://docs.rs/lancedb/latest/lancedb/error/type.Result.html?search= Converts a mutable Result reference into a Result containing mutable references. ```rust fn mutate(r: &mut Result) { match r.as_mut() { Ok(v) => *v = 42, Err(e) => *e = 0, } } let mut x: Result = Ok(2); mutate(&mut x); assert_eq!(x.unwrap(), 42); let mut x: Result = Err(13); mutate(&mut x); assert_eq!(x.unwrap_err(), 0); ``` -------------------------------- ### Connect to LanceNamespaceDatabase Source: https://docs.rs/lancedb/latest/lancedb/database/namespace/struct.LanceNamespaceDatabase.html?search=std%3A%3Avec Asynchronous method to establish a connection to the database using namespace configuration. ```rust pub async fn connect( ns_impl: &str, ns_properties: HashMap, storage_options: HashMap, read_consistency_interval: Option, session: Option>, pushdown_operations: HashSet, ) -> Result ``` -------------------------------- ### IndexBuilder::execute Source: https://docs.rs/lancedb/latest/lancedb/index/struct.IndexBuilder.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Executes the index creation process. ```APIDOC ## pub async fn execute(self) -> Result<()> ### Description Finalizes the configuration and executes the index creation operation. ``` -------------------------------- ### Get mutable reference to Arc Source: https://docs.rs/lancedb/latest/lancedb/table/write_progress/type.ProgressCallback.html?search= Returns a mutable reference if there are no other Arc or Weak pointers. Use make_mut if cloning is required. ```rust use std::sync::Arc; let mut x = Arc::new(3); *Arc::get_mut(&mut x).unwrap() = 4; assert_eq!(*x, 4); let _y = Arc::clone(&x); assert!(Arc::get_mut(&mut x).is_none()); ``` -------------------------------- ### pub async fn index_stats(&self, index_name: impl AsRef) -> Result> Source: https://docs.rs/lancedb/latest/lancedb/table/struct.Table.html Get statistics about an index. ```APIDOC ## pub async fn index_stats(&self, index_name: impl AsRef) -> Result> ### Description Get statistics about an index. Returns None if the index does not exist. ``` -------------------------------- ### ObjectStoreRegistry Methods Source: https://docs.rs/lancedb/latest/lancedb/struct.ObjectStoreRegistry.html?search= Methods for interacting with the registry, including creating instances, retrieving providers, and managing active stores. ```rust pub fn empty() -> ObjectStoreRegistry ``` ```rust pub fn get_provider(&self, scheme: &str) -> Option> ``` ```rust pub fn active_stores(&self) -> Vec> ``` ```rust pub fn stats(&self) -> ObjectStoreRegistryStats ``` ```rust pub async fn get_store( &self, base_path: Url, params: &ObjectStoreParams, ) -> Result, Error> ``` ```rust pub fn calculate_object_store_prefix( &self, uri: &str, storage_options: Option<&HashMap>, ) -> Result ``` ```rust pub fn insert(&self, scheme: &str, provider: Arc) ``` -------------------------------- ### pub async fn restore(&self) -> Result<()> Source: https://docs.rs/lancedb/latest/lancedb/table/struct.Table.html Restore the table to the currently checked out version. ```APIDOC ## pub async fn restore(&self) -> Result<()> ### Description Restore the table to the currently checked out version. This operation will overwrite the latest version of the table with a previous version. ``` -------------------------------- ### Get expression data type using ExprSchemable Source: https://docs.rs/lancedb/latest/lancedb/expr/enum.DfExpr.html?search= Demonstrates how to determine the resulting Arrow DataType of an expression given a specific schema. ```rust fn main() { let expr = col("c1") + col("c2"); let schema = DFSchema::from_unqualified_fields( vec![ Field::new("c1", DataType::Int32, true), Field::new("c2", DataType::Float32, true), ] .into(), HashMap::new(), ) .unwrap(); assert_eq!("Float32", format!("{}", expr.get_type(&schema).unwrap())); } ``` -------------------------------- ### Create a table Source: https://docs.rs/lancedb/latest/lancedb/index.html?search=u32+-%3E+bool Define a schema using arrow-rs and create a table from a RecordBatch. ```rust use arrow_array::{RecordBatch, RecordBatchIterator}; use arrow_schema::{DataType, Field, Schema}; let ndims = 128; let schema = Arc::new(Schema::new(vec![ Field::new("id", DataType::Int32, false), Field::new( "vector", DataType::FixedSizeList(Arc::new(Field::new("item", DataType::Float32, true)), ndims), true, ), ])); let data = RecordBatch::try_new( schema.clone(), vec![ Arc::new(Int32Array::from_iter_values(0..256)), Arc::new( FixedSizeListArray::from_iter_primitive::( (0..256).map(|_| Some(vec![Some(1.0); ndims as usize])), ndims, ), ), ], ) .unwrap(); db.create_table("my_table", data) .execute() .await .unwrap(); ``` -------------------------------- ### Convert Box to NonNull pointer with allocator Source: https://docs.rs/lancedb/latest/lancedb/arrow/type.BoxedRecordBatchReader.html?search= Demonstrates consuming a Box into a NonNull pointer and allocator, with examples for automatic and manual memory cleanup. ```rust #![feature(allocator_api)] use std::alloc::System; let x = Box::new_in(String::from("Hello"), System); let (non_null, alloc) = Box::into_non_null_with_allocator(x); let x = unsafe { Box::from_non_null_in(non_null, alloc) }; ``` ```rust #![feature(allocator_api)] use std::alloc::{Allocator, Layout, System}; let x = Box::new_in(String::from("Hello"), System); let (non_null, alloc) = Box::into_non_null_with_allocator(x); unsafe { non_null.drop_in_place(); alloc.deallocate(non_null.cast::(), Layout::new::()); } ``` -------------------------------- ### OptimizeOptions Builder Methods Source: https://docs.rs/lancedb/latest/lancedb/table/struct.OptimizeOptions.html Methods for initializing and configuring the OptimizeOptions struct. ```APIDOC ## OptimizeOptions Methods ### new() Creates a new instance of OptimizeOptions. ### merge(num: usize) Creates an OptimizeOptions instance configured for merging. ### append() Creates an OptimizeOptions instance configured for appending. ### retrain() Creates an OptimizeOptions instance configured for retraining. ### num_indices_to_merge(num: Option) Sets the number of indices to merge. ### index_names(names: Vec) Sets the specific index names to be optimized. ### transaction_properties(properties: HashMap) Sets transaction properties to store in the commit manifest. ### progress(progress: Arc) Sets a progress callback for index building during optimization. ``` -------------------------------- ### PermutationReader Initialization Methods Source: https://docs.rs/lancedb/latest/lancedb/dataloader/permutation/reader/struct.PermutationReader.html?search= Methods for creating and configuring a new PermutationReader instance. ```rust pub async fn inner_new( base_table: Arc, permutation_table: Option>, split: u64, ) -> Result ``` ```rust pub async fn try_from_tables( base_table: Arc, permutation_table: Arc, split: u64, ) -> Result ``` ```rust pub async fn identity(base_table: Arc) -> Self ``` ```rust pub async fn with_offset(self, offset: u64) -> Result ``` ```rust pub async fn with_limit(self, limit: u64) -> Result ``` -------------------------------- ### Displaying Expressions Source: https://docs.rs/lancedb/latest/lancedb/expr/enum.DfExpr.html?search= Demonstrates different ways to format expressions for debugging, SQL-like representation, or human-readable output. ```rust let expr = col("c1") + lit(42); assert_eq!(format!("{expr:?}"), "BinaryExpr(BinaryExpr { left: Column(Column { relation: None, name: \"c1\" }), op: Plus, right: Literal(Int32(42), None) })"); ``` ```rust let expr = col("c1") + lit(42); assert_eq!(format!("{expr}"), "c1 + Int32(42)"); ``` ```rust let expr = col("c1") + lit(42); assert_eq!(format!("{}", expr.human_display()), "c1 + 42"); ``` -------------------------------- ### pub async fn from_path Source: https://docs.rs/lancedb/latest/lancedb/table/struct.BranchContents.html?search= Retrieves the BranchContents from a specified path and object store. ```APIDOC ## pub async fn from_path(path: &Path, object_store: &ObjectStore, branch_name: &str) -> Result ### Description Retrieves the BranchContents for a given branch name from the specified object store path. ### Parameters - **path** (&Path) - The path to the branch data. - **object_store** (&ObjectStore) - The object store instance to read from. - **branch_name** (&str) - The name of the branch to retrieve. ### Returns - **Result** - Returns the BranchContents struct on success, or an Error if the operation fails. ``` -------------------------------- ### pub async fn version(&self) -> Result Source: https://docs.rs/lancedb/latest/lancedb/table/struct.Table.html Retrieve the current version of the table. ```APIDOC ## pub async fn version(&self) -> Result ### Description Retrieve the version of the table. Every operation that modifies the table increases the version number. ``` -------------------------------- ### Connect to a LanceDB database Source: https://docs.rs/lancedb/latest/lancedb/connection/fn.connect.html Initializes a connection to a database located at the provided URI, which can be a local path or cloud storage. ```rust pub fn connect(uri: &str) -> ConnectBuilder ``` -------------------------------- ### Connect to a ListingDatabase Source: https://docs.rs/lancedb/latest/lancedb/database/listing/struct.ListingDatabase.html Connects to a directory-based database using the provided connection request options. ```rust pub async fn connect_with_options(request: &ConnectRequest) -> Result ``` -------------------------------- ### Clone from reference Source: https://docs.rs/lancedb/latest/lancedb/arrow/type.BoxedRecordBatchReader.html?search= Experimental APIs to allocate memory on the heap and clone a source reference into it. ```rust #![feature(clone_from_ref)] let hello: Box = Box::clone_from_ref("hello"); ``` ```rust #![feature(clone_from_ref)] #![feature(allocator_api)] let hello: Box = Box::try_clone_from_ref("hello")?; ``` -------------------------------- ### Configure Index Builder Methods Source: https://docs.rs/lancedb/latest/lancedb/index/vector/struct.IvfFlatIndexBuilder.html?search=std%3A%3Avec Methods for configuring the IVF Flat index builder, including distance metrics, partition counts, sampling rates, and training iterations. ```rust pub fn distance_type(self, distance_type: DistanceType) -> Self ``` ```rust pub fn num_partitions(self, num_partitions: u32) -> Self ``` ```rust pub fn sample_rate(self, sample_rate: u32) -> Self ``` ```rust pub fn max_iterations(self, max_iterations: u32) -> Self ``` ```rust pub fn target_partition_size(self, target_partition_size: u32) -> Self ``` -------------------------------- ### Configure Namespace Client Source: https://docs.rs/lancedb/latest/lancedb/table/struct.NativeTable.html?search=std%3A%3Avec Sets the namespace client for server-side query execution. ```rust pub fn with_namespace_client( self, namespace_client: Arc, ) -> Self ``` -------------------------------- ### MatchQuery Configuration Methods Source: https://docs.rs/lancedb/latest/lancedb/index/scalar/struct.MatchQuery.html?search= Methods to configure the MatchQuery instance using a builder-like pattern. ```APIDOC ## Configuration Methods - **with_column(column: Option)**: Sets the target column for the search. - **with_boost(boost: f32)**: Sets the boost factor for the query. - **with_fuzziness(fuzziness: Option)**: Configures the fuzziness level for matching. - **with_max_expansions(max_expansions: usize)**: Sets the maximum number of terms to expand for fuzzy matching (default: 50). - **with_operator(operator: Operator)**: Sets the operator for combining terms (And/Or, default: Or). - **with_prefix_length(prefix_length: u32)**: Sets the number of prefix characters to remain unchanged for fuzzy matching (default: 0). ``` -------------------------------- ### analyze_plan Source: https://docs.rs/lancedb/latest/lancedb/query/trait.ExecutableQuery.html?search=std%3A%3Avec Executes the query and returns runtime metrics. ```APIDOC ## fn analyze_plan(&self) -> impl Future> + Send ### Description Executes the query to retrieve and display runtime metrics, including the query plan. ### Returns - **Result** - A future that resolves to a string representation of the runtime metrics or an error. ``` -------------------------------- ### Box::new_uninit_in Source: https://docs.rs/lancedb/latest/lancedb/arrow/type.BoxedRecordBatchReader.html?search=u32+-%3E+bool Constructs a new box with uninitialized contents in the provided allocator. ```APIDOC ## pub fn new_uninit_in(alloc: A) -> Box, A> ### Description Constructs a new box with uninitialized contents in the provided allocator. ``` -------------------------------- ### Splitter::new Source: https://docs.rs/lancedb/latest/lancedb/dataloader/permutation/split/struct.Splitter.html?search= Creates a new instance of the Splitter. ```APIDOC ## pub fn new(temp_dir: TemporaryDirectory, strategy: SplitStrategy) -> Self ### Description Initializes a new Splitter with the specified temporary directory and split strategy. ### Parameters - **temp_dir** (TemporaryDirectory) - Required - The directory used for temporary storage during splitting. - **strategy** (SplitStrategy) - Required - The strategy to be used for splitting the data. ``` -------------------------------- ### execute Source: https://docs.rs/lancedb/latest/lancedb/query/struct.Query.html Executes the query with default options. ```APIDOC ## fn execute(&self) -> impl Future> + Send ### Description Executes the query using default execution options and returns a stream of record batches. ``` -------------------------------- ### pub fn connect(uri: &str) -> ConnectBuilder Source: https://docs.rs/lancedb/latest/lancedb/connection/fn.connect.html Connects to a LanceDB database located at the specified URI. ```APIDOC ## connect ### Description Connect to a LanceDB database. This function returns a ConnectBuilder to further configure the connection. ### Signature `pub fn connect(uri: &str) -> ConnectBuilder` ### Arguments - **uri** (&str) - The URI where the database is located. This can be a local directory, supported remote cloud storage, or a LanceDB Cloud database. ``` -------------------------------- ### CloneToUninit Implementation Source: https://docs.rs/lancedb/latest/lancedb/database/listing/struct.ListingDatabaseOptions.html?search= Experimental nightly API for performing copy-assignment to uninitialized memory. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### initial_storage_options Source: https://docs.rs/lancedb/latest/lancedb/table/struct.NativeTable.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Retrieves the storage options used during table initialization. ```APIDOC ## fn initial_storage_options() ### Description Get the initial storage options that were passed in when opening this table. ``` -------------------------------- ### OAuthHeaderProvider::new Source: https://docs.rs/lancedb/latest/lancedb/remote/oauth/struct.OAuthHeaderProvider.html?search= Creates a new instance of the OAuthHeaderProvider using the provided configuration. ```APIDOC ## pub fn new(config: OAuthConfig) -> Result ### Description Creates a new OAuth header provider from the provided configuration. This provider manages the full token lifecycle and handles automatic token refresh. ### Parameters - **config** (OAuthConfig) - Required - The configuration object containing OAuth credentials and settings. ### Returns - **Result** - Returns the initialized OAuthHeaderProvider or an error if initialization fails. ``` -------------------------------- ### pub async fn list_indices(&self) -> Result> Source: https://docs.rs/lancedb/latest/lancedb/table/struct.Table.html List all indices that have been created. ```APIDOC ## pub async fn list_indices(&self) -> Result> ### Description List all indices that have been created with Self::create_index. ``` -------------------------------- ### create_from_namespace Source: https://docs.rs/lancedb/latest/lancedb/table/struct.NativeTable.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Creates a new Table using a namespace client for storage options, enabling automatic credential refresh for cloud storage. ```APIDOC ## create_from_namespace ### Description Creates a new Table using a namespace client for storage options. This method sets up a `StorageOptionsProvider` from the namespace client, enabling automatic credential refresh for cloud storage. ### Parameters - **namespace_client** (Arc) - The namespace client to use for storage options - **uri** (&str) - The URI to the table - **name** (&str) - The table name - **namespace** (Vec) - The namespace path - **batches** (impl StreamingWriteSource) - RecordBatch to be saved in the database - **write_store_wrapper** (Option>) - Optional wrapper for the object store on write path - **params** (Option) - Optional write parameters - **read_consistency_interval** (Option) - Optional interval for read consistency - **pushdown_operations** (HashSet) - Operations to push down to the namespace server - **session** (Option>) - Optional session ### Returns - **NativeTable** - A NativeTable object. ```