@lancedb/lancedb 0.15.0 → 0.15.1-beta.3
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/README.md +1 -1
- package/dist/arrow.d.ts +29 -30
- package/dist/arrow.js +40 -45
- package/dist/connection.d.ts +3 -0
- package/dist/connection.js +32 -16
- package/dist/embedding/embedding_function.d.ts +3 -3
- package/dist/embedding/embedding_function.js +5 -16
- package/dist/embedding/index.d.ts +1 -1
- package/dist/embedding/index.js +2 -13
- package/dist/embedding/openai.js +2 -13
- package/dist/embedding/registry.d.ts +2 -5
- package/dist/embedding/registry.js +2 -15
- package/dist/embedding/transformers.js +2 -13
- package/dist/index.d.ts +11 -7
- package/dist/index.js +11 -22
- package/dist/indices.d.ts +0 -2
- package/dist/indices.js +2 -15
- package/dist/merge.d.ts +2 -2
- package/dist/merge.js +17 -5
- package/dist/native.d.ts +1 -11
- package/dist/native.js +1 -2
- package/dist/query.d.ts +37 -4
- package/dist/query.js +39 -17
- package/dist/rerankers/rrf.d.ts +2 -1
- package/dist/rerankers/rrf.js +2 -1
- package/dist/sanitize.js +2 -13
- package/dist/table.d.ts +24 -8
- package/dist/table.js +13 -40
- package/dist/util.js +2 -0
- package/license_header.txt +2 -0
- package/package.json +10 -10
- package/typedoc_post_process.js +22 -17
package/dist/indices.js
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
// you may not use this file except in compliance with the License.
|
|
6
|
-
// You may obtain a copy of the License at
|
|
7
|
-
//
|
|
8
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
//
|
|
10
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
// See the License for the specific language governing permissions and
|
|
14
|
-
// limitations under the License.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
15
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
5
|
exports.Index = void 0;
|
|
17
6
|
const native_1 = require("./native");
|
|
@@ -97,8 +86,6 @@ class Index {
|
|
|
97
86
|
* The results of a full text search are ordered by relevance measured by BM25.
|
|
98
87
|
*
|
|
99
88
|
* You can combine filters with full text search.
|
|
100
|
-
*
|
|
101
|
-
* For now, the full text search index only supports English, and doesn't support phrase search.
|
|
102
89
|
*/
|
|
103
90
|
static fts(options) {
|
|
104
91
|
return new Index(native_1.Index.fts(options?.withPosition, options?.baseTokenizer, options?.language, options?.maxTokenLength, options?.lowercase, options?.stem, options?.removeStopWords, options?.asciiFolding));
|
package/dist/merge.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Data } from "./arrow";
|
|
1
|
+
import { Data, Schema } from "./arrow";
|
|
2
2
|
import { NativeMergeInsertBuilder } from "./native";
|
|
3
3
|
/** A builder used to create and run a merge insert operation */
|
|
4
4
|
export declare class MergeInsertBuilder {
|
|
5
5
|
#private;
|
|
6
6
|
/** Construct a MergeInsertBuilder. __Internal use only.__ */
|
|
7
|
-
constructor(native: NativeMergeInsertBuilder);
|
|
7
|
+
constructor(native: NativeMergeInsertBuilder, schema: Schema | Promise<Schema>);
|
|
8
8
|
/**
|
|
9
9
|
* Rows that exist in both the source table (new data) and
|
|
10
10
|
* the target table (old data) will be updated, replacing
|
package/dist/merge.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MergeInsertBuilder = void 0;
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
4
6
|
const arrow_1 = require("./arrow");
|
|
5
7
|
/** A builder used to create and run a merge insert operation */
|
|
6
8
|
class MergeInsertBuilder {
|
|
7
9
|
#native;
|
|
10
|
+
#schema;
|
|
8
11
|
/** Construct a MergeInsertBuilder. __Internal use only.__ */
|
|
9
|
-
constructor(native) {
|
|
12
|
+
constructor(native, schema) {
|
|
10
13
|
this.#native = native;
|
|
14
|
+
this.#schema = schema;
|
|
11
15
|
}
|
|
12
16
|
/**
|
|
13
17
|
* Rows that exist in both the source table (new data) and
|
|
@@ -32,14 +36,14 @@ class MergeInsertBuilder {
|
|
|
32
36
|
* For example, "target.last_update < source.last_update"
|
|
33
37
|
*/
|
|
34
38
|
whenMatchedUpdateAll(options) {
|
|
35
|
-
return new MergeInsertBuilder(this.#native.whenMatchedUpdateAll(options?.where));
|
|
39
|
+
return new MergeInsertBuilder(this.#native.whenMatchedUpdateAll(options?.where), this.#schema);
|
|
36
40
|
}
|
|
37
41
|
/**
|
|
38
42
|
* Rows that exist only in the source table (new data) should
|
|
39
43
|
* be inserted into the target table.
|
|
40
44
|
*/
|
|
41
45
|
whenNotMatchedInsertAll() {
|
|
42
|
-
return new MergeInsertBuilder(this.#native.whenNotMatchedInsertAll());
|
|
46
|
+
return new MergeInsertBuilder(this.#native.whenNotMatchedInsertAll(), this.#schema);
|
|
43
47
|
}
|
|
44
48
|
/**
|
|
45
49
|
* Rows that exist only in the target table (old data) will be
|
|
@@ -49,7 +53,7 @@ class MergeInsertBuilder {
|
|
|
49
53
|
* @param options.where - An optional condition to limit what data is deleted
|
|
50
54
|
*/
|
|
51
55
|
whenNotMatchedBySourceDelete(options) {
|
|
52
|
-
return new MergeInsertBuilder(this.#native.whenNotMatchedBySourceDelete(options?.where));
|
|
56
|
+
return new MergeInsertBuilder(this.#native.whenNotMatchedBySourceDelete(options?.where), this.#schema);
|
|
53
57
|
}
|
|
54
58
|
/**
|
|
55
59
|
* Executes the merge insert operation
|
|
@@ -57,7 +61,15 @@ class MergeInsertBuilder {
|
|
|
57
61
|
* Nothing is returned but the `Table` is updated
|
|
58
62
|
*/
|
|
59
63
|
async execute(data) {
|
|
60
|
-
|
|
64
|
+
let schema;
|
|
65
|
+
if (this.#schema instanceof Promise) {
|
|
66
|
+
schema = await this.#schema;
|
|
67
|
+
this.#schema = schema; // In case of future calls
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
schema = this.#schema;
|
|
71
|
+
}
|
|
72
|
+
const buffer = await (0, arrow_1.fromDataToBuffer)(data, undefined, schema);
|
|
61
73
|
await this.#native.execute(buffer);
|
|
62
74
|
}
|
|
63
75
|
}
|
package/dist/native.d.ts
CHANGED
|
@@ -228,17 +228,6 @@ export interface ConnectionOptions {
|
|
|
228
228
|
*/
|
|
229
229
|
hostOverride?: string
|
|
230
230
|
}
|
|
231
|
-
/** Write mode for writing a table. */
|
|
232
|
-
export enum WriteMode {
|
|
233
|
-
Create = 'Create',
|
|
234
|
-
Append = 'Append',
|
|
235
|
-
Overwrite = 'Overwrite'
|
|
236
|
-
}
|
|
237
|
-
/** Write options when creating a Table. */
|
|
238
|
-
export interface WriteOptions {
|
|
239
|
-
/** Write mode for writing to a table. */
|
|
240
|
-
mode?: WriteMode
|
|
241
|
-
}
|
|
242
231
|
export interface OpenTableOptions {
|
|
243
232
|
storageOptions?: Record<string, string>
|
|
244
233
|
}
|
|
@@ -345,6 +334,7 @@ export class Table {
|
|
|
345
334
|
countRows(filter?: string | undefined | null): Promise<number>
|
|
346
335
|
delete(predicate: string): Promise<void>
|
|
347
336
|
createIndex(index: Index | undefined | null, column: string, replace?: boolean | undefined | null): Promise<void>
|
|
337
|
+
dropIndex(indexName: string): Promise<void>
|
|
348
338
|
update(onlyIf: string | undefined | null, columns: Array<[string, string]>): Promise<bigint>
|
|
349
339
|
query(): Query
|
|
350
340
|
vectorSearch(vector: Float32Array): VectorQuery
|
package/dist/native.js
CHANGED
|
@@ -319,7 +319,7 @@ if (!nativeBinding) {
|
|
|
319
319
|
}
|
|
320
320
|
throw new Error(`Failed to load native binding`);
|
|
321
321
|
}
|
|
322
|
-
const { Connection, Index, RecordBatchIterator, NativeMergeInsertBuilder, Query, VectorQuery, Reranker, RrfReranker, Table
|
|
322
|
+
const { Connection, Index, RecordBatchIterator, NativeMergeInsertBuilder, Query, VectorQuery, Reranker, RrfReranker, Table } = nativeBinding;
|
|
323
323
|
module.exports.Connection = Connection;
|
|
324
324
|
module.exports.Index = Index;
|
|
325
325
|
module.exports.RecordBatchIterator = RecordBatchIterator;
|
|
@@ -329,4 +329,3 @@ module.exports.VectorQuery = VectorQuery;
|
|
|
329
329
|
module.exports.Reranker = Reranker;
|
|
330
330
|
module.exports.RrfReranker = RrfReranker;
|
|
331
331
|
module.exports.Table = Table;
|
|
332
|
-
module.exports.WriteMode = WriteMode;
|
package/dist/query.d.ts
CHANGED
|
@@ -32,10 +32,22 @@ export interface FullTextSearchOptions {
|
|
|
32
32
|
*/
|
|
33
33
|
columns?: string | string[];
|
|
34
34
|
}
|
|
35
|
-
/** Common methods supported by all query types
|
|
35
|
+
/** Common methods supported by all query types
|
|
36
|
+
*
|
|
37
|
+
* @see {@link Query}
|
|
38
|
+
* @see {@link VectorQuery}
|
|
39
|
+
*
|
|
40
|
+
* @hideconstructor
|
|
41
|
+
*/
|
|
36
42
|
export declare class QueryBase<NativeQueryType extends NativeQuery | NativeVectorQuery> implements AsyncIterable<RecordBatch> {
|
|
37
43
|
protected inner: NativeQueryType | Promise<NativeQueryType>;
|
|
44
|
+
/**
|
|
45
|
+
* @hidden
|
|
46
|
+
*/
|
|
38
47
|
protected constructor(inner: NativeQueryType | Promise<NativeQueryType>);
|
|
48
|
+
/**
|
|
49
|
+
* @hidden
|
|
50
|
+
*/
|
|
39
51
|
protected doCall(fn: (inner: NativeQueryType) => void): void;
|
|
40
52
|
/**
|
|
41
53
|
* A filter statement to be applied to this query.
|
|
@@ -52,7 +64,7 @@ export declare class QueryBase<NativeQueryType extends NativeQuery | NativeVecto
|
|
|
52
64
|
where(predicate: string): this;
|
|
53
65
|
/**
|
|
54
66
|
* A filter statement to be applied to this query.
|
|
55
|
-
* @
|
|
67
|
+
* @see where
|
|
56
68
|
* @deprecated Use `where` instead
|
|
57
69
|
*/
|
|
58
70
|
filter(predicate: string): this;
|
|
@@ -100,7 +112,7 @@ export declare class QueryBase<NativeQueryType extends NativeQuery | NativeVecto
|
|
|
100
112
|
* Skip searching un-indexed data. This can make search faster, but will miss
|
|
101
113
|
* any data that is not yet indexed.
|
|
102
114
|
*
|
|
103
|
-
* Use {@link
|
|
115
|
+
* Use {@link Table#optimize} to index all un-indexed data.
|
|
104
116
|
*/
|
|
105
117
|
fastSearch(): this;
|
|
106
118
|
/**
|
|
@@ -111,6 +123,9 @@ export declare class QueryBase<NativeQueryType extends NativeQuery | NativeVecto
|
|
|
111
123
|
* order to perform hybrid search.
|
|
112
124
|
*/
|
|
113
125
|
withRowId(): this;
|
|
126
|
+
/**
|
|
127
|
+
* @hidden
|
|
128
|
+
*/
|
|
114
129
|
protected nativeExecute(options?: Partial<QueryExecutionOptions>): Promise<NativeBatchIterator>;
|
|
115
130
|
/**
|
|
116
131
|
* Execute the query and return the results as an @see {@link AsyncIterator}
|
|
@@ -124,6 +139,9 @@ export declare class QueryBase<NativeQueryType extends NativeQuery | NativeVecto
|
|
|
124
139
|
*
|
|
125
140
|
*/
|
|
126
141
|
protected execute(options?: Partial<QueryExecutionOptions>): RecordBatchIterator;
|
|
142
|
+
/**
|
|
143
|
+
* @hidden
|
|
144
|
+
*/
|
|
127
145
|
[Symbol.asyncIterator](): AsyncIterator<RecordBatch<any>>;
|
|
128
146
|
/** Collect the results as an Arrow @see {@link ArrowTable}. */
|
|
129
147
|
toArrow(options?: Partial<QueryExecutionOptions>): Promise<ArrowTable>;
|
|
@@ -156,8 +174,15 @@ export interface ExecutableQuery {
|
|
|
156
174
|
* A builder used to construct a vector search
|
|
157
175
|
*
|
|
158
176
|
* This builder can be reused to execute the query many times.
|
|
177
|
+
*
|
|
178
|
+
* @see {@link Query#nearestTo}
|
|
179
|
+
*
|
|
180
|
+
* @hideconstructor
|
|
159
181
|
*/
|
|
160
182
|
export declare class VectorQuery extends QueryBase<NativeVectorQuery> {
|
|
183
|
+
/**
|
|
184
|
+
* @hidden
|
|
185
|
+
*/
|
|
161
186
|
constructor(inner: NativeVectorQuery | Promise<NativeVectorQuery>);
|
|
162
187
|
/**
|
|
163
188
|
* Set the number of partitions to search (probe)
|
|
@@ -282,8 +307,16 @@ export declare class VectorQuery extends QueryBase<NativeVectorQuery> {
|
|
|
282
307
|
addQueryVector(vector: IntoVector): VectorQuery;
|
|
283
308
|
rerank(reranker: Reranker): VectorQuery;
|
|
284
309
|
}
|
|
285
|
-
/** A builder for LanceDB queries.
|
|
310
|
+
/** A builder for LanceDB queries.
|
|
311
|
+
*
|
|
312
|
+
* @see {@link Table#query}, {@link Table#search}
|
|
313
|
+
*
|
|
314
|
+
* @hideconstructor
|
|
315
|
+
*/
|
|
286
316
|
export declare class Query extends QueryBase<NativeQuery> {
|
|
317
|
+
/**
|
|
318
|
+
* @hidden
|
|
319
|
+
*/
|
|
287
320
|
constructor(tbl: NativeTable);
|
|
288
321
|
/**
|
|
289
322
|
* Find the nearest vectors to the given query vector.
|
package/dist/query.js
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
// you may not use this file except in compliance with the License.
|
|
6
|
-
// You may obtain a copy of the License at
|
|
7
|
-
//
|
|
8
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
//
|
|
10
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
// See the License for the specific language governing permissions and
|
|
14
|
-
// limitations under the License.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
15
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
5
|
exports.Query = exports.VectorQuery = exports.QueryBase = exports.RecordBatchIterator = void 0;
|
|
17
6
|
const arrow_1 = require("./arrow");
|
|
@@ -55,14 +44,26 @@ class RecordBatchIterable {
|
|
|
55
44
|
return new RecordBatchIterator(this.inner.execute(this.options?.maxBatchLength));
|
|
56
45
|
}
|
|
57
46
|
}
|
|
58
|
-
/** Common methods supported by all query types
|
|
47
|
+
/** Common methods supported by all query types
|
|
48
|
+
*
|
|
49
|
+
* @see {@link Query}
|
|
50
|
+
* @see {@link VectorQuery}
|
|
51
|
+
*
|
|
52
|
+
* @hideconstructor
|
|
53
|
+
*/
|
|
59
54
|
class QueryBase {
|
|
60
55
|
inner;
|
|
56
|
+
/**
|
|
57
|
+
* @hidden
|
|
58
|
+
*/
|
|
61
59
|
constructor(inner) {
|
|
62
60
|
this.inner = inner;
|
|
63
61
|
// intentionally empty
|
|
64
62
|
}
|
|
65
63
|
// call a function on the inner (either a promise or the actual object)
|
|
64
|
+
/**
|
|
65
|
+
* @hidden
|
|
66
|
+
*/
|
|
66
67
|
doCall(fn) {
|
|
67
68
|
if (this.inner instanceof Promise) {
|
|
68
69
|
this.inner = this.inner.then((inner) => {
|
|
@@ -92,7 +93,7 @@ class QueryBase {
|
|
|
92
93
|
}
|
|
93
94
|
/**
|
|
94
95
|
* A filter statement to be applied to this query.
|
|
95
|
-
* @
|
|
96
|
+
* @see where
|
|
96
97
|
* @deprecated Use `where` instead
|
|
97
98
|
*/
|
|
98
99
|
filter(predicate) {
|
|
@@ -184,7 +185,7 @@ class QueryBase {
|
|
|
184
185
|
* Skip searching un-indexed data. This can make search faster, but will miss
|
|
185
186
|
* any data that is not yet indexed.
|
|
186
187
|
*
|
|
187
|
-
* Use {@link
|
|
188
|
+
* Use {@link Table#optimize} to index all un-indexed data.
|
|
188
189
|
*/
|
|
189
190
|
fastSearch() {
|
|
190
191
|
this.doCall((inner) => inner.fastSearch());
|
|
@@ -201,6 +202,9 @@ class QueryBase {
|
|
|
201
202
|
this.doCall((inner) => inner.withRowId());
|
|
202
203
|
return this;
|
|
203
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* @hidden
|
|
207
|
+
*/
|
|
204
208
|
nativeExecute(options) {
|
|
205
209
|
if (this.inner instanceof Promise) {
|
|
206
210
|
return this.inner.then((inner) => inner.execute(options?.maxBatchLength));
|
|
@@ -223,6 +227,9 @@ class QueryBase {
|
|
|
223
227
|
execute(options) {
|
|
224
228
|
return new RecordBatchIterator(this.nativeExecute(options));
|
|
225
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* @hidden
|
|
232
|
+
*/
|
|
226
233
|
// biome-ignore lint/suspicious/noExplicitAny: skip
|
|
227
234
|
[Symbol.asyncIterator]() {
|
|
228
235
|
const promise = this.nativeExecute();
|
|
@@ -277,8 +284,15 @@ exports.QueryBase = QueryBase;
|
|
|
277
284
|
* A builder used to construct a vector search
|
|
278
285
|
*
|
|
279
286
|
* This builder can be reused to execute the query many times.
|
|
287
|
+
*
|
|
288
|
+
* @see {@link Query#nearestTo}
|
|
289
|
+
*
|
|
290
|
+
* @hideconstructor
|
|
280
291
|
*/
|
|
281
292
|
class VectorQuery extends QueryBase {
|
|
293
|
+
/**
|
|
294
|
+
* @hidden
|
|
295
|
+
*/
|
|
282
296
|
constructor(inner) {
|
|
283
297
|
super(inner);
|
|
284
298
|
}
|
|
@@ -483,8 +497,16 @@ class VectorQuery extends QueryBase {
|
|
|
483
497
|
}
|
|
484
498
|
}
|
|
485
499
|
exports.VectorQuery = VectorQuery;
|
|
486
|
-
/** A builder for LanceDB queries.
|
|
500
|
+
/** A builder for LanceDB queries.
|
|
501
|
+
*
|
|
502
|
+
* @see {@link Table#query}, {@link Table#search}
|
|
503
|
+
*
|
|
504
|
+
* @hideconstructor
|
|
505
|
+
*/
|
|
487
506
|
class Query extends QueryBase {
|
|
507
|
+
/**
|
|
508
|
+
* @hidden
|
|
509
|
+
*/
|
|
488
510
|
constructor(tbl) {
|
|
489
511
|
super(tbl.query());
|
|
490
512
|
}
|
package/dist/rerankers/rrf.d.ts
CHANGED
|
@@ -3,10 +3,11 @@ import { RrfReranker as NativeRRFReranker } from "../native";
|
|
|
3
3
|
/**
|
|
4
4
|
* Reranks the results using the Reciprocal Rank Fusion (RRF) algorithm.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* @hideconstructor
|
|
7
7
|
*/
|
|
8
8
|
export declare class RRFReranker {
|
|
9
9
|
private inner;
|
|
10
|
+
/** @ignore */
|
|
10
11
|
constructor(inner: NativeRRFReranker);
|
|
11
12
|
static create(k?: number): Promise<RRFReranker>;
|
|
12
13
|
rerankHybrid(query: string, vecResults: RecordBatch, ftsResults: RecordBatch): Promise<RecordBatch>;
|
package/dist/rerankers/rrf.js
CHANGED
|
@@ -8,10 +8,11 @@ const native_1 = require("../native");
|
|
|
8
8
|
/**
|
|
9
9
|
* Reranks the results using the Reciprocal Rank Fusion (RRF) algorithm.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* @hideconstructor
|
|
12
12
|
*/
|
|
13
13
|
class RRFReranker {
|
|
14
14
|
inner;
|
|
15
|
+
/** @ignore */
|
|
15
16
|
constructor(inner) {
|
|
16
17
|
this.inner = inner;
|
|
17
18
|
}
|
package/dist/sanitize.js
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
// you may not use this file except in compliance with the License.
|
|
6
|
-
// You may obtain a copy of the License at
|
|
7
|
-
//
|
|
8
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
//
|
|
10
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
// See the License for the specific language governing permissions and
|
|
14
|
-
// limitations under the License.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
15
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
5
|
exports.sanitizeMetadata = sanitizeMetadata;
|
|
17
6
|
exports.sanitizeInt = sanitizeInt;
|
package/dist/table.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Table as ArrowTable, Data, IntoVector, Schema
|
|
2
|
-
import { CreateTableOptions } from "./connection";
|
|
1
|
+
import { Table as ArrowTable, Data, IntoVector, Schema } from "./arrow";
|
|
3
2
|
import { IndexOptions } from "./indices";
|
|
4
3
|
import { MergeInsertBuilder } from "./merge";
|
|
5
4
|
import { AddColumnsSql, ColumnAlteration, IndexConfig, IndexStatistics, OptimizeStats, Table as _NativeTable } from "./native";
|
|
@@ -61,8 +60,14 @@ export interface Version {
|
|
|
61
60
|
* can call the `close` method. Once the Table is closed, it cannot be used for any
|
|
62
61
|
* further operations.
|
|
63
62
|
*
|
|
63
|
+
* Tables are created using the methods {@link Connection#createTable}
|
|
64
|
+
* and {@link Connection#createEmptyTable}. Existing tables are opened
|
|
65
|
+
* using {@link Connection#openTable}.
|
|
66
|
+
*
|
|
64
67
|
* Closing a table is optional. It not closed, it will be closed when it is garbage
|
|
65
68
|
* collected.
|
|
69
|
+
*
|
|
70
|
+
* @hideconstructor
|
|
66
71
|
*/
|
|
67
72
|
export declare abstract class Table {
|
|
68
73
|
/** Returns the name of the table */
|
|
@@ -148,8 +153,9 @@ export declare abstract class Table {
|
|
|
148
153
|
* Indices on scalar columns will speed up filtering (in both
|
|
149
154
|
* vector and non-vector searches)
|
|
150
155
|
*
|
|
151
|
-
*
|
|
152
|
-
* The index name will always be `${column}_idx
|
|
156
|
+
* We currently don't support custom named indexes.
|
|
157
|
+
* The index name will always be `${column}_idx`.
|
|
158
|
+
*
|
|
153
159
|
* @example
|
|
154
160
|
* // If the column has a vector (fixed size list) data type then
|
|
155
161
|
* // an IvfPq vector index will be created.
|
|
@@ -170,6 +176,17 @@ export declare abstract class Table {
|
|
|
170
176
|
* await table.createIndex("my_float_col");
|
|
171
177
|
*/
|
|
172
178
|
abstract createIndex(column: string, options?: Partial<IndexOptions>): Promise<void>;
|
|
179
|
+
/**
|
|
180
|
+
* Drop an index from the table.
|
|
181
|
+
*
|
|
182
|
+
* @param name The name of the index.
|
|
183
|
+
*
|
|
184
|
+
* This does not delete the index from disk, it just removes it from the table.
|
|
185
|
+
* To delete the index, run {@link Table#optimize} after dropping the index.
|
|
186
|
+
*
|
|
187
|
+
* Use {@link Table.listIndices} to find the names of the indices.
|
|
188
|
+
*/
|
|
189
|
+
abstract dropIndex(name: string): Promise<void>;
|
|
173
190
|
/**
|
|
174
191
|
* Create a {@link Query} Builder.
|
|
175
192
|
*
|
|
@@ -359,12 +376,10 @@ export declare abstract class Table {
|
|
|
359
376
|
*
|
|
360
377
|
* @param {string} name The name of the index.
|
|
361
378
|
* @returns {IndexStatistics | undefined} The stats of the index. If the index does not exist, it will return undefined
|
|
379
|
+
*
|
|
380
|
+
* Use {@link Table.listIndices} to find the names of the indices.
|
|
362
381
|
*/
|
|
363
382
|
abstract indexStats(name: string): Promise<IndexStatistics | undefined>;
|
|
364
|
-
static parseTableData(data: Record<string, unknown>[] | TableLike, options?: Partial<CreateTableOptions>, streaming?: boolean): Promise<{
|
|
365
|
-
buf: Buffer;
|
|
366
|
-
mode: string;
|
|
367
|
-
}>;
|
|
368
383
|
}
|
|
369
384
|
export declare class LocalTable extends Table {
|
|
370
385
|
private readonly inner;
|
|
@@ -385,6 +400,7 @@ export declare class LocalTable extends Table {
|
|
|
385
400
|
countRows(filter?: string): Promise<number>;
|
|
386
401
|
delete(predicate: string): Promise<void>;
|
|
387
402
|
createIndex(column: string, options?: Partial<IndexOptions>): Promise<void>;
|
|
403
|
+
dropIndex(name: string): Promise<void>;
|
|
388
404
|
query(): Query;
|
|
389
405
|
search(query: string | IntoVector, queryType?: string, ftsColumns?: string | string[]): VectorQuery | Query;
|
|
390
406
|
vectorSearch(vector: IntoVector): VectorQuery;
|
package/dist/table.js
CHANGED
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
// you may not use this file except in compliance with the License.
|
|
6
|
-
// You may obtain a copy of the License at
|
|
7
|
-
//
|
|
8
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
//
|
|
10
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
// See the License for the specific language governing permissions and
|
|
14
|
-
// limitations under the License.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
15
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
5
|
exports.LocalTable = exports.Table = void 0;
|
|
17
6
|
const arrow_1 = require("./arrow");
|
|
18
7
|
const registry_1 = require("./embedding/registry");
|
|
19
8
|
const merge_1 = require("./merge");
|
|
20
9
|
const query_1 = require("./query");
|
|
21
|
-
const sanitize_1 = require("./sanitize");
|
|
22
10
|
const util_1 = require("./util");
|
|
23
11
|
/**
|
|
24
12
|
* A Table is a collection of Records in a LanceDB Database.
|
|
@@ -29,35 +17,19 @@ const util_1 = require("./util");
|
|
|
29
17
|
* can call the `close` method. Once the Table is closed, it cannot be used for any
|
|
30
18
|
* further operations.
|
|
31
19
|
*
|
|
20
|
+
* Tables are created using the methods {@link Connection#createTable}
|
|
21
|
+
* and {@link Connection#createEmptyTable}. Existing tables are opened
|
|
22
|
+
* using {@link Connection#openTable}.
|
|
23
|
+
*
|
|
32
24
|
* Closing a table is optional. It not closed, it will be closed when it is garbage
|
|
33
25
|
* collected.
|
|
26
|
+
*
|
|
27
|
+
* @hideconstructor
|
|
34
28
|
*/
|
|
35
29
|
class Table {
|
|
36
30
|
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
37
31
|
return this.display();
|
|
38
32
|
}
|
|
39
|
-
static async parseTableData(data, options, streaming = false) {
|
|
40
|
-
let mode = options?.mode ?? "create";
|
|
41
|
-
const existOk = options?.existOk ?? false;
|
|
42
|
-
if (mode === "create" && existOk) {
|
|
43
|
-
mode = "exist_ok";
|
|
44
|
-
}
|
|
45
|
-
let table;
|
|
46
|
-
if ((0, arrow_1.isArrowTable)(data)) {
|
|
47
|
-
table = (0, sanitize_1.sanitizeTable)(data);
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
table = (0, arrow_1.makeArrowTable)(data, options);
|
|
51
|
-
}
|
|
52
|
-
if (streaming) {
|
|
53
|
-
const buf = await (0, arrow_1.fromTableToStreamBuffer)(table, options?.embeddingFunction, options?.schema);
|
|
54
|
-
return { buf, mode };
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
const buf = await (0, arrow_1.fromTableToBuffer)(table, options?.embeddingFunction, options?.schema);
|
|
58
|
-
return { buf, mode };
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
33
|
}
|
|
62
34
|
exports.Table = Table;
|
|
63
35
|
class LocalTable extends Table {
|
|
@@ -92,9 +64,7 @@ class LocalTable extends Table {
|
|
|
92
64
|
async add(data, options) {
|
|
93
65
|
const mode = options?.mode ?? "append";
|
|
94
66
|
const schema = await this.schema();
|
|
95
|
-
const
|
|
96
|
-
const functions = await registry.parseFunctions(schema.metadata);
|
|
97
|
-
const buffer = await (0, arrow_1.fromDataToBuffer)(data, functions.values().next().value, schema);
|
|
67
|
+
const buffer = await (0, arrow_1.fromDataToBuffer)(data, undefined, schema);
|
|
98
68
|
await this.inner.add(buffer, mode);
|
|
99
69
|
}
|
|
100
70
|
async update(optsOrUpdates, options) {
|
|
@@ -154,6 +124,9 @@ class LocalTable extends Table {
|
|
|
154
124
|
const nativeIndex = options?.config?.inner;
|
|
155
125
|
await this.inner.createIndex(nativeIndex, column, options?.replace);
|
|
156
126
|
}
|
|
127
|
+
async dropIndex(name) {
|
|
128
|
+
await this.inner.dropIndex(name);
|
|
129
|
+
}
|
|
157
130
|
query() {
|
|
158
131
|
return new query_1.Query(this.inner);
|
|
159
132
|
}
|
|
@@ -245,7 +218,7 @@ class LocalTable extends Table {
|
|
|
245
218
|
}
|
|
246
219
|
mergeInsert(on) {
|
|
247
220
|
on = Array.isArray(on) ? on : [on];
|
|
248
|
-
return new merge_1.MergeInsertBuilder(this.inner.mergeInsert(on));
|
|
221
|
+
return new merge_1.MergeInsertBuilder(this.inner.mergeInsert(on), this.schema());
|
|
249
222
|
}
|
|
250
223
|
/**
|
|
251
224
|
* Check if the table uses the new manifest path scheme.
|
package/dist/util.js
CHANGED
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"ann"
|
|
12
12
|
],
|
|
13
13
|
"private": false,
|
|
14
|
-
"version": "0.15.
|
|
14
|
+
"version": "0.15.1-beta.3",
|
|
15
15
|
"main": "dist/index.js",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": "./dist/index.js",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"build": "npm run build:debug && tsc -b && shx cp lancedb/native.d.ts dist/native.d.ts && shx cp lancedb/*.node dist/",
|
|
85
85
|
"build-release": "npm run build:release && tsc -b && shx cp lancedb/native.d.ts dist/native.d.ts",
|
|
86
86
|
"lint-ci": "biome ci .",
|
|
87
|
-
"docs": "typedoc --plugin typedoc-plugin-markdown --out ../docs/src/js lancedb/index.ts",
|
|
87
|
+
"docs": "typedoc --plugin typedoc-plugin-markdown --treatWarningsAsErrors --out ../docs/src/js lancedb/index.ts",
|
|
88
88
|
"postdocs": "node typedoc_post_process.js",
|
|
89
89
|
"lint": "biome check . && biome format .",
|
|
90
90
|
"lint-fix": "biome check --write . && biome format --write .",
|
|
@@ -98,14 +98,14 @@
|
|
|
98
98
|
"reflect-metadata": "^0.2.2"
|
|
99
99
|
},
|
|
100
100
|
"optionalDependencies": {
|
|
101
|
-
"@lancedb/lancedb-darwin-x64": "0.15.
|
|
102
|
-
"@lancedb/lancedb-darwin-arm64": "0.15.
|
|
103
|
-
"@lancedb/lancedb-linux-x64-gnu": "0.15.
|
|
104
|
-
"@lancedb/lancedb-linux-arm64-gnu": "0.15.
|
|
105
|
-
"@lancedb/lancedb-linux-x64-musl": "0.15.
|
|
106
|
-
"@lancedb/lancedb-linux-arm64-musl": "0.15.
|
|
107
|
-
"@lancedb/lancedb-win32-x64-msvc": "0.15.
|
|
108
|
-
"@lancedb/lancedb-win32-arm64-msvc": "0.15.
|
|
101
|
+
"@lancedb/lancedb-darwin-x64": "0.15.1-beta.3",
|
|
102
|
+
"@lancedb/lancedb-darwin-arm64": "0.15.1-beta.3",
|
|
103
|
+
"@lancedb/lancedb-linux-x64-gnu": "0.15.1-beta.3",
|
|
104
|
+
"@lancedb/lancedb-linux-arm64-gnu": "0.15.1-beta.3",
|
|
105
|
+
"@lancedb/lancedb-linux-x64-musl": "0.15.1-beta.3",
|
|
106
|
+
"@lancedb/lancedb-linux-arm64-musl": "0.15.1-beta.3",
|
|
107
|
+
"@lancedb/lancedb-win32-x64-msvc": "0.15.1-beta.3",
|
|
108
|
+
"@lancedb/lancedb-win32-arm64-msvc": "0.15.1-beta.3"
|
|
109
109
|
},
|
|
110
110
|
"peerDependencies": {
|
|
111
111
|
"apache-arrow": ">=15.0.0 <=18.1.0"
|