@lancedb/lancedb 0.5.1 → 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 +42 -7
- package/dist/arrow.js +6 -5
- package/dist/connection.d.ts +55 -29
- package/dist/connection.js +22 -74
- package/dist/embedding/embedding_function.d.ts +11 -3
- package/dist/embedding/embedding_function.js +36 -12
- package/dist/embedding/openai.d.ts +6 -5
- package/dist/embedding/openai.js +4 -2
- package/dist/embedding/registry.d.ts +10 -11
- package/dist/embedding/registry.js +4 -0
- 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 +34 -7
- package/dist/native.js +26 -9
- package/dist/query.d.ts +51 -16
- package/dist/query.js +122 -21
- 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 +116 -25
- package/dist/table.js +117 -233
- 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 +87 -24
- package/lancedb/connection.ts +115 -92
- package/lancedb/embedding/embedding_function.ts +48 -16
- package/lancedb/embedding/openai.ts +11 -6
- package/lancedb/embedding/registry.ts +38 -22
- package/lancedb/index.ts +101 -2
- package/lancedb/merge.ts +70 -0
- package/lancedb/query.ts +168 -39
- 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 +344 -101
- package/lancedb/util.ts +69 -0
- package/native.d.ts +208 -0
- package/nodejs-artifacts/arrow.d.ts +42 -7
- package/nodejs-artifacts/arrow.js +6 -5
- package/nodejs-artifacts/connection.d.ts +55 -29
- package/nodejs-artifacts/connection.js +22 -74
- package/nodejs-artifacts/embedding/embedding_function.d.ts +11 -3
- package/nodejs-artifacts/embedding/embedding_function.js +36 -12
- package/nodejs-artifacts/embedding/openai.d.ts +6 -5
- package/nodejs-artifacts/embedding/openai.js +4 -2
- package/nodejs-artifacts/embedding/registry.d.ts +10 -11
- package/nodejs-artifacts/embedding/registry.js +4 -0
- 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 +34 -7
- package/nodejs-artifacts/native.js +26 -9
- package/nodejs-artifacts/query.d.ts +51 -16
- package/nodejs-artifacts/query.js +122 -21
- 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 +116 -25
- package/nodejs-artifacts/table.js +117 -233
- package/nodejs-artifacts/util.d.ts +14 -0
- package/nodejs-artifacts/util.js +65 -0
- package/package.json +25 -11
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2023 LanceDB Developers.
|
|
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.
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.RemoteTable = void 0;
|
|
17
|
+
const table_1 = require("../table");
|
|
18
|
+
const util_1 = require("../util");
|
|
19
|
+
class RemoteTable extends table_1.Table {
|
|
20
|
+
#client;
|
|
21
|
+
#name;
|
|
22
|
+
// Used in the display() method
|
|
23
|
+
#dbName;
|
|
24
|
+
get #tablePrefix() {
|
|
25
|
+
return `/v1/table/${encodeURIComponent(this.#name)}/`;
|
|
26
|
+
}
|
|
27
|
+
get name() {
|
|
28
|
+
return this.#name;
|
|
29
|
+
}
|
|
30
|
+
constructor(client, tableName, dbName) {
|
|
31
|
+
super();
|
|
32
|
+
this.#client = client;
|
|
33
|
+
this.#name = tableName;
|
|
34
|
+
this.#dbName = dbName;
|
|
35
|
+
}
|
|
36
|
+
isOpen() {
|
|
37
|
+
return !this.#client.isOpen();
|
|
38
|
+
}
|
|
39
|
+
close() {
|
|
40
|
+
this.#client.close();
|
|
41
|
+
}
|
|
42
|
+
display() {
|
|
43
|
+
return `RemoteTable(${this.#dbName}; ${this.#name})`;
|
|
44
|
+
}
|
|
45
|
+
async schema() {
|
|
46
|
+
const resp = await this.#client.post(`${this.#tablePrefix}/describe/`);
|
|
47
|
+
// TODO: parse this into a valid arrow schema
|
|
48
|
+
return resp.schema;
|
|
49
|
+
}
|
|
50
|
+
async add(data, options) {
|
|
51
|
+
const { buf, mode } = await table_1.Table.parseTableData(data, options, true);
|
|
52
|
+
await this.#client.post(`${this.#tablePrefix}/insert/`, buf, {
|
|
53
|
+
params: {
|
|
54
|
+
mode,
|
|
55
|
+
},
|
|
56
|
+
headers: {
|
|
57
|
+
"Content-Type": "application/vnd.apache.arrow.stream",
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
async update(optsOrUpdates, options) {
|
|
62
|
+
const isValues = "values" in optsOrUpdates && typeof optsOrUpdates.values !== "string";
|
|
63
|
+
const isValuesSql = "valuesSql" in optsOrUpdates &&
|
|
64
|
+
typeof optsOrUpdates.valuesSql !== "string";
|
|
65
|
+
const isMap = (obj) => {
|
|
66
|
+
return obj instanceof Map;
|
|
67
|
+
};
|
|
68
|
+
let predicate;
|
|
69
|
+
let columns;
|
|
70
|
+
switch (true) {
|
|
71
|
+
case isMap(optsOrUpdates):
|
|
72
|
+
columns = Array.from(optsOrUpdates.entries());
|
|
73
|
+
predicate = options?.where;
|
|
74
|
+
break;
|
|
75
|
+
case isValues && isMap(optsOrUpdates.values):
|
|
76
|
+
columns = Array.from(optsOrUpdates.values.entries()).map(([k, v]) => [
|
|
77
|
+
k,
|
|
78
|
+
(0, util_1.toSQL)(v),
|
|
79
|
+
]);
|
|
80
|
+
predicate = optsOrUpdates.where;
|
|
81
|
+
break;
|
|
82
|
+
case isValues && !isMap(optsOrUpdates.values):
|
|
83
|
+
columns = Object.entries(optsOrUpdates.values).map(([k, v]) => [
|
|
84
|
+
k,
|
|
85
|
+
(0, util_1.toSQL)(v),
|
|
86
|
+
]);
|
|
87
|
+
predicate = optsOrUpdates.where;
|
|
88
|
+
break;
|
|
89
|
+
case isValuesSql && isMap(optsOrUpdates.valuesSql):
|
|
90
|
+
columns = Array.from(optsOrUpdates.valuesSql.entries());
|
|
91
|
+
predicate = optsOrUpdates.where;
|
|
92
|
+
break;
|
|
93
|
+
case isValuesSql && !isMap(optsOrUpdates.valuesSql):
|
|
94
|
+
columns = Object.entries(optsOrUpdates.valuesSql).map(([k, v]) => [
|
|
95
|
+
k,
|
|
96
|
+
v,
|
|
97
|
+
]);
|
|
98
|
+
predicate = optsOrUpdates.where;
|
|
99
|
+
break;
|
|
100
|
+
default:
|
|
101
|
+
columns = Object.entries(optsOrUpdates);
|
|
102
|
+
predicate = options?.where;
|
|
103
|
+
}
|
|
104
|
+
await this.#client.post(`${this.#tablePrefix}/update/`, {
|
|
105
|
+
predicate: predicate ?? null,
|
|
106
|
+
updates: columns,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
async countRows(filter) {
|
|
110
|
+
const payload = { predicate: filter };
|
|
111
|
+
return await this.#client.post(`${this.#tablePrefix}/count_rows/`, payload);
|
|
112
|
+
}
|
|
113
|
+
async delete(predicate) {
|
|
114
|
+
const payload = { predicate };
|
|
115
|
+
await this.#client.post(`${this.#tablePrefix}/delete/`, payload);
|
|
116
|
+
}
|
|
117
|
+
async createIndex(column, options) {
|
|
118
|
+
if (options !== undefined) {
|
|
119
|
+
console.warn("options are not yet supported on the LanceDB cloud");
|
|
120
|
+
}
|
|
121
|
+
const indexType = "vector";
|
|
122
|
+
const metric = "L2";
|
|
123
|
+
const data = {
|
|
124
|
+
column,
|
|
125
|
+
// biome-ignore lint/style/useNamingConvention: external API
|
|
126
|
+
index_type: indexType,
|
|
127
|
+
// biome-ignore lint/style/useNamingConvention: external API
|
|
128
|
+
metric_type: metric,
|
|
129
|
+
};
|
|
130
|
+
await this.#client.post(`${this.#tablePrefix}/create_index`, data);
|
|
131
|
+
}
|
|
132
|
+
query() {
|
|
133
|
+
throw new Error("query() is not yet supported on the LanceDB cloud");
|
|
134
|
+
}
|
|
135
|
+
search(_query) {
|
|
136
|
+
throw new Error("search() is not yet supported on the LanceDB cloud");
|
|
137
|
+
}
|
|
138
|
+
vectorSearch(_vector) {
|
|
139
|
+
throw new Error("vectorSearch() is not yet supported on the LanceDB cloud");
|
|
140
|
+
}
|
|
141
|
+
addColumns(_newColumnTransforms) {
|
|
142
|
+
throw new Error("addColumns() is not yet supported on the LanceDB cloud");
|
|
143
|
+
}
|
|
144
|
+
alterColumns(_columnAlterations) {
|
|
145
|
+
throw new Error("alterColumns() is not yet supported on the LanceDB cloud");
|
|
146
|
+
}
|
|
147
|
+
dropColumns(_columnNames) {
|
|
148
|
+
throw new Error("dropColumns() is not yet supported on the LanceDB cloud");
|
|
149
|
+
}
|
|
150
|
+
async version() {
|
|
151
|
+
const resp = await this.#client.post(`${this.#tablePrefix}/describe/`);
|
|
152
|
+
return resp.version;
|
|
153
|
+
}
|
|
154
|
+
checkout(_version) {
|
|
155
|
+
throw new Error("checkout() is not yet supported on the LanceDB cloud");
|
|
156
|
+
}
|
|
157
|
+
checkoutLatest() {
|
|
158
|
+
throw new Error("checkoutLatest() is not yet supported on the LanceDB cloud");
|
|
159
|
+
}
|
|
160
|
+
restore() {
|
|
161
|
+
throw new Error("restore() is not yet supported on the LanceDB cloud");
|
|
162
|
+
}
|
|
163
|
+
optimize(_options) {
|
|
164
|
+
throw new Error("optimize() is not yet supported on the LanceDB cloud");
|
|
165
|
+
}
|
|
166
|
+
async listIndices() {
|
|
167
|
+
return await this.#client.post(`${this.#tablePrefix}/index/list/`);
|
|
168
|
+
}
|
|
169
|
+
toArrow() {
|
|
170
|
+
throw new Error("toArrow() is not yet supported on the LanceDB cloud");
|
|
171
|
+
}
|
|
172
|
+
mergeInsert(_on) {
|
|
173
|
+
throw new Error("mergeInsert() is not yet supported on the LanceDB cloud");
|
|
174
|
+
}
|
|
175
|
+
async indexStats(_name) {
|
|
176
|
+
throw new Error("indexStats() is not yet supported on the LanceDB cloud");
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
exports.RemoteTable = RemoteTable;
|
package/dist/sanitize.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TKeys } from "apache-arrow/type";
|
|
2
|
-
import { DataType, Date_, Decimal, DenseUnion, Dictionary, Duration, Field, FixedSizeBinary, FixedSizeList, Float, Int, Interval, List, Map_, Schema, SparseUnion, Struct, Time, Timestamp, TimestampMicrosecond, TimestampMillisecond, TimestampNanosecond, TimestampSecond, Type, Union } from "./arrow";
|
|
2
|
+
import { DataType, Date_, Decimal, DenseUnion, Dictionary, Duration, Field, FixedSizeBinary, FixedSizeList, Float, Int, Interval, List, Map_, Schema, SchemaLike, SparseUnion, Struct, Table, TableLike, Time, Timestamp, TimestampMicrosecond, TimestampMillisecond, TimestampNanosecond, TimestampSecond, Type, Union } from "./arrow";
|
|
3
3
|
export declare function sanitizeMetadata(metadataLike?: unknown): Map<string, string> | undefined;
|
|
4
4
|
export declare function sanitizeInt(typeLike: object): Int<Type.Int | Type.Int8 | Type.Int16 | Type.Int32 | Type.Int64 | Type.Uint8 | Type.Uint16 | Type.Uint32 | Type.Uint64>;
|
|
5
5
|
export declare function sanitizeFloat(typeLike: object): Float<Type.Float | Type.Float16 | Type.Float32 | Type.Float64>;
|
|
@@ -27,4 +27,5 @@ export declare function sanitizeField(fieldLike: unknown): Field;
|
|
|
27
27
|
* instance because they might be using a different instance of apache-arrow
|
|
28
28
|
* than lancedb is using.
|
|
29
29
|
*/
|
|
30
|
-
export declare function sanitizeSchema(schemaLike:
|
|
30
|
+
export declare function sanitizeSchema(schemaLike: SchemaLike): Schema;
|
|
31
|
+
export declare function sanitizeTable(tableLike: TableLike): Table;
|
package/dist/sanitize.js
CHANGED
|
@@ -13,7 +13,15 @@
|
|
|
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.sanitizeSchema = exports.sanitizeField = exports.sanitizeType = exports.sanitizeDictionary = exports.sanitizeDuration = exports.sanitizeMap = exports.sanitizeFixedSizeList = exports.sanitizeFixedSizeBinary = exports.sanitizeTypedUnion = exports.sanitizeUnion = exports.sanitizeStruct = exports.sanitizeList = exports.sanitizeInterval = exports.sanitizeTypedTimestamp = exports.sanitizeTimestamp = exports.sanitizeTime = exports.sanitizeDate = exports.sanitizeDecimal = exports.sanitizeFloat = exports.sanitizeInt = exports.sanitizeMetadata = void 0;
|
|
16
|
+
exports.sanitizeTable = exports.sanitizeSchema = exports.sanitizeField = exports.sanitizeType = exports.sanitizeDictionary = exports.sanitizeDuration = exports.sanitizeMap = exports.sanitizeFixedSizeList = exports.sanitizeFixedSizeBinary = exports.sanitizeTypedUnion = exports.sanitizeUnion = exports.sanitizeStruct = exports.sanitizeList = exports.sanitizeInterval = exports.sanitizeTypedTimestamp = exports.sanitizeTimestamp = exports.sanitizeTime = exports.sanitizeDate = exports.sanitizeDecimal = exports.sanitizeFloat = exports.sanitizeInt = exports.sanitizeMetadata = void 0;
|
|
17
|
+
// The utilities in this file help sanitize data from the user's arrow
|
|
18
|
+
// library into the types expected by vectordb's arrow library. Node
|
|
19
|
+
// generally allows for mulitple versions of the same library (and sometimes
|
|
20
|
+
// even multiple copies of the same version) to be installed at the same
|
|
21
|
+
// time. However, arrow-js uses instanceof which expected that the input
|
|
22
|
+
// comes from the exact same library instance. This is not always the case
|
|
23
|
+
// and so we must sanitize the input to ensure that it is compatible.
|
|
24
|
+
const apache_arrow_1 = require("apache-arrow");
|
|
17
25
|
const arrow_1 = require("./arrow");
|
|
18
26
|
function sanitizeMetadata(metadataLike) {
|
|
19
27
|
if (metadataLike === undefined || metadataLike === null) {
|
|
@@ -380,3 +388,49 @@ function sanitizeSchema(schemaLike) {
|
|
|
380
388
|
return new arrow_1.Schema(sanitizedFields, metadata);
|
|
381
389
|
}
|
|
382
390
|
exports.sanitizeSchema = sanitizeSchema;
|
|
391
|
+
function sanitizeTable(tableLike) {
|
|
392
|
+
if (tableLike instanceof arrow_1.Table) {
|
|
393
|
+
return tableLike;
|
|
394
|
+
}
|
|
395
|
+
if (typeof tableLike !== "object" || tableLike === null) {
|
|
396
|
+
throw Error("Expected a Table but object was null/undefined");
|
|
397
|
+
}
|
|
398
|
+
if (!("schema" in tableLike)) {
|
|
399
|
+
throw Error("The table passed in does not appear to be a table (no 'schema' property)");
|
|
400
|
+
}
|
|
401
|
+
if (!("batches" in tableLike)) {
|
|
402
|
+
throw Error("The table passed in does not appear to be a table (no 'columns' property)");
|
|
403
|
+
}
|
|
404
|
+
const schema = sanitizeSchema(tableLike.schema);
|
|
405
|
+
const batches = tableLike.batches.map(sanitizeRecordBatch);
|
|
406
|
+
return new arrow_1.Table(schema, batches);
|
|
407
|
+
}
|
|
408
|
+
exports.sanitizeTable = sanitizeTable;
|
|
409
|
+
function sanitizeRecordBatch(batchLike) {
|
|
410
|
+
if (batchLike instanceof arrow_1.RecordBatch) {
|
|
411
|
+
return batchLike;
|
|
412
|
+
}
|
|
413
|
+
if (typeof batchLike !== "object" || batchLike === null) {
|
|
414
|
+
throw Error("Expected a RecordBatch but object was null/undefined");
|
|
415
|
+
}
|
|
416
|
+
if (!("schema" in batchLike)) {
|
|
417
|
+
throw Error("The record batch passed in does not appear to be a record batch (no 'schema' property)");
|
|
418
|
+
}
|
|
419
|
+
if (!("data" in batchLike)) {
|
|
420
|
+
throw Error("The record batch passed in does not appear to be a record batch (no 'data' property)");
|
|
421
|
+
}
|
|
422
|
+
const schema = sanitizeSchema(batchLike.schema);
|
|
423
|
+
const data = sanitizeData(batchLike.data);
|
|
424
|
+
return new arrow_1.RecordBatch(schema, data);
|
|
425
|
+
}
|
|
426
|
+
function sanitizeData(dataLike) {
|
|
427
|
+
if (dataLike instanceof apache_arrow_1.Data) {
|
|
428
|
+
return dataLike;
|
|
429
|
+
}
|
|
430
|
+
return new apache_arrow_1.Data(dataLike.type, dataLike.offset, dataLike.length, dataLike.nullCount, {
|
|
431
|
+
[apache_arrow_1.BufferType.OFFSET]: dataLike.valueOffsets,
|
|
432
|
+
[apache_arrow_1.BufferType.DATA]: dataLike.values,
|
|
433
|
+
[apache_arrow_1.BufferType.VALIDITY]: dataLike.nullBitmap,
|
|
434
|
+
[apache_arrow_1.BufferType.TYPE]: dataLike.typeIds,
|
|
435
|
+
});
|
|
436
|
+
}
|
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,12 +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
|
-
constructor(inner: _NativeTable);
|
|
62
|
+
export declare abstract class Table {
|
|
63
|
+
/** Returns the name of the table */
|
|
64
|
+
abstract get name(): string;
|
|
62
65
|
/** Return true if the table has not been closed */
|
|
63
|
-
isOpen(): boolean;
|
|
66
|
+
abstract isOpen(): boolean;
|
|
64
67
|
/**
|
|
65
68
|
* Close the table, releasing any underlying resources.
|
|
66
69
|
*
|
|
@@ -68,16 +71,40 @@ export declare class Table {
|
|
|
68
71
|
*
|
|
69
72
|
* Any attempt to use the table after it is closed will result in an error.
|
|
70
73
|
*/
|
|
71
|
-
close(): void;
|
|
74
|
+
abstract close(): void;
|
|
72
75
|
/** Return a brief description of the table */
|
|
73
|
-
display(): string;
|
|
76
|
+
abstract display(): string;
|
|
74
77
|
/** Get the schema of the table. */
|
|
75
|
-
schema(): Promise<Schema>;
|
|
78
|
+
abstract schema(): Promise<Schema>;
|
|
76
79
|
/**
|
|
77
80
|
* Insert records into this Table.
|
|
78
81
|
* @param {Data} data Records to be inserted into the Table
|
|
79
82
|
*/
|
|
80
|
-
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>;
|
|
81
108
|
/**
|
|
82
109
|
* Update existing records in the Table
|
|
83
110
|
*
|
|
@@ -103,11 +130,11 @@ export declare class Table {
|
|
|
103
130
|
* @param {Partial<UpdateOptions>} options - additional options to control
|
|
104
131
|
* the update behavior
|
|
105
132
|
*/
|
|
106
|
-
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>;
|
|
107
134
|
/** Count the total number of rows in the dataset. */
|
|
108
|
-
countRows(filter?: string): Promise<number>;
|
|
135
|
+
abstract countRows(filter?: string): Promise<number>;
|
|
109
136
|
/** Delete the rows that satisfy the predicate. */
|
|
110
|
-
delete(predicate: string): Promise<void>;
|
|
137
|
+
abstract delete(predicate: string): Promise<void>;
|
|
111
138
|
/**
|
|
112
139
|
* Create an index to speed up queries.
|
|
113
140
|
*
|
|
@@ -115,6 +142,9 @@ export declare class Table {
|
|
|
115
142
|
* Indices on vector columns will speed up vector searches.
|
|
116
143
|
* Indices on scalar columns will speed up filtering (in both
|
|
117
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`
|
|
118
148
|
* @example
|
|
119
149
|
* // If the column has a vector (fixed size list) data type then
|
|
120
150
|
* // an IvfPq vector index will be created.
|
|
@@ -134,7 +164,7 @@ export declare class Table {
|
|
|
134
164
|
* // Or create a Scalar index
|
|
135
165
|
* await table.createIndex("my_float_col");
|
|
136
166
|
*/
|
|
137
|
-
createIndex(column: string, options?: Partial<IndexOptions>): Promise<void>;
|
|
167
|
+
abstract createIndex(column: string, options?: Partial<IndexOptions>): Promise<void>;
|
|
138
168
|
/**
|
|
139
169
|
* Create a {@link Query} Builder.
|
|
140
170
|
*
|
|
@@ -185,7 +215,20 @@ export declare class Table {
|
|
|
185
215
|
* }
|
|
186
216
|
* @returns {Query} A builder that can be used to parameterize the query
|
|
187
217
|
*/
|
|
188
|
-
query(): Query;
|
|
218
|
+
abstract query(): Query;
|
|
219
|
+
/**
|
|
220
|
+
* Create a search query to find the nearest neighbors
|
|
221
|
+
* of the given query vector
|
|
222
|
+
* @param {string} query - the query. This will be converted to a vector using the table's provided embedding function
|
|
223
|
+
* @note If no embedding functions are defined in the table, this will error when collecting the results.
|
|
224
|
+
*/
|
|
225
|
+
abstract search(query: string): VectorQuery;
|
|
226
|
+
/**
|
|
227
|
+
* Create a search query to find the nearest neighbors
|
|
228
|
+
* of the given query vector
|
|
229
|
+
* @param {IntoVector} query - the query vector
|
|
230
|
+
*/
|
|
231
|
+
abstract search(query: IntoVector): VectorQuery;
|
|
189
232
|
/**
|
|
190
233
|
* Search the table with a given query vector.
|
|
191
234
|
*
|
|
@@ -193,7 +236,7 @@ export declare class Table {
|
|
|
193
236
|
* is the same thing as calling `nearestTo` on the builder returned
|
|
194
237
|
* by `query`. @see {@link Query#nearestTo} for more details.
|
|
195
238
|
*/
|
|
196
|
-
vectorSearch(vector:
|
|
239
|
+
abstract vectorSearch(vector: IntoVector): VectorQuery;
|
|
197
240
|
/**
|
|
198
241
|
* Add new columns with defined values.
|
|
199
242
|
* @param {AddColumnsSql[]} newColumnTransforms pairs of column names and
|
|
@@ -201,13 +244,13 @@ export declare class Table {
|
|
|
201
244
|
* expressions will be evaluated for each row in the table, and can
|
|
202
245
|
* reference existing columns in the table.
|
|
203
246
|
*/
|
|
204
|
-
addColumns(newColumnTransforms: AddColumnsSql[]): Promise<void>;
|
|
247
|
+
abstract addColumns(newColumnTransforms: AddColumnsSql[]): Promise<void>;
|
|
205
248
|
/**
|
|
206
249
|
* Alter the name or nullability of columns.
|
|
207
250
|
* @param {ColumnAlteration[]} columnAlterations One or more alterations to
|
|
208
251
|
* apply to columns.
|
|
209
252
|
*/
|
|
210
|
-
alterColumns(columnAlterations: ColumnAlteration[]): Promise<void>;
|
|
253
|
+
abstract alterColumns(columnAlterations: ColumnAlteration[]): Promise<void>;
|
|
211
254
|
/**
|
|
212
255
|
* Drop one or more columns from the dataset
|
|
213
256
|
*
|
|
@@ -219,9 +262,9 @@ export declare class Table {
|
|
|
219
262
|
* be nested column references (e.g. "a.b.c") or top-level column names
|
|
220
263
|
* (e.g. "a").
|
|
221
264
|
*/
|
|
222
|
-
dropColumns(columnNames: string[]): Promise<void>;
|
|
265
|
+
abstract dropColumns(columnNames: string[]): Promise<void>;
|
|
223
266
|
/** Retrieve the version of the table */
|
|
224
|
-
version(): Promise<number>;
|
|
267
|
+
abstract version(): Promise<number>;
|
|
225
268
|
/**
|
|
226
269
|
* Checks out a specific version of the table _This is an in-place operation._
|
|
227
270
|
*
|
|
@@ -247,14 +290,14 @@ export declare class Table {
|
|
|
247
290
|
* console.log(await table.version()); // 2
|
|
248
291
|
* ```
|
|
249
292
|
*/
|
|
250
|
-
checkout(version: number): Promise<void>;
|
|
293
|
+
abstract checkout(version: number): Promise<void>;
|
|
251
294
|
/**
|
|
252
295
|
* Checkout the latest version of the table. _This is an in-place operation._
|
|
253
296
|
*
|
|
254
297
|
* The table will be set back into standard mode, and will track the latest
|
|
255
298
|
* version of the table.
|
|
256
299
|
*/
|
|
257
|
-
checkoutLatest(): Promise<void>;
|
|
300
|
+
abstract checkoutLatest(): Promise<void>;
|
|
258
301
|
/**
|
|
259
302
|
* Restore the table to the currently checked out version
|
|
260
303
|
*
|
|
@@ -267,7 +310,7 @@ export declare class Table {
|
|
|
267
310
|
* Once the operation concludes the table will no longer be in a checked
|
|
268
311
|
* out state and the read_consistency_interval, if any, will apply.
|
|
269
312
|
*/
|
|
270
|
-
restore(): Promise<void>;
|
|
313
|
+
abstract restore(): Promise<void>;
|
|
271
314
|
/**
|
|
272
315
|
* Optimize the on-disk data and indices for better performance.
|
|
273
316
|
*
|
|
@@ -298,7 +341,55 @@ export declare class Table {
|
|
|
298
341
|
* you have added or modified 100,000 or more records or run more than 20 data
|
|
299
342
|
* modification operations.
|
|
300
343
|
*/
|
|
301
|
-
optimize(options?: Partial<OptimizeOptions>): Promise<OptimizeStats>;
|
|
344
|
+
abstract optimize(options?: Partial<OptimizeOptions>): Promise<OptimizeStats>;
|
|
302
345
|
/** List all indices that have been created with {@link Table.createIndex} */
|
|
346
|
+
abstract listIndices(): Promise<IndexConfig[]>;
|
|
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>;
|
|
303
391
|
listIndices(): Promise<IndexConfig[]>;
|
|
392
|
+
toArrow(): Promise<ArrowTable>;
|
|
393
|
+
indexStats(name: string): Promise<IndexStatistics | undefined>;
|
|
394
|
+
mergeInsert(on: string | string[]): MergeInsertBuilder;
|
|
304
395
|
}
|