| 1 | // Copyright 2024 Lance Developers. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | use std::collections::HashMap; |
| 16 | |
| 17 | use napi_derive::*; |
| 18 | |
| 19 | mod connection; |
| 20 | mod error; |
| 21 | mod index; |
| 22 | mod iterator; |
| 23 | pub mod merge; |
| 24 | mod query; |
| 25 | pub mod remote; |
| 26 | mod table; |
| 27 | mod util; |
| 28 | |
| 29 | #[napi(object)] |
| 30 | #[derive(Debug)] |
| 31 | pub struct ConnectionOptions { |
| 32 | /// (For LanceDB OSS only): The interval, in seconds, at which to check for |
| 33 | /// updates to the table from other processes. If None, then consistency is not |
| 34 | /// checked. For performance reasons, this is the default. For strong |
| 35 | /// consistency, set this to zero seconds. Then every read will check for |
| 36 | /// updates from other processes. As a compromise, you can set this to a |
| 37 | /// non-zero value for eventual consistency. If more than that interval |
| 38 | /// has passed since the last check, then the table will be checked for updates. |
| 39 | /// Note: this consistency only applies to read operations. Write operations are |
| 40 | /// always consistent. |
| 41 | pub read_consistency_interval: Option<f64>, |
| 42 | /// (For LanceDB OSS only): configuration for object storage. |
| 43 | /// |
| 44 | /// The available options are described at https://lancedb.github.io/lancedb/guides/storage/ |
| 45 | pub storage_options: Option<HashMap<String, String>>, |
| 46 | |
| 47 | /// (For LanceDB cloud only): configuration for the remote HTTP client. |
| 48 | pub client_config: Option<remote::ClientConfig>, |
| 49 | /// (For LanceDB cloud only): the API key to use with LanceDB Cloud. |
| 50 | /// |
| 51 | /// Can also be set via the environment variable `LANCEDB_API_KEY`. |
| 52 | pub api_key: Option<String>, |
| 53 | /// (For LanceDB cloud only): the region to use for LanceDB cloud. |
| 54 | /// Defaults to 'us-east-1'. |
| 55 | pub region: Option<String>, |
| 56 | /// (For LanceDB cloud only): the host to use for LanceDB cloud. Used |
| 57 | /// for testing purposes. |
| 58 | pub host_override: Option<String>, |
| 59 | } |
| 60 | |
| 61 | /// Write mode for writing a table. |
| 62 | #[napi(string_enum)] |
| 63 | pub enum WriteMode { |
| 64 | Create, |
| 65 | Append, |
| 66 | Overwrite, |
| 67 | } |
| 68 | |
| 69 | /// Write options when creating a Table. |
| 70 | #[napi(object)] |
| 71 | pub struct WriteOptions { |
| 72 | /// Write mode for writing to a table. |
| 73 | pub mode: Option<WriteMode>, |
| 74 | } |
| 75 | |
| 76 | #[napi(object)] |
| 77 | pub struct OpenTableOptions { |
| 78 | pub storage_options: Option<HashMap<String, String>>, |
| 79 | } |