@lancedb/lancedb 0.4.16 → 0.4.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,10 +13,32 @@
13
13
  // limitations under the License.
14
14
 
15
15
  import { fromTableToBuffer, makeArrowTable, makeEmptyTable } from "./arrow";
16
- import { Connection as LanceDbConnection } from "./native";
16
+ import { ConnectionOptions, Connection as LanceDbConnection } from "./native";
17
17
  import { Table } from "./table";
18
18
  import { Table as ArrowTable, Schema } from "apache-arrow";
19
19
 
20
+ /**
21
+ * Connect to a LanceDB instance at the given URI.
22
+ *
23
+ * Accepted formats:
24
+ *
25
+ * - `/path/to/database` - local database
26
+ * - `s3://bucket/path/to/database` or `gs://bucket/path/to/database` - database on cloud storage
27
+ * - `db://host:port` - remote database (LanceDB cloud)
28
+ * @param {string} uri - The uri of the database. If the database uri starts
29
+ * with `db://` then it connects to a remote database.
30
+ * @see {@link ConnectionOptions} for more details on the URI format.
31
+ */
32
+ export async function connect(
33
+ uri: string,
34
+ opts?: Partial<ConnectionOptions>,
35
+ ): Promise<Connection> {
36
+ opts = opts ?? {};
37
+ opts.storageOptions = cleanseStorageOptions(opts.storageOptions);
38
+ const nativeConn = await LanceDbConnection.new(uri, opts);
39
+ return new Connection(nativeConn);
40
+ }
41
+
20
42
  export interface CreateTableOptions {
21
43
  /**
22
44
  * The mode to use when creating the table.
@@ -33,6 +55,40 @@ export interface CreateTableOptions {
33
55
  * then no error will be raised.
34
56
  */
35
57
  existOk: boolean;
58
+
59
+ /**
60
+ * Configuration for object storage.
61
+ *
62
+ * Options already set on the connection will be inherited by the table,
63
+ * but can be overridden here.
64
+ *
65
+ * The available options are described at https://lancedb.github.io/lancedb/guides/storage/
66
+ */
67
+ storageOptions?: Record<string, string>;
68
+ }
69
+
70
+ export interface OpenTableOptions {
71
+ /**
72
+ * Configuration for object storage.
73
+ *
74
+ * Options already set on the connection will be inherited by the table,
75
+ * but can be overridden here.
76
+ *
77
+ * The available options are described at https://lancedb.github.io/lancedb/guides/storage/
78
+ */
79
+ storageOptions?: Record<string, string>;
80
+ /**
81
+ * Set the size of the index cache, specified as a number of entries
82
+ *
83
+ * The exact meaning of an "entry" will depend on the type of index:
84
+ * - IVF: there is one entry for each IVF partition
85
+ * - BTREE: there is one entry for the entire index
86
+ *
87
+ * This cache applies to the entire opened table, across all indices.
88
+ * Setting this value higher will increase performance on larger datasets
89
+ * at the expense of more RAM
90
+ */
91
+ indexCacheSize?: number;
36
92
  }
37
93
 
38
94
  export interface TableNamesOptions {
@@ -109,8 +165,15 @@ export class Connection {
109
165
  * Open a table in the database.
110
166
  * @param {string} name - The name of the table
111
167
  */
112
- async openTable(name: string): Promise<Table> {
113
- const innerTable = await this.inner.openTable(name);
168
+ async openTable(
169
+ name: string,
170
+ options?: Partial<OpenTableOptions>,
171
+ ): Promise<Table> {
172
+ const innerTable = await this.inner.openTable(
173
+ name,
174
+ cleanseStorageOptions(options?.storageOptions),
175
+ options?.indexCacheSize,
176
+ );
114
177
  return new Table(innerTable);
115
178
  }
116
179
 
@@ -139,7 +202,12 @@ export class Connection {
139
202
  table = makeArrowTable(data);
140
203
  }
141
204
  const buf = await fromTableToBuffer(table);
142
- const innerTable = await this.inner.createTable(name, buf, mode);
205
+ const innerTable = await this.inner.createTable(
206
+ name,
207
+ buf,
208
+ mode,
209
+ cleanseStorageOptions(options?.storageOptions),
210
+ );
143
211
  return new Table(innerTable);
144
212
  }
145
213
 
@@ -162,7 +230,12 @@ export class Connection {
162
230
 
163
231
  const table = makeEmptyTable(schema);
164
232
  const buf = await fromTableToBuffer(table);
165
- const innerTable = await this.inner.createEmptyTable(name, buf, mode);
233
+ const innerTable = await this.inner.createEmptyTable(
234
+ name,
235
+ buf,
236
+ mode,
237
+ cleanseStorageOptions(options?.storageOptions),
238
+ );
166
239
  return new Table(innerTable);
167
240
  }
168
241
 
@@ -174,3 +247,43 @@ export class Connection {
174
247
  return this.inner.dropTable(name);
175
248
  }
176
249
  }
250
+
251
+ /**
252
+ * Takes storage options and makes all the keys snake case.
253
+ */
254
+ function cleanseStorageOptions(
255
+ options?: Record<string, string>,
256
+ ): Record<string, string> | undefined {
257
+ if (options === undefined) {
258
+ return undefined;
259
+ }
260
+ const result: Record<string, string> = {};
261
+ for (const [key, value] of Object.entries(options)) {
262
+ if (value !== undefined) {
263
+ const newKey = camelToSnakeCase(key);
264
+ result[newKey] = value;
265
+ }
266
+ }
267
+ return result;
268
+ }
269
+
270
+ /**
271
+ * Convert a string to snake case. It might already be snake case, in which case it is
272
+ * returned unchanged.
273
+ */
274
+ function camelToSnakeCase(camel: string): string {
275
+ if (camel.includes("_")) {
276
+ // Assume if there is at least one underscore, it is already snake case
277
+ return camel;
278
+ }
279
+ if (camel.toLocaleUpperCase() === camel) {
280
+ // Assume if the string is all uppercase, it is already snake case
281
+ return camel;
282
+ }
283
+
284
+ let result = camel.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
285
+ if (result.startsWith("_")) {
286
+ result = result.slice(1);
287
+ }
288
+ return result;
289
+ }
package/lancedb/index.ts CHANGED
@@ -12,12 +12,6 @@
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
14
 
15
- import { Connection } from "./connection";
16
- import {
17
- Connection as LanceDbConnection,
18
- ConnectionOptions,
19
- } from "./native.js";
20
-
21
15
  export {
22
16
  WriteOptions,
23
17
  WriteMode,
@@ -32,6 +26,7 @@ export {
32
26
  VectorColumnOptions,
33
27
  } from "./arrow";
34
28
  export {
29
+ connect,
35
30
  Connection,
36
31
  CreateTableOptions,
37
32
  TableNamesOptions,
@@ -46,24 +41,3 @@ export {
46
41
  export { Index, IndexOptions, IvfPqOptions } from "./indices";
47
42
  export { Table, AddDataOptions, IndexConfig, UpdateOptions } from "./table";
48
43
  export * as embedding from "./embedding";
49
-
50
- /**
51
- * Connect to a LanceDB instance at the given URI.
52
- *
53
- * Accpeted formats:
54
- *
55
- * - `/path/to/database` - local database
56
- * - `s3://bucket/path/to/database` or `gs://bucket/path/to/database` - database on cloud storage
57
- * - `db://host:port` - remote database (LanceDB cloud)
58
- * @param {string} uri - The uri of the database. If the database uri starts
59
- * with `db://` then it connects to a remote database.
60
- * @see {@link ConnectionOptions} for more details on the URI format.
61
- */
62
- export async function connect(
63
- uri: string,
64
- opts?: Partial<ConnectionOptions>,
65
- ): Promise<Connection> {
66
- opts = opts ?? {};
67
- const nativeConn = await LanceDbConnection.new(uri, opts);
68
- return new Connection(nativeConn);
69
- }
package/lancedb/table.ts CHANGED
@@ -169,17 +169,20 @@ export class Table {
169
169
  * // If the column has a vector (fixed size list) data type then
170
170
  * // an IvfPq vector index will be created.
171
171
  * const table = await conn.openTable("my_table");
172
- * await table.createIndex(["vector"]);
172
+ * await table.createIndex("vector");
173
173
  * @example
174
174
  * // For advanced control over vector index creation you can specify
175
175
  * // the index type and options.
176
176
  * const table = await conn.openTable("my_table");
177
- * await table.createIndex(["vector"], I)
178
- * .ivf_pq({ num_partitions: 128, num_sub_vectors: 16 })
179
- * .build();
177
+ * await table.createIndex("vector", {
178
+ * config: lancedb.Index.ivfPq({
179
+ * numPartitions: 128,
180
+ * numSubVectors: 16,
181
+ * }),
182
+ * });
180
183
  * @example
181
184
  * // Or create a Scalar index
182
- * await table.createIndex("my_float_col").build();
185
+ * await table.createIndex("my_float_col");
183
186
  */
184
187
  async createIndex(column: string, options?: Partial<IndexOptions>) {
185
188
  // Bit of a hack to get around the fact that TS has no package-scope.
@@ -197,8 +200,7 @@ export class Table {
197
200
  * vector similarity, sorting, and more.
198
201
  *
199
202
  * Note: By default, all columns are returned. For best performance, you should
200
- * only fetch the columns you need. See [`Query::select_with_projection`] for
201
- * more details.
203
+ * only fetch the columns you need.
202
204
  *
203
205
  * When appropriate, various indices and statistics based pruning will be used to
204
206
  * accelerate the query.
@@ -206,10 +208,13 @@ export class Table {
206
208
  * // SQL-style filtering
207
209
  * //
208
210
  * // This query will return up to 1000 rows whose value in the `id` column
209
- * // is greater than 5. LanceDb supports a broad set of filtering functions.
210
- * for await (const batch of table.query()
211
- * .filter("id > 1").select(["id"]).limit(20)) {
212
- * console.log(batch);
211
+ * // is greater than 5. LanceDb supports a broad set of filtering functions.
212
+ * for await (const batch of table
213
+ * .query()
214
+ * .where("id > 1")
215
+ * .select(["id"])
216
+ * .limit(20)) {
217
+ * console.log(batch);
213
218
  * }
214
219
  * @example
215
220
  * // Vector Similarity Search
@@ -218,13 +223,14 @@ export class Table {
218
223
  * // closest to the query vector [1.0, 2.0, 3.0]. If an index has been created
219
224
  * // on the "vector" column then this will perform an ANN search.
220
225
  * //
221
- * // The `refine_factor` and `nprobes` methods are used to control the recall /
226
+ * // The `refineFactor` and `nprobes` methods are used to control the recall /
222
227
  * // latency tradeoff of the search.
223
- * for await (const batch of table.query()
224
- * .nearestTo([1, 2, 3])
225
- * .refineFactor(5).nprobe(10)
226
- * .limit(10)) {
227
- * console.log(batch);
228
+ * for await (const batch of table
229
+ * .query()
230
+ * .where("id > 1")
231
+ * .select(["id"])
232
+ * .limit(20)) {
233
+ * console.log(batch);
228
234
  * }
229
235
  * @example
230
236
  * // Scan the full dataset
@@ -286,43 +292,45 @@ export class Table {
286
292
  await this.inner.dropColumns(columnNames);
287
293
  }
288
294
 
289
- /**
290
- * Retrieve the version of the table
291
- *
292
- * LanceDb supports versioning. Every operation that modifies the table increases
293
- * version. As long as a version hasn't been deleted you can `[Self::checkout]` that
294
- * version to view the data at that point. In addition, you can `[Self::restore]` the
295
- * version to replace the current table with a previous version.
296
- */
295
+ /** Retrieve the version of the table */
297
296
  async version(): Promise<number> {
298
297
  return await this.inner.version();
299
298
  }
300
299
 
301
300
  /**
302
- * Checks out a specific version of the Table
301
+ * Checks out a specific version of the table _This is an in-place operation._
303
302
  *
304
- * Any read operation on the table will now access the data at the checked out version.
305
- * As a consequence, calling this method will disable any read consistency interval
306
- * that was previously set.
303
+ * This allows viewing previous versions of the table. If you wish to
304
+ * keep writing to the dataset starting from an old version, then use
305
+ * the `restore` function.
307
306
  *
308
- * This is a read-only operation that turns the table into a sort of "view"
309
- * or "detached head". Other table instances will not be affected. To make the change
310
- * permanent you can use the `[Self::restore]` method.
311
- *
312
- * Any operation that modifies the table will fail while the table is in a checked
313
- * out state.
307
+ * Calling this method will set the table into time-travel mode. If you
308
+ * wish to return to standard mode, call `checkoutLatest`.
309
+ * @param {number} version The version to checkout
310
+ * @example
311
+ * ```typescript
312
+ * import * as lancedb from "@lancedb/lancedb"
313
+ * const db = await lancedb.connect("./.lancedb");
314
+ * const table = await db.createTable("my_table", [
315
+ * { vector: [1.1, 0.9], type: "vector" },
316
+ * ]);
314
317
  *
315
- * To return the table to a normal state use `[Self::checkout_latest]`
318
+ * console.log(await table.version()); // 1
319
+ * console.log(table.display());
320
+ * await table.add([{ vector: [0.5, 0.2], type: "vector" }]);
321
+ * await table.checkout(1);
322
+ * console.log(await table.version()); // 2
323
+ * ```
316
324
  */
317
325
  async checkout(version: number): Promise<void> {
318
326
  await this.inner.checkout(version);
319
327
  }
320
328
 
321
329
  /**
322
- * Ensures the table is pointing at the latest version
330
+ * Checkout the latest version of the table. _This is an in-place operation._
323
331
  *
324
- * This can be used to manually update a table when the read_consistency_interval is None
325
- * It can also be used to undo a `[Self::checkout]` operation
332
+ * The table will be set back into standard mode, and will track the latest
333
+ * version of the table.
326
334
  */
327
335
  async checkoutLatest(): Promise<void> {
328
336
  await this.inner.checkoutLatest();
@@ -344,9 +352,7 @@ export class Table {
344
352
  await this.inner.restore();
345
353
  }
346
354
 
347
- /**
348
- * List all indices that have been created with Self::create_index
349
- */
355
+ /** List all indices that have been created with {@link Table.createIndex} */
350
356
  async listIndices(): Promise<IndexConfig[]> {
351
357
  return await this.inner.listIndices();
352
358
  }
@@ -1,6 +1,19 @@
1
- import { Connection as LanceDbConnection } from "./native";
1
+ import { ConnectionOptions, Connection as LanceDbConnection } from "./native";
2
2
  import { Table } from "./table";
3
3
  import { Table as ArrowTable, Schema } from "apache-arrow";
4
+ /**
5
+ * Connect to a LanceDB instance at the given URI.
6
+ *
7
+ * Accepted formats:
8
+ *
9
+ * - `/path/to/database` - local database
10
+ * - `s3://bucket/path/to/database` or `gs://bucket/path/to/database` - database on cloud storage
11
+ * - `db://host:port` - remote database (LanceDB cloud)
12
+ * @param {string} uri - The uri of the database. If the database uri starts
13
+ * with `db://` then it connects to a remote database.
14
+ * @see {@link ConnectionOptions} for more details on the URI format.
15
+ */
16
+ export declare function connect(uri: string, opts?: Partial<ConnectionOptions>): Promise<Connection>;
4
17
  export interface CreateTableOptions {
5
18
  /**
6
19
  * The mode to use when creating the table.
@@ -17,6 +30,38 @@ export interface CreateTableOptions {
17
30
  * then no error will be raised.
18
31
  */
19
32
  existOk: boolean;
33
+ /**
34
+ * Configuration for object storage.
35
+ *
36
+ * Options already set on the connection will be inherited by the table,
37
+ * but can be overridden here.
38
+ *
39
+ * The available options are described at https://lancedb.github.io/lancedb/guides/storage/
40
+ */
41
+ storageOptions?: Record<string, string>;
42
+ }
43
+ export interface OpenTableOptions {
44
+ /**
45
+ * Configuration for object storage.
46
+ *
47
+ * Options already set on the connection will be inherited by the table,
48
+ * but can be overridden here.
49
+ *
50
+ * The available options are described at https://lancedb.github.io/lancedb/guides/storage/
51
+ */
52
+ storageOptions?: Record<string, string>;
53
+ /**
54
+ * Set the size of the index cache, specified as a number of entries
55
+ *
56
+ * The exact meaning of an "entry" will depend on the type of index:
57
+ * - IVF: there is one entry for each IVF partition
58
+ * - BTREE: there is one entry for the entire index
59
+ *
60
+ * This cache applies to the entire opened table, across all indices.
61
+ * Setting this value higher will increase performance on larger datasets
62
+ * at the expense of more RAM
63
+ */
64
+ indexCacheSize?: number;
20
65
  }
21
66
  export interface TableNamesOptions {
22
67
  /**
@@ -75,7 +120,7 @@ export declare class Connection {
75
120
  * Open a table in the database.
76
121
  * @param {string} name - The name of the table
77
122
  */
78
- openTable(name: string): Promise<Table>;
123
+ openTable(name: string, options?: Partial<OpenTableOptions>): Promise<Table>;
79
124
  /**
80
125
  * Creates a new Table and initialize it with new data.
81
126
  * @param {string} name - The name of the table.
@@ -13,10 +13,30 @@
13
13
  // See the License for the specific language governing permissions and
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.Connection = void 0;
16
+ exports.Connection = exports.connect = void 0;
17
17
  const arrow_1 = require("./arrow");
18
+ const native_1 = require("./native");
18
19
  const table_1 = require("./table");
19
20
  const apache_arrow_1 = require("apache-arrow");
21
+ /**
22
+ * Connect to a LanceDB instance at the given URI.
23
+ *
24
+ * Accepted formats:
25
+ *
26
+ * - `/path/to/database` - local database
27
+ * - `s3://bucket/path/to/database` or `gs://bucket/path/to/database` - database on cloud storage
28
+ * - `db://host:port` - remote database (LanceDB cloud)
29
+ * @param {string} uri - The uri of the database. If the database uri starts
30
+ * with `db://` then it connects to a remote database.
31
+ * @see {@link ConnectionOptions} for more details on the URI format.
32
+ */
33
+ async function connect(uri, opts) {
34
+ opts = opts ?? {};
35
+ opts.storageOptions = cleanseStorageOptions(opts.storageOptions);
36
+ const nativeConn = await native_1.Connection.new(uri, opts);
37
+ return new Connection(nativeConn);
38
+ }
39
+ exports.connect = connect;
20
40
  /**
21
41
  * A LanceDB Connection that allows you to open tables and create new ones.
22
42
  *
@@ -72,8 +92,8 @@ class Connection {
72
92
  * Open a table in the database.
73
93
  * @param {string} name - The name of the table
74
94
  */
75
- async openTable(name) {
76
- const innerTable = await this.inner.openTable(name);
95
+ async openTable(name, options) {
96
+ const innerTable = await this.inner.openTable(name, cleanseStorageOptions(options?.storageOptions), options?.indexCacheSize);
77
97
  return new table_1.Table(innerTable);
78
98
  }
79
99
  /**
@@ -96,7 +116,7 @@ class Connection {
96
116
  table = (0, arrow_1.makeArrowTable)(data);
97
117
  }
98
118
  const buf = await (0, arrow_1.fromTableToBuffer)(table);
99
- const innerTable = await this.inner.createTable(name, buf, mode);
119
+ const innerTable = await this.inner.createTable(name, buf, mode, cleanseStorageOptions(options?.storageOptions));
100
120
  return new table_1.Table(innerTable);
101
121
  }
102
122
  /**
@@ -112,7 +132,7 @@ class Connection {
112
132
  }
113
133
  const table = (0, arrow_1.makeEmptyTable)(schema);
114
134
  const buf = await (0, arrow_1.fromTableToBuffer)(table);
115
- const innerTable = await this.inner.createEmptyTable(name, buf, mode);
135
+ const innerTable = await this.inner.createEmptyTable(name, buf, mode, cleanseStorageOptions(options?.storageOptions));
116
136
  return new table_1.Table(innerTable);
117
137
  }
118
138
  /**
@@ -124,3 +144,38 @@ class Connection {
124
144
  }
125
145
  }
126
146
  exports.Connection = Connection;
147
+ /**
148
+ * Takes storage options and makes all the keys snake case.
149
+ */
150
+ function cleanseStorageOptions(options) {
151
+ if (options === undefined) {
152
+ return undefined;
153
+ }
154
+ const result = {};
155
+ for (const [key, value] of Object.entries(options)) {
156
+ if (value !== undefined) {
157
+ const newKey = camelToSnakeCase(key);
158
+ result[newKey] = value;
159
+ }
160
+ }
161
+ return result;
162
+ }
163
+ /**
164
+ * Convert a string to snake case. It might already be snake case, in which case it is
165
+ * returned unchanged.
166
+ */
167
+ function camelToSnakeCase(camel) {
168
+ if (camel.includes("_")) {
169
+ // Assume if there is at least one underscore, it is already snake case
170
+ return camel;
171
+ }
172
+ if (camel.toLocaleUpperCase() === camel) {
173
+ // Assume if the string is all uppercase, it is already snake case
174
+ return camel;
175
+ }
176
+ let result = camel.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
177
+ if (result.startsWith("_")) {
178
+ result = result.slice(1);
179
+ }
180
+ return result;
181
+ }
@@ -1,22 +1,7 @@
1
- import { Connection } from "./connection";
2
- import { ConnectionOptions } from "./native.js";
3
1
  export { WriteOptions, WriteMode, AddColumnsSql, ColumnAlteration, ConnectionOptions, } from "./native.js";
4
2
  export { makeArrowTable, MakeArrowTableOptions, Data, VectorColumnOptions, } from "./arrow";
5
- export { Connection, CreateTableOptions, TableNamesOptions, } from "./connection";
3
+ export { connect, Connection, CreateTableOptions, TableNamesOptions, } from "./connection";
6
4
  export { ExecutableQuery, Query, QueryBase, VectorQuery, RecordBatchIterator, } from "./query";
7
5
  export { Index, IndexOptions, IvfPqOptions } from "./indices";
8
6
  export { Table, AddDataOptions, IndexConfig, UpdateOptions } from "./table";
9
7
  export * as embedding from "./embedding";
10
- /**
11
- * Connect to a LanceDB instance at the given URI.
12
- *
13
- * Accpeted formats:
14
- *
15
- * - `/path/to/database` - local database
16
- * - `s3://bucket/path/to/database` or `gs://bucket/path/to/database` - database on cloud storage
17
- * - `db://host:port` - remote database (LanceDB cloud)
18
- * @param {string} uri - The uri of the database. If the database uri starts
19
- * with `db://` then it connects to a remote database.
20
- * @see {@link ConnectionOptions} for more details on the URI format.
21
- */
22
- export declare function connect(uri: string, opts?: Partial<ConnectionOptions>): Promise<Connection>;
@@ -13,15 +13,14 @@
13
13
  // See the License for the specific language governing permissions and
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.connect = exports.embedding = exports.Table = exports.Index = exports.RecordBatchIterator = exports.VectorQuery = exports.QueryBase = exports.Query = exports.Connection = exports.VectorColumnOptions = exports.MakeArrowTableOptions = exports.makeArrowTable = void 0;
17
- const connection_1 = require("./connection");
18
- const native_js_1 = require("./native.js");
16
+ exports.embedding = exports.Table = exports.Index = exports.RecordBatchIterator = exports.VectorQuery = exports.QueryBase = exports.Query = exports.Connection = exports.connect = exports.VectorColumnOptions = exports.MakeArrowTableOptions = exports.makeArrowTable = void 0;
19
17
  var arrow_1 = require("./arrow");
20
18
  Object.defineProperty(exports, "makeArrowTable", { enumerable: true, get: function () { return arrow_1.makeArrowTable; } });
21
19
  Object.defineProperty(exports, "MakeArrowTableOptions", { enumerable: true, get: function () { return arrow_1.MakeArrowTableOptions; } });
22
20
  Object.defineProperty(exports, "VectorColumnOptions", { enumerable: true, get: function () { return arrow_1.VectorColumnOptions; } });
23
- var connection_2 = require("./connection");
24
- Object.defineProperty(exports, "Connection", { enumerable: true, get: function () { return connection_2.Connection; } });
21
+ var connection_1 = require("./connection");
22
+ Object.defineProperty(exports, "connect", { enumerable: true, get: function () { return connection_1.connect; } });
23
+ Object.defineProperty(exports, "Connection", { enumerable: true, get: function () { return connection_1.Connection; } });
25
24
  var query_1 = require("./query");
26
25
  Object.defineProperty(exports, "Query", { enumerable: true, get: function () { return query_1.Query; } });
27
26
  Object.defineProperty(exports, "QueryBase", { enumerable: true, get: function () { return query_1.QueryBase; } });
@@ -32,21 +31,3 @@ Object.defineProperty(exports, "Index", { enumerable: true, get: function () { r
32
31
  var table_1 = require("./table");
33
32
  Object.defineProperty(exports, "Table", { enumerable: true, get: function () { return table_1.Table; } });
34
33
  exports.embedding = require("./embedding");
35
- /**
36
- * Connect to a LanceDB instance at the given URI.
37
- *
38
- * Accpeted formats:
39
- *
40
- * - `/path/to/database` - local database
41
- * - `s3://bucket/path/to/database` or `gs://bucket/path/to/database` - database on cloud storage
42
- * - `db://host:port` - remote database (LanceDB cloud)
43
- * @param {string} uri - The uri of the database. If the database uri starts
44
- * with `db://` then it connects to a remote database.
45
- * @see {@link ConnectionOptions} for more details on the URI format.
46
- */
47
- async function connect(uri, opts) {
48
- opts = opts ?? {};
49
- const nativeConn = await native_js_1.Connection.new(uri, opts);
50
- return new connection_1.Connection(nativeConn);
51
- }
52
- exports.connect = connect;
@@ -62,6 +62,12 @@ export interface ConnectionOptions {
62
62
  * always consistent.
63
63
  */
64
64
  readConsistencyInterval?: number
65
+ /**
66
+ * (For LanceDB OSS only): configuration for object storage.
67
+ *
68
+ * The available options are described at https://lancedb.github.io/lancedb/guides/storage/
69
+ */
70
+ storageOptions?: Record<string, string>
65
71
  }
66
72
  /** Write mode for writing a table. */
67
73
  export const enum WriteMode {
@@ -73,7 +79,9 @@ export const enum WriteMode {
73
79
  export interface WriteOptions {
74
80
  mode?: WriteMode
75
81
  }
76
- export function connect(uri: string, options: ConnectionOptions): Promise<Connection>
82
+ export interface OpenTableOptions {
83
+ storageOptions?: Record<string, string>
84
+ }
77
85
  export class Connection {
78
86
  /** Create a new Connection instance from the given URI. */
79
87
  static new(uri: string, options: ConnectionOptions): Promise<Connection>
@@ -90,9 +98,9 @@ export class Connection {
90
98
  * - buf: The buffer containing the IPC file.
91
99
  *
92
100
  */
93
- createTable(name: string, buf: Buffer, mode: string): Promise<Table>
94
- createEmptyTable(name: string, schemaBuf: Buffer, mode: string): Promise<Table>
95
- openTable(name: string): Promise<Table>
101
+ createTable(name: string, buf: Buffer, mode: string, storageOptions?: Record<string, string> | undefined | null): Promise<Table>
102
+ createEmptyTable(name: string, schemaBuf: Buffer, mode: string, storageOptions?: Record<string, string> | undefined | null): Promise<Table>
103
+ openTable(name: string, storageOptions?: Record<string, string> | undefined | null, indexCacheSize?: number | undefined | null): Promise<Table>
96
104
  /** Drop table with the name. Or raise an error if the table does not exist. */
97
105
  dropTable(name: string): Promise<void>
98
106
  }
@@ -303,7 +303,7 @@ if (!nativeBinding) {
303
303
  }
304
304
  throw new Error(`Failed to load native binding`);
305
305
  }
306
- const { Connection, Index, RecordBatchIterator, Query, VectorQuery, Table, WriteMode, connect } = nativeBinding;
306
+ const { Connection, Index, RecordBatchIterator, Query, VectorQuery, Table, WriteMode } = nativeBinding;
307
307
  module.exports.Connection = Connection;
308
308
  module.exports.Index = Index;
309
309
  module.exports.RecordBatchIterator = RecordBatchIterator;
@@ -311,4 +311,3 @@ module.exports.Query = Query;
311
311
  module.exports.VectorQuery = VectorQuery;
312
312
  module.exports.Table = Table;
313
313
  module.exports.WriteMode = WriteMode;
314
- module.exports.connect = connect;