@lancedb/lancedb 0.5.2 → 0.7.0
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.
- package/Cargo.toml +3 -3
- package/biome.json +19 -3
- package/dist/arrow.d.ts +41 -8
- package/dist/arrow.js +4 -4
- package/dist/connection.d.ts +49 -29
- package/dist/connection.js +21 -73
- package/dist/embedding/embedding_function.d.ts +9 -1
- package/dist/embedding/embedding_function.js +6 -0
- package/dist/embedding/openai.d.ts +6 -5
- package/dist/embedding/openai.js +4 -2
- package/dist/embedding/registry.d.ts +6 -11
- package/dist/index.d.ts +51 -3
- package/dist/index.js +28 -4
- package/dist/merge.d.ts +54 -0
- package/dist/merge.js +64 -0
- package/dist/native.d.ts +29 -3
- package/dist/native.js +26 -9
- package/dist/query.d.ts +33 -10
- package/dist/query.js +100 -13
- package/dist/remote/client.d.ts +28 -0
- package/dist/remote/client.js +172 -0
- package/dist/remote/connection.d.ts +25 -0
- package/dist/remote/connection.js +110 -0
- package/dist/remote/index.d.ts +3 -0
- package/dist/remote/index.js +9 -0
- package/dist/remote/table.d.ts +42 -0
- package/dist/remote/table.js +179 -0
- package/dist/sanitize.d.ts +3 -2
- package/dist/sanitize.js +55 -1
- package/dist/table.d.ts +105 -30
- package/dist/table.js +94 -237
- package/dist/util.d.ts +14 -0
- package/dist/util.js +65 -0
- package/examples/ann_indexes.ts +49 -0
- package/examples/basic.ts +149 -0
- package/examples/embedding.ts +83 -0
- package/examples/filtering.ts +34 -0
- package/examples/jsconfig.json +27 -0
- package/examples/package-lock.json +79 -0
- package/examples/package.json +18 -0
- package/examples/search.ts +37 -0
- package/lancedb/arrow.ts +80 -23
- package/lancedb/connection.ts +107 -92
- package/lancedb/embedding/embedding_function.ts +12 -1
- package/lancedb/embedding/openai.ts +11 -6
- package/lancedb/embedding/registry.ts +34 -22
- package/lancedb/index.ts +101 -2
- package/lancedb/merge.ts +70 -0
- package/lancedb/query.ts +114 -28
- package/lancedb/remote/client.ts +221 -0
- package/lancedb/remote/connection.ts +201 -0
- package/lancedb/remote/index.ts +3 -0
- package/lancedb/remote/table.ts +226 -0
- package/lancedb/sanitize.ts +73 -1
- package/lancedb/table.ts +320 -132
- package/lancedb/util.ts +69 -0
- package/native.d.ts +208 -0
- package/nodejs-artifacts/arrow.d.ts +41 -8
- package/nodejs-artifacts/arrow.js +4 -4
- package/nodejs-artifacts/connection.d.ts +49 -29
- package/nodejs-artifacts/connection.js +21 -73
- package/nodejs-artifacts/embedding/embedding_function.d.ts +9 -1
- package/nodejs-artifacts/embedding/embedding_function.js +6 -0
- package/nodejs-artifacts/embedding/openai.d.ts +6 -5
- package/nodejs-artifacts/embedding/openai.js +4 -2
- package/nodejs-artifacts/embedding/registry.d.ts +6 -11
- package/nodejs-artifacts/index.d.ts +51 -3
- package/nodejs-artifacts/index.js +28 -4
- package/nodejs-artifacts/merge.d.ts +54 -0
- package/nodejs-artifacts/merge.js +64 -0
- package/nodejs-artifacts/native.d.ts +29 -3
- package/nodejs-artifacts/native.js +26 -9
- package/nodejs-artifacts/query.d.ts +33 -10
- package/nodejs-artifacts/query.js +100 -13
- package/nodejs-artifacts/remote/client.d.ts +28 -0
- package/nodejs-artifacts/remote/client.js +172 -0
- package/nodejs-artifacts/remote/connection.d.ts +25 -0
- package/nodejs-artifacts/remote/connection.js +110 -0
- package/nodejs-artifacts/remote/index.d.ts +3 -0
- package/nodejs-artifacts/remote/index.js +9 -0
- package/nodejs-artifacts/remote/table.d.ts +42 -0
- package/nodejs-artifacts/remote/table.js +179 -0
- package/nodejs-artifacts/sanitize.d.ts +3 -2
- package/nodejs-artifacts/sanitize.js +55 -1
- package/nodejs-artifacts/table.d.ts +105 -30
- package/nodejs-artifacts/table.js +94 -237
- package/nodejs-artifacts/util.d.ts +14 -0
- package/nodejs-artifacts/util.js +65 -0
- package/package.json +25 -11
package/dist/table.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Table as ArrowTable, Data, IntoVector, Schema, TableLike } from "./arrow";
|
|
3
|
+
import { CreateTableOptions } from "./connection";
|
|
2
4
|
import { IndexOptions } from "./indices";
|
|
3
|
-
import {
|
|
5
|
+
import { MergeInsertBuilder } from "./merge";
|
|
6
|
+
import { AddColumnsSql, ColumnAlteration, IndexConfig, IndexStatistics, OptimizeStats, Table as _NativeTable } from "./native";
|
|
4
7
|
import { Query, VectorQuery } from "./query";
|
|
8
|
+
import { IntoSql } from "./util";
|
|
5
9
|
export { IndexConfig } from "./native";
|
|
6
10
|
/**
|
|
7
11
|
* Options for adding data to a table.
|
|
@@ -55,13 +59,11 @@ export interface OptimizeOptions {
|
|
|
55
59
|
* Closing a table is optional. It not closed, it will be closed when it is garbage
|
|
56
60
|
* collected.
|
|
57
61
|
*/
|
|
58
|
-
export declare class Table {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
/** Construct a Table. Internal use only. */
|
|
62
|
-
constructor(inner: _NativeTable);
|
|
62
|
+
export declare abstract class Table {
|
|
63
|
+
/** Returns the name of the table */
|
|
64
|
+
abstract get name(): string;
|
|
63
65
|
/** Return true if the table has not been closed */
|
|
64
|
-
isOpen(): boolean;
|
|
66
|
+
abstract isOpen(): boolean;
|
|
65
67
|
/**
|
|
66
68
|
* Close the table, releasing any underlying resources.
|
|
67
69
|
*
|
|
@@ -69,16 +71,40 @@ export declare class Table {
|
|
|
69
71
|
*
|
|
70
72
|
* Any attempt to use the table after it is closed will result in an error.
|
|
71
73
|
*/
|
|
72
|
-
close(): void;
|
|
74
|
+
abstract close(): void;
|
|
73
75
|
/** Return a brief description of the table */
|
|
74
|
-
display(): string;
|
|
76
|
+
abstract display(): string;
|
|
75
77
|
/** Get the schema of the table. */
|
|
76
|
-
schema(): Promise<Schema>;
|
|
78
|
+
abstract schema(): Promise<Schema>;
|
|
77
79
|
/**
|
|
78
80
|
* Insert records into this Table.
|
|
79
81
|
* @param {Data} data Records to be inserted into the Table
|
|
80
82
|
*/
|
|
81
|
-
add(data: Data, options?: Partial<AddDataOptions>): Promise<void>;
|
|
83
|
+
abstract add(data: Data, options?: Partial<AddDataOptions>): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Update existing records in the Table
|
|
86
|
+
* @param opts.values The values to update. The keys are the column names and the values
|
|
87
|
+
* are the values to set.
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* table.update({where:"x = 2", values:{"vector": [10, 10]}})
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
abstract update(opts: {
|
|
94
|
+
values: Map<string, IntoSql> | Record<string, IntoSql>;
|
|
95
|
+
} & Partial<UpdateOptions>): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Update existing records in the Table
|
|
98
|
+
* @param opts.valuesSql The values to update. The keys are the column names and the values
|
|
99
|
+
* are the values to set. The values are SQL expressions.
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* table.update({where:"x = 2", valuesSql:{"x": "x + 1"}})
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
abstract update(opts: {
|
|
106
|
+
valuesSql: Map<string, string> | Record<string, string>;
|
|
107
|
+
} & Partial<UpdateOptions>): Promise<void>;
|
|
82
108
|
/**
|
|
83
109
|
* Update existing records in the Table
|
|
84
110
|
*
|
|
@@ -104,11 +130,11 @@ export declare class Table {
|
|
|
104
130
|
* @param {Partial<UpdateOptions>} options - additional options to control
|
|
105
131
|
* the update behavior
|
|
106
132
|
*/
|
|
107
|
-
update(updates: Map<string, string> | Record<string, string>, options?: Partial<UpdateOptions>): Promise<void>;
|
|
133
|
+
abstract update(updates: Map<string, string> | Record<string, string>, options?: Partial<UpdateOptions>): Promise<void>;
|
|
108
134
|
/** Count the total number of rows in the dataset. */
|
|
109
|
-
countRows(filter?: string): Promise<number>;
|
|
135
|
+
abstract countRows(filter?: string): Promise<number>;
|
|
110
136
|
/** Delete the rows that satisfy the predicate. */
|
|
111
|
-
delete(predicate: string): Promise<void>;
|
|
137
|
+
abstract delete(predicate: string): Promise<void>;
|
|
112
138
|
/**
|
|
113
139
|
* Create an index to speed up queries.
|
|
114
140
|
*
|
|
@@ -116,6 +142,9 @@ export declare class Table {
|
|
|
116
142
|
* Indices on vector columns will speed up vector searches.
|
|
117
143
|
* Indices on scalar columns will speed up filtering (in both
|
|
118
144
|
* vector and non-vector searches)
|
|
145
|
+
*
|
|
146
|
+
* @note We currently don't support custom named indexes,
|
|
147
|
+
* The index name will always be `${column}_idx`
|
|
119
148
|
* @example
|
|
120
149
|
* // If the column has a vector (fixed size list) data type then
|
|
121
150
|
* // an IvfPq vector index will be created.
|
|
@@ -135,7 +164,7 @@ export declare class Table {
|
|
|
135
164
|
* // Or create a Scalar index
|
|
136
165
|
* await table.createIndex("my_float_col");
|
|
137
166
|
*/
|
|
138
|
-
createIndex(column: string, options?: Partial<IndexOptions>): Promise<void>;
|
|
167
|
+
abstract createIndex(column: string, options?: Partial<IndexOptions>): Promise<void>;
|
|
139
168
|
/**
|
|
140
169
|
* Create a {@link Query} Builder.
|
|
141
170
|
*
|
|
@@ -186,20 +215,20 @@ export declare class Table {
|
|
|
186
215
|
* }
|
|
187
216
|
* @returns {Query} A builder that can be used to parameterize the query
|
|
188
217
|
*/
|
|
189
|
-
query(): Query;
|
|
218
|
+
abstract query(): Query;
|
|
190
219
|
/**
|
|
191
220
|
* Create a search query to find the nearest neighbors
|
|
192
221
|
* of the given query vector
|
|
193
222
|
* @param {string} query - the query. This will be converted to a vector using the table's provided embedding function
|
|
194
|
-
* @
|
|
223
|
+
* @note If no embedding functions are defined in the table, this will error when collecting the results.
|
|
195
224
|
*/
|
|
196
|
-
search(query: string):
|
|
225
|
+
abstract search(query: string): VectorQuery;
|
|
197
226
|
/**
|
|
198
227
|
* Create a search query to find the nearest neighbors
|
|
199
228
|
* of the given query vector
|
|
200
229
|
* @param {IntoVector} query - the query vector
|
|
201
230
|
*/
|
|
202
|
-
search(query: IntoVector): VectorQuery;
|
|
231
|
+
abstract search(query: IntoVector): VectorQuery;
|
|
203
232
|
/**
|
|
204
233
|
* Search the table with a given query vector.
|
|
205
234
|
*
|
|
@@ -207,7 +236,7 @@ export declare class Table {
|
|
|
207
236
|
* is the same thing as calling `nearestTo` on the builder returned
|
|
208
237
|
* by `query`. @see {@link Query#nearestTo} for more details.
|
|
209
238
|
*/
|
|
210
|
-
vectorSearch(vector: IntoVector): VectorQuery;
|
|
239
|
+
abstract vectorSearch(vector: IntoVector): VectorQuery;
|
|
211
240
|
/**
|
|
212
241
|
* Add new columns with defined values.
|
|
213
242
|
* @param {AddColumnsSql[]} newColumnTransforms pairs of column names and
|
|
@@ -215,13 +244,13 @@ export declare class Table {
|
|
|
215
244
|
* expressions will be evaluated for each row in the table, and can
|
|
216
245
|
* reference existing columns in the table.
|
|
217
246
|
*/
|
|
218
|
-
addColumns(newColumnTransforms: AddColumnsSql[]): Promise<void>;
|
|
247
|
+
abstract addColumns(newColumnTransforms: AddColumnsSql[]): Promise<void>;
|
|
219
248
|
/**
|
|
220
249
|
* Alter the name or nullability of columns.
|
|
221
250
|
* @param {ColumnAlteration[]} columnAlterations One or more alterations to
|
|
222
251
|
* apply to columns.
|
|
223
252
|
*/
|
|
224
|
-
alterColumns(columnAlterations: ColumnAlteration[]): Promise<void>;
|
|
253
|
+
abstract alterColumns(columnAlterations: ColumnAlteration[]): Promise<void>;
|
|
225
254
|
/**
|
|
226
255
|
* Drop one or more columns from the dataset
|
|
227
256
|
*
|
|
@@ -233,9 +262,9 @@ export declare class Table {
|
|
|
233
262
|
* be nested column references (e.g. "a.b.c") or top-level column names
|
|
234
263
|
* (e.g. "a").
|
|
235
264
|
*/
|
|
236
|
-
dropColumns(columnNames: string[]): Promise<void>;
|
|
265
|
+
abstract dropColumns(columnNames: string[]): Promise<void>;
|
|
237
266
|
/** Retrieve the version of the table */
|
|
238
|
-
version(): Promise<number>;
|
|
267
|
+
abstract version(): Promise<number>;
|
|
239
268
|
/**
|
|
240
269
|
* Checks out a specific version of the table _This is an in-place operation._
|
|
241
270
|
*
|
|
@@ -261,14 +290,14 @@ export declare class Table {
|
|
|
261
290
|
* console.log(await table.version()); // 2
|
|
262
291
|
* ```
|
|
263
292
|
*/
|
|
264
|
-
checkout(version: number): Promise<void>;
|
|
293
|
+
abstract checkout(version: number): Promise<void>;
|
|
265
294
|
/**
|
|
266
295
|
* Checkout the latest version of the table. _This is an in-place operation._
|
|
267
296
|
*
|
|
268
297
|
* The table will be set back into standard mode, and will track the latest
|
|
269
298
|
* version of the table.
|
|
270
299
|
*/
|
|
271
|
-
checkoutLatest(): Promise<void>;
|
|
300
|
+
abstract checkoutLatest(): Promise<void>;
|
|
272
301
|
/**
|
|
273
302
|
* Restore the table to the currently checked out version
|
|
274
303
|
*
|
|
@@ -281,7 +310,7 @@ export declare class Table {
|
|
|
281
310
|
* Once the operation concludes the table will no longer be in a checked
|
|
282
311
|
* out state and the read_consistency_interval, if any, will apply.
|
|
283
312
|
*/
|
|
284
|
-
restore(): Promise<void>;
|
|
313
|
+
abstract restore(): Promise<void>;
|
|
285
314
|
/**
|
|
286
315
|
* Optimize the on-disk data and indices for better performance.
|
|
287
316
|
*
|
|
@@ -312,9 +341,55 @@ export declare class Table {
|
|
|
312
341
|
* you have added or modified 100,000 or more records or run more than 20 data
|
|
313
342
|
* modification operations.
|
|
314
343
|
*/
|
|
315
|
-
optimize(options?: Partial<OptimizeOptions>): Promise<OptimizeStats>;
|
|
344
|
+
abstract optimize(options?: Partial<OptimizeOptions>): Promise<OptimizeStats>;
|
|
316
345
|
/** List all indices that have been created with {@link Table.createIndex} */
|
|
317
|
-
listIndices(): Promise<IndexConfig[]>;
|
|
346
|
+
abstract listIndices(): Promise<IndexConfig[]>;
|
|
318
347
|
/** Return the table as an arrow table */
|
|
348
|
+
abstract toArrow(): Promise<ArrowTable>;
|
|
349
|
+
abstract mergeInsert(on: string | string[]): MergeInsertBuilder;
|
|
350
|
+
/** List all the stats of a specified index
|
|
351
|
+
*
|
|
352
|
+
* @param {string} name The name of the index.
|
|
353
|
+
* @returns {IndexStatistics | undefined} The stats of the index. If the index does not exist, it will return undefined
|
|
354
|
+
*/
|
|
355
|
+
abstract indexStats(name: string): Promise<IndexStatistics | undefined>;
|
|
356
|
+
static parseTableData(data: Record<string, unknown>[] | TableLike, options?: Partial<CreateTableOptions>, streaming?: boolean): Promise<{
|
|
357
|
+
buf: Buffer;
|
|
358
|
+
mode: string;
|
|
359
|
+
}>;
|
|
360
|
+
}
|
|
361
|
+
export declare class LocalTable extends Table {
|
|
362
|
+
private readonly inner;
|
|
363
|
+
constructor(inner: _NativeTable);
|
|
364
|
+
get name(): string;
|
|
365
|
+
isOpen(): boolean;
|
|
366
|
+
close(): void;
|
|
367
|
+
display(): string;
|
|
368
|
+
private getEmbeddingFunctions;
|
|
369
|
+
/** Get the schema of the table. */
|
|
370
|
+
schema(): Promise<Schema>;
|
|
371
|
+
add(data: Data, options?: Partial<AddDataOptions>): Promise<void>;
|
|
372
|
+
update(optsOrUpdates: (Map<string, string> | Record<string, string>) | ({
|
|
373
|
+
values: Map<string, IntoSql> | Record<string, IntoSql>;
|
|
374
|
+
} & Partial<UpdateOptions>) | ({
|
|
375
|
+
valuesSql: Map<string, string> | Record<string, string>;
|
|
376
|
+
} & Partial<UpdateOptions>), options?: Partial<UpdateOptions>): Promise<void>;
|
|
377
|
+
countRows(filter?: string): Promise<number>;
|
|
378
|
+
delete(predicate: string): Promise<void>;
|
|
379
|
+
createIndex(column: string, options?: Partial<IndexOptions>): Promise<void>;
|
|
380
|
+
query(): Query;
|
|
381
|
+
search(query: string | IntoVector): VectorQuery;
|
|
382
|
+
vectorSearch(vector: IntoVector): VectorQuery;
|
|
383
|
+
addColumns(newColumnTransforms: AddColumnsSql[]): Promise<void>;
|
|
384
|
+
alterColumns(columnAlterations: ColumnAlteration[]): Promise<void>;
|
|
385
|
+
dropColumns(columnNames: string[]): Promise<void>;
|
|
386
|
+
version(): Promise<number>;
|
|
387
|
+
checkout(version: number): Promise<void>;
|
|
388
|
+
checkoutLatest(): Promise<void>;
|
|
389
|
+
restore(): Promise<void>;
|
|
390
|
+
optimize(options?: Partial<OptimizeOptions>): Promise<OptimizeStats>;
|
|
391
|
+
listIndices(): Promise<IndexConfig[]>;
|
|
319
392
|
toArrow(): Promise<ArrowTable>;
|
|
393
|
+
indexStats(name: string): Promise<IndexStatistics | undefined>;
|
|
394
|
+
mergeInsert(on: string | string[]): MergeInsertBuilder;
|
|
320
395
|
}
|