@lancedb/lancedb 0.11.0-beta.0 → 0.11.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/dist/index.d.ts +3 -4
- package/dist/index.js +3 -5
- package/dist/native.d.ts +103 -8
- package/package.json +9 -9
- package/dist/remote/client.d.ts +0 -27
- package/dist/remote/client.js +0 -170
- package/dist/remote/connection.d.ts +0 -24
- package/dist/remote/connection.js +0 -110
- package/dist/remote/index.d.ts +0 -3
- package/dist/remote/index.js +0 -9
- package/dist/remote/table.d.ts +0 -42
- package/dist/remote/table.js +0 -179
- package/native.d.ts +0 -208
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Connection } from "./connection";
|
|
2
2
|
import { ConnectionOptions } from "./native.js";
|
|
3
|
-
|
|
4
|
-
export { WriteOptions, WriteMode, AddColumnsSql, ColumnAlteration, ConnectionOptions, IndexStatistics, IndexMetadata, IndexConfig, } from "./native.js";
|
|
3
|
+
export { WriteOptions, WriteMode, AddColumnsSql, ColumnAlteration, ConnectionOptions, IndexStatistics, IndexConfig, ClientConfig, TimeoutConfig, RetryConfig, } from "./native.js";
|
|
5
4
|
export { makeArrowTable, MakeArrowTableOptions, Data, VectorColumnOptions, } from "./arrow";
|
|
6
5
|
export { Connection, CreateTableOptions, TableNamesOptions, } from "./connection";
|
|
7
6
|
export { ExecutableQuery, Query, QueryBase, VectorQuery, RecordBatchIterator, } from "./query";
|
|
@@ -31,7 +30,7 @@ export * as embedding from "./embedding";
|
|
|
31
30
|
* });
|
|
32
31
|
* ```
|
|
33
32
|
*/
|
|
34
|
-
export declare function connect(uri: string, opts?: Partial<ConnectionOptions
|
|
33
|
+
export declare function connect(uri: string, opts?: Partial<ConnectionOptions>): Promise<Connection>;
|
|
35
34
|
/**
|
|
36
35
|
* Connect to a LanceDB instance at the given URI.
|
|
37
36
|
*
|
|
@@ -50,6 +49,6 @@ export declare function connect(uri: string, opts?: Partial<ConnectionOptions |
|
|
|
50
49
|
* });
|
|
51
50
|
* ```
|
|
52
51
|
*/
|
|
53
|
-
export declare function connect(opts: Partial<
|
|
52
|
+
export declare function connect(opts: Partial<ConnectionOptions> & {
|
|
54
53
|
uri: string;
|
|
55
54
|
}): Promise<Connection>;
|
package/dist/index.js
CHANGED
|
@@ -13,11 +13,12 @@
|
|
|
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.embedding = exports.Table = exports.Index = exports.RecordBatchIterator = exports.VectorQuery = exports.QueryBase = exports.Query = exports.Connection = exports.VectorColumnOptions = exports.MakeArrowTableOptions = exports.makeArrowTable = void 0;
|
|
16
|
+
exports.embedding = exports.Table = exports.Index = exports.RecordBatchIterator = exports.VectorQuery = exports.QueryBase = exports.Query = exports.Connection = exports.VectorColumnOptions = exports.MakeArrowTableOptions = exports.makeArrowTable = exports.WriteMode = void 0;
|
|
17
17
|
exports.connect = connect;
|
|
18
18
|
const connection_1 = require("./connection");
|
|
19
19
|
const native_js_1 = require("./native.js");
|
|
20
|
-
|
|
20
|
+
var native_js_2 = require("./native.js");
|
|
21
|
+
Object.defineProperty(exports, "WriteMode", { enumerable: true, get: function () { return native_js_2.WriteMode; } });
|
|
21
22
|
var arrow_1 = require("./arrow");
|
|
22
23
|
Object.defineProperty(exports, "makeArrowTable", { enumerable: true, get: function () { return arrow_1.makeArrowTable; } });
|
|
23
24
|
Object.defineProperty(exports, "MakeArrowTableOptions", { enumerable: true, get: function () { return arrow_1.MakeArrowTableOptions; } });
|
|
@@ -47,9 +48,6 @@ async function connect(uriOrOptions, opts = {}) {
|
|
|
47
48
|
if (!uri) {
|
|
48
49
|
throw new Error("uri is required");
|
|
49
50
|
}
|
|
50
|
-
if (uri?.startsWith("db://")) {
|
|
51
|
-
return new remote_1.RemoteConnection(uri, opts);
|
|
52
|
-
}
|
|
53
51
|
opts = opts ?? {};
|
|
54
52
|
opts.storageOptions = (0, connection_1.cleanseStorageOptions)(opts.storageOptions);
|
|
55
53
|
const nativeConn = await native_js_1.Connection.new(uri, opts);
|
package/dist/native.d.ts
CHANGED
|
@@ -3,6 +3,81 @@
|
|
|
3
3
|
|
|
4
4
|
/* auto-generated by NAPI-RS */
|
|
5
5
|
|
|
6
|
+
/** Timeout configuration for remote HTTP client. */
|
|
7
|
+
export interface TimeoutConfig {
|
|
8
|
+
/**
|
|
9
|
+
* The timeout for establishing a connection in seconds. Default is 120
|
|
10
|
+
* seconds (2 minutes). This can also be set via the environment variable
|
|
11
|
+
* `LANCE_CLIENT_CONNECT_TIMEOUT`, as an integer number of seconds.
|
|
12
|
+
*/
|
|
13
|
+
connectTimeout?: number
|
|
14
|
+
/**
|
|
15
|
+
* The timeout for reading data from the server in seconds. Default is 300
|
|
16
|
+
* seconds (5 minutes). This can also be set via the environment variable
|
|
17
|
+
* `LANCE_CLIENT_READ_TIMEOUT`, as an integer number of seconds.
|
|
18
|
+
*/
|
|
19
|
+
readTimeout?: number
|
|
20
|
+
/**
|
|
21
|
+
* The timeout for keeping idle connections in the connection pool in seconds.
|
|
22
|
+
* Default is 300 seconds (5 minutes). This can also be set via the
|
|
23
|
+
* environment variable `LANCE_CLIENT_CONNECTION_TIMEOUT`, as an integer
|
|
24
|
+
* number of seconds.
|
|
25
|
+
*/
|
|
26
|
+
poolIdleTimeout?: number
|
|
27
|
+
}
|
|
28
|
+
/** Retry configuration for the remote HTTP client. */
|
|
29
|
+
export interface RetryConfig {
|
|
30
|
+
/**
|
|
31
|
+
* The maximum number of retries for a request. Default is 3. You can also
|
|
32
|
+
* set this via the environment variable `LANCE_CLIENT_MAX_RETRIES`.
|
|
33
|
+
*/
|
|
34
|
+
retries?: number
|
|
35
|
+
/**
|
|
36
|
+
* The maximum number of retries for connection errors. Default is 3. You
|
|
37
|
+
* can also set this via the environment variable `LANCE_CLIENT_CONNECT_RETRIES`.
|
|
38
|
+
*/
|
|
39
|
+
connectRetries?: number
|
|
40
|
+
/**
|
|
41
|
+
* The maximum number of retries for read errors. Default is 3. You can also
|
|
42
|
+
* set this via the environment variable `LANCE_CLIENT_READ_RETRIES`.
|
|
43
|
+
*/
|
|
44
|
+
readRetries?: number
|
|
45
|
+
/**
|
|
46
|
+
* The backoff factor to apply between retries. Default is 0.25. Between each retry
|
|
47
|
+
* the client will wait for the amount of seconds:
|
|
48
|
+
* `{backoff factor} * (2 ** ({number of previous retries}))`. So for the default
|
|
49
|
+
* of 0.25, the first retry will wait 0.25 seconds, the second retry will wait 0.5
|
|
50
|
+
* seconds, the third retry will wait 1 second, etc.
|
|
51
|
+
*
|
|
52
|
+
* You can also set this via the environment variable
|
|
53
|
+
* `LANCE_CLIENT_RETRY_BACKOFF_FACTOR`.
|
|
54
|
+
*/
|
|
55
|
+
backoffFactor?: number
|
|
56
|
+
/**
|
|
57
|
+
* The jitter to apply to the backoff factor, in seconds. Default is 0.25.
|
|
58
|
+
*
|
|
59
|
+
* A random value between 0 and `backoff_jitter` will be added to the backoff
|
|
60
|
+
* factor in seconds. So for the default of 0.25 seconds, between 0 and 250
|
|
61
|
+
* milliseconds will be added to the sleep between each retry.
|
|
62
|
+
*
|
|
63
|
+
* You can also set this via the environment variable
|
|
64
|
+
* `LANCE_CLIENT_RETRY_BACKOFF_JITTER`.
|
|
65
|
+
*/
|
|
66
|
+
backoffJitter?: number
|
|
67
|
+
/**
|
|
68
|
+
* The HTTP status codes for which to retry the request. Default is
|
|
69
|
+
* [429, 500, 502, 503].
|
|
70
|
+
*
|
|
71
|
+
* You can also set this via the environment variable
|
|
72
|
+
* `LANCE_CLIENT_RETRY_STATUSES`. Use a comma-separated list of integers.
|
|
73
|
+
*/
|
|
74
|
+
statuses?: Array<number>
|
|
75
|
+
}
|
|
76
|
+
export interface ClientConfig {
|
|
77
|
+
userAgent?: string
|
|
78
|
+
retryConfig?: RetryConfig
|
|
79
|
+
timeoutConfig?: TimeoutConfig
|
|
80
|
+
}
|
|
6
81
|
/** A description of an index currently configured on a column */
|
|
7
82
|
export interface IndexConfig {
|
|
8
83
|
/** The name of the index */
|
|
@@ -80,13 +155,15 @@ export interface IndexStatistics {
|
|
|
80
155
|
/** The number of rows not indexed */
|
|
81
156
|
numUnindexedRows: number
|
|
82
157
|
/** The type of the index */
|
|
83
|
-
indexType
|
|
84
|
-
/**
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
158
|
+
indexType: string
|
|
159
|
+
/**
|
|
160
|
+
* The type of the distance function used by the index. This is only
|
|
161
|
+
* present for vector indices. Scalar and full text search indices do
|
|
162
|
+
* not have a distance function.
|
|
163
|
+
*/
|
|
164
|
+
distanceType?: string
|
|
165
|
+
/** The number of parts this index is split into. */
|
|
166
|
+
numIndices?: number
|
|
90
167
|
}
|
|
91
168
|
export interface ConnectionOptions {
|
|
92
169
|
/**
|
|
@@ -107,9 +184,27 @@ export interface ConnectionOptions {
|
|
|
107
184
|
* The available options are described at https://lancedb.github.io/lancedb/guides/storage/
|
|
108
185
|
*/
|
|
109
186
|
storageOptions?: Record<string, string>
|
|
187
|
+
/** (For LanceDB cloud only): configuration for the remote HTTP client. */
|
|
188
|
+
clientConfig?: ClientConfig
|
|
189
|
+
/**
|
|
190
|
+
* (For LanceDB cloud only): the API key to use with LanceDB Cloud.
|
|
191
|
+
*
|
|
192
|
+
* Can also be set via the environment variable `LANCEDB_API_KEY`.
|
|
193
|
+
*/
|
|
194
|
+
apiKey?: string
|
|
195
|
+
/**
|
|
196
|
+
* (For LanceDB cloud only): the region to use for LanceDB cloud.
|
|
197
|
+
* Defaults to 'us-east-1'.
|
|
198
|
+
*/
|
|
199
|
+
region?: string
|
|
200
|
+
/**
|
|
201
|
+
* (For LanceDB cloud only): the host to use for LanceDB cloud. Used
|
|
202
|
+
* for testing purposes.
|
|
203
|
+
*/
|
|
204
|
+
hostOverride?: string
|
|
110
205
|
}
|
|
111
206
|
/** Write mode for writing a table. */
|
|
112
|
-
export
|
|
207
|
+
export enum WriteMode {
|
|
113
208
|
Create = 'Create',
|
|
114
209
|
Append = 'Append',
|
|
115
210
|
Overwrite = 'Overwrite'
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"vector database",
|
|
11
11
|
"ann"
|
|
12
12
|
],
|
|
13
|
-
"version": "0.11.0
|
|
13
|
+
"version": "0.11.0",
|
|
14
14
|
"main": "dist/index.js",
|
|
15
15
|
"exports": {
|
|
16
16
|
".": "./dist/index.js",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"@napi-rs/cli": "^2.18.3",
|
|
41
41
|
"@types/axios": "^0.14.0",
|
|
42
42
|
"@types/jest": "^29.1.2",
|
|
43
|
+
"@types/node": "^22.7.4",
|
|
43
44
|
"@types/tmp": "^0.2.6",
|
|
44
45
|
"apache-arrow-13": "npm:apache-arrow@13.0.0",
|
|
45
46
|
"apache-arrow-14": "npm:apache-arrow@14.0.0",
|
|
@@ -73,8 +74,8 @@
|
|
|
73
74
|
],
|
|
74
75
|
"scripts": {
|
|
75
76
|
"artifacts": "napi artifacts",
|
|
76
|
-
"build:debug": "napi build --platform --dts ../lancedb/native.d.ts --js ../lancedb/native.js lancedb",
|
|
77
|
-
"build:release": "napi build --platform --release --dts ../lancedb/native.d.ts --js ../lancedb/native.js dist/",
|
|
77
|
+
"build:debug": "napi build --platform --no-const-enum --dts ../lancedb/native.d.ts --js ../lancedb/native.js lancedb",
|
|
78
|
+
"build:release": "napi build --platform --no-const-enum --release --dts ../lancedb/native.d.ts --js ../lancedb/native.js dist/",
|
|
78
79
|
"build": "npm run build:debug && tsc -b && shx cp lancedb/native.d.ts dist/native.d.ts && shx cp lancedb/*.node dist/",
|
|
79
80
|
"build-release": "npm run build:release && tsc -b && shx cp lancedb/native.d.ts dist/native.d.ts",
|
|
80
81
|
"lint-ci": "biome ci .",
|
|
@@ -88,15 +89,14 @@
|
|
|
88
89
|
"version": "napi version"
|
|
89
90
|
},
|
|
90
91
|
"dependencies": {
|
|
91
|
-
"axios": "^1.7.2",
|
|
92
92
|
"reflect-metadata": "^0.2.2"
|
|
93
93
|
},
|
|
94
94
|
"optionalDependencies": {
|
|
95
|
-
"@lancedb/lancedb-darwin-arm64": "0.11.0
|
|
96
|
-
"@lancedb/lancedb-linux-arm64-gnu": "0.11.0
|
|
97
|
-
"@lancedb/lancedb-darwin-x64": "0.11.0
|
|
98
|
-
"@lancedb/lancedb-linux-x64-gnu": "0.11.0
|
|
99
|
-
"@lancedb/lancedb-win32-x64-msvc": "0.11.0
|
|
95
|
+
"@lancedb/lancedb-darwin-arm64": "0.11.0",
|
|
96
|
+
"@lancedb/lancedb-linux-arm64-gnu": "0.11.0",
|
|
97
|
+
"@lancedb/lancedb-darwin-x64": "0.11.0",
|
|
98
|
+
"@lancedb/lancedb-linux-x64-gnu": "0.11.0",
|
|
99
|
+
"@lancedb/lancedb-win32-x64-msvc": "0.11.0"
|
|
100
100
|
},
|
|
101
101
|
"peerDependencies": {
|
|
102
102
|
"apache-arrow": ">=13.0.0 <=17.0.0"
|
package/dist/remote/client.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { type AxiosResponse } from "axios";
|
|
2
|
-
import { Table as ArrowTable } from "../arrow";
|
|
3
|
-
import { VectorQuery } from "../query";
|
|
4
|
-
export declare class RestfulLanceDBClient {
|
|
5
|
-
#private;
|
|
6
|
-
constructor(dbName: string, apiKey: string, region: string, hostOverride?: string, timeout?: number);
|
|
7
|
-
get session(): import("axios").AxiosInstance;
|
|
8
|
-
get url(): string;
|
|
9
|
-
get headers(): {
|
|
10
|
-
[key: string]: string;
|
|
11
|
-
};
|
|
12
|
-
isOpen(): boolean;
|
|
13
|
-
private checkNotClosed;
|
|
14
|
-
close(): void;
|
|
15
|
-
get(uri: string, params?: Record<string, any>): Promise<any>;
|
|
16
|
-
post(uri: string, body?: any): Promise<any>;
|
|
17
|
-
post(uri: string, body: any, additional: {
|
|
18
|
-
config?: {
|
|
19
|
-
responseType: "arraybuffer";
|
|
20
|
-
};
|
|
21
|
-
headers?: Record<string, string>;
|
|
22
|
-
params?: Record<string, string>;
|
|
23
|
-
}): Promise<Buffer>;
|
|
24
|
-
listTables(limit?: number, pageToken?: string): Promise<string[]>;
|
|
25
|
-
query(tableName: string, query: VectorQuery): Promise<ArrowTable>;
|
|
26
|
-
static checkStatus(response: AxiosResponse): void;
|
|
27
|
-
}
|
package/dist/remote/client.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
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.RestfulLanceDBClient = void 0;
|
|
17
|
-
const axios_1 = require("axios");
|
|
18
|
-
const arrow_1 = require("../arrow");
|
|
19
|
-
class RestfulLanceDBClient {
|
|
20
|
-
#dbName;
|
|
21
|
-
#region;
|
|
22
|
-
#apiKey;
|
|
23
|
-
#hostOverride;
|
|
24
|
-
#closed = false;
|
|
25
|
-
#timeout = 12 * 1000; // 12 seconds;
|
|
26
|
-
#session;
|
|
27
|
-
constructor(dbName, apiKey, region, hostOverride, timeout) {
|
|
28
|
-
this.#dbName = dbName;
|
|
29
|
-
this.#apiKey = apiKey;
|
|
30
|
-
this.#region = region;
|
|
31
|
-
this.#hostOverride = hostOverride ?? this.#hostOverride;
|
|
32
|
-
this.#timeout = timeout ?? this.#timeout;
|
|
33
|
-
}
|
|
34
|
-
// todo: cache the session.
|
|
35
|
-
get session() {
|
|
36
|
-
if (this.#session !== undefined) {
|
|
37
|
-
return this.#session;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
return axios_1.default.create({
|
|
41
|
-
baseURL: this.url,
|
|
42
|
-
headers: {
|
|
43
|
-
// biome-ignore lint: external API
|
|
44
|
-
Authorization: `Bearer ${this.#apiKey}`,
|
|
45
|
-
},
|
|
46
|
-
transformResponse: decodeErrorData,
|
|
47
|
-
timeout: this.#timeout,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
get url() {
|
|
52
|
-
return (this.#hostOverride ??
|
|
53
|
-
`https://${this.#dbName}.${this.#region}.api.lancedb.com`);
|
|
54
|
-
}
|
|
55
|
-
get headers() {
|
|
56
|
-
const headers = {
|
|
57
|
-
"x-api-key": this.#apiKey,
|
|
58
|
-
"x-request-id": "na",
|
|
59
|
-
};
|
|
60
|
-
if (this.#region == "local") {
|
|
61
|
-
headers["Host"] = `${this.#dbName}.${this.#region}.api.lancedb.com`;
|
|
62
|
-
}
|
|
63
|
-
if (this.#hostOverride) {
|
|
64
|
-
headers["x-lancedb-database"] = this.#dbName;
|
|
65
|
-
}
|
|
66
|
-
return headers;
|
|
67
|
-
}
|
|
68
|
-
isOpen() {
|
|
69
|
-
return !this.#closed;
|
|
70
|
-
}
|
|
71
|
-
checkNotClosed() {
|
|
72
|
-
if (this.#closed) {
|
|
73
|
-
throw new Error("Connection is closed");
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
close() {
|
|
77
|
-
this.#session = undefined;
|
|
78
|
-
this.#closed = true;
|
|
79
|
-
}
|
|
80
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
81
|
-
async get(uri, params) {
|
|
82
|
-
this.checkNotClosed();
|
|
83
|
-
uri = new URL(uri, this.url).toString();
|
|
84
|
-
let response;
|
|
85
|
-
try {
|
|
86
|
-
response = await this.session.get(uri, {
|
|
87
|
-
headers: this.headers,
|
|
88
|
-
params,
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
catch (e) {
|
|
92
|
-
if (e instanceof axios_1.AxiosError && e.response) {
|
|
93
|
-
response = e.response;
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
throw e;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
RestfulLanceDBClient.checkStatus(response);
|
|
100
|
-
return response.data;
|
|
101
|
-
}
|
|
102
|
-
async post(uri,
|
|
103
|
-
// biome-ignore lint/suspicious/noExplicitAny: api request
|
|
104
|
-
body, additional) {
|
|
105
|
-
this.checkNotClosed();
|
|
106
|
-
uri = new URL(uri, this.url).toString();
|
|
107
|
-
additional = Object.assign({ config: { responseType: "json" } }, additional);
|
|
108
|
-
const headers = { ...this.headers, ...additional.headers };
|
|
109
|
-
if (!headers["Content-Type"]) {
|
|
110
|
-
headers["Content-Type"] = "application/json";
|
|
111
|
-
}
|
|
112
|
-
let response;
|
|
113
|
-
try {
|
|
114
|
-
response = await this.session.post(uri, body, {
|
|
115
|
-
headers,
|
|
116
|
-
responseType: additional.config.responseType,
|
|
117
|
-
params: new Map(Object.entries(additional.params ?? {})),
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
catch (e) {
|
|
121
|
-
if (e instanceof axios_1.AxiosError && e.response) {
|
|
122
|
-
response = e.response;
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
throw e;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
RestfulLanceDBClient.checkStatus(response);
|
|
129
|
-
if (additional.config.responseType === "arraybuffer") {
|
|
130
|
-
return response.data;
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
return JSON.parse(response.data);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
async listTables(limit = 10, pageToken = "") {
|
|
137
|
-
const json = await this.get("/v1/table", { limit, pageToken });
|
|
138
|
-
return json.tables;
|
|
139
|
-
}
|
|
140
|
-
async query(tableName, query) {
|
|
141
|
-
const tbl = await this.post(`/v1/table/${tableName}/query`, query, {
|
|
142
|
-
config: {
|
|
143
|
-
responseType: "arraybuffer",
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
return (0, arrow_1.tableFromIPC)(tbl);
|
|
147
|
-
}
|
|
148
|
-
static checkStatus(response) {
|
|
149
|
-
if (response.status === 404) {
|
|
150
|
-
throw new Error(`Not found: ${response.data}`);
|
|
151
|
-
}
|
|
152
|
-
else if (response.status >= 400 && response.status < 500) {
|
|
153
|
-
throw new Error(`Bad Request: ${response.status}, error: ${response.data}`);
|
|
154
|
-
}
|
|
155
|
-
else if (response.status >= 500 && response.status < 600) {
|
|
156
|
-
throw new Error(`Internal Server Error: ${response.status}, error: ${response.data}`);
|
|
157
|
-
}
|
|
158
|
-
else if (response.status !== 200) {
|
|
159
|
-
throw new Error(`Unknown Error: ${response.status}, error: ${response.data}`);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
exports.RestfulLanceDBClient = RestfulLanceDBClient;
|
|
164
|
-
function decodeErrorData(data) {
|
|
165
|
-
if (Buffer.isBuffer(data)) {
|
|
166
|
-
const decoded = data.toString("utf-8");
|
|
167
|
-
return decoded;
|
|
168
|
-
}
|
|
169
|
-
return data;
|
|
170
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Data, SchemaLike } from "../arrow";
|
|
2
|
-
import { Connection, CreateTableOptions, OpenTableOptions, TableNamesOptions } from "../connection";
|
|
3
|
-
import { Table } from "../table";
|
|
4
|
-
export interface RemoteConnectionOptions {
|
|
5
|
-
apiKey?: string;
|
|
6
|
-
region?: string;
|
|
7
|
-
hostOverride?: string;
|
|
8
|
-
timeout?: number;
|
|
9
|
-
}
|
|
10
|
-
export declare class RemoteConnection extends Connection {
|
|
11
|
-
#private;
|
|
12
|
-
constructor(url: string, { apiKey, region, hostOverride, timeout }: RemoteConnectionOptions);
|
|
13
|
-
isOpen(): boolean;
|
|
14
|
-
close(): void;
|
|
15
|
-
display(): string;
|
|
16
|
-
tableNames(options?: Partial<TableNamesOptions>): Promise<string[]>;
|
|
17
|
-
openTable(name: string, _options?: Partial<OpenTableOptions> | undefined): Promise<Table>;
|
|
18
|
-
createTable(nameOrOptions: string | ({
|
|
19
|
-
name: string;
|
|
20
|
-
data: Data;
|
|
21
|
-
} & Partial<CreateTableOptions>), data?: Data, options?: Partial<CreateTableOptions> | undefined): Promise<Table>;
|
|
22
|
-
createEmptyTable(name: string, schema: SchemaLike, options?: Partial<CreateTableOptions> | undefined): Promise<Table>;
|
|
23
|
-
dropTable(name: string): Promise<void>;
|
|
24
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RemoteConnection = void 0;
|
|
4
|
-
const arrow_1 = require("../arrow");
|
|
5
|
-
const connection_1 = require("../connection");
|
|
6
|
-
const table_1 = require("../table");
|
|
7
|
-
const util_1 = require("../util");
|
|
8
|
-
const client_1 = require("./client");
|
|
9
|
-
const table_2 = require("./table");
|
|
10
|
-
class RemoteConnection extends connection_1.Connection {
|
|
11
|
-
#dbName;
|
|
12
|
-
#apiKey;
|
|
13
|
-
#region;
|
|
14
|
-
#client;
|
|
15
|
-
#tableCache = new util_1.TTLCache(300_000);
|
|
16
|
-
constructor(url, { apiKey, region, hostOverride, timeout }) {
|
|
17
|
-
super();
|
|
18
|
-
apiKey = apiKey ?? process.env.LANCEDB_API_KEY;
|
|
19
|
-
region = region ?? process.env.LANCEDB_REGION;
|
|
20
|
-
if (!apiKey) {
|
|
21
|
-
throw new Error("apiKey is required when connecting to LanceDB Cloud");
|
|
22
|
-
}
|
|
23
|
-
if (!region) {
|
|
24
|
-
throw new Error("region is required when connecting to LanceDB Cloud");
|
|
25
|
-
}
|
|
26
|
-
const parsed = new URL(url);
|
|
27
|
-
if (parsed.protocol !== "db:") {
|
|
28
|
-
throw new Error(`invalid protocol: ${parsed.protocol}, only accepts db://`);
|
|
29
|
-
}
|
|
30
|
-
this.#dbName = parsed.hostname;
|
|
31
|
-
this.#apiKey = apiKey;
|
|
32
|
-
this.#region = region;
|
|
33
|
-
this.#client = new client_1.RestfulLanceDBClient(this.#dbName, this.#apiKey, this.#region, hostOverride, timeout);
|
|
34
|
-
}
|
|
35
|
-
isOpen() {
|
|
36
|
-
return this.#client.isOpen();
|
|
37
|
-
}
|
|
38
|
-
close() {
|
|
39
|
-
return this.#client.close();
|
|
40
|
-
}
|
|
41
|
-
display() {
|
|
42
|
-
return `RemoteConnection(${this.#dbName})`;
|
|
43
|
-
}
|
|
44
|
-
async tableNames(options) {
|
|
45
|
-
const response = await this.#client.get("/v1/table/", {
|
|
46
|
-
limit: options?.limit ?? 10,
|
|
47
|
-
// biome-ignore lint/style/useNamingConvention: <explanation>
|
|
48
|
-
page_token: options?.startAfter ?? "",
|
|
49
|
-
});
|
|
50
|
-
const body = await response.body();
|
|
51
|
-
for (const table of body.tables) {
|
|
52
|
-
this.#tableCache.set(table, true);
|
|
53
|
-
}
|
|
54
|
-
return body.tables;
|
|
55
|
-
}
|
|
56
|
-
async openTable(name, _options) {
|
|
57
|
-
if (this.#tableCache.get(name) === undefined) {
|
|
58
|
-
await this.#client.post(`/v1/table/${encodeURIComponent(name)}/describe/`);
|
|
59
|
-
this.#tableCache.set(name, true);
|
|
60
|
-
}
|
|
61
|
-
return new table_2.RemoteTable(this.#client, name, this.#dbName);
|
|
62
|
-
}
|
|
63
|
-
async createTable(nameOrOptions, data, options) {
|
|
64
|
-
if (typeof nameOrOptions !== "string" && "name" in nameOrOptions) {
|
|
65
|
-
const { name, data, ...options } = nameOrOptions;
|
|
66
|
-
return this.createTable(name, data, options);
|
|
67
|
-
}
|
|
68
|
-
if (data === undefined) {
|
|
69
|
-
throw new Error("data is required");
|
|
70
|
-
}
|
|
71
|
-
if (options?.mode) {
|
|
72
|
-
console.warn("option 'mode' is not supported in LanceDB Cloud", "LanceDB Cloud only supports the default 'create' mode.", "If the table already exists, an error will be thrown.");
|
|
73
|
-
}
|
|
74
|
-
if (options?.embeddingFunction) {
|
|
75
|
-
console.warn("embedding_functions is not yet supported on LanceDB Cloud.", "Please vote https://github.com/lancedb/lancedb/issues/626 ", "for this feature.");
|
|
76
|
-
}
|
|
77
|
-
const { buf } = await table_1.Table.parseTableData(data, options, true /** streaming */);
|
|
78
|
-
await this.#client.post(`/v1/table/${encodeURIComponent(nameOrOptions)}/create/`, buf, {
|
|
79
|
-
config: {
|
|
80
|
-
responseType: "arraybuffer",
|
|
81
|
-
},
|
|
82
|
-
headers: { "Content-Type": "application/vnd.apache.arrow.stream" },
|
|
83
|
-
});
|
|
84
|
-
this.#tableCache.set(nameOrOptions, true);
|
|
85
|
-
return new table_2.RemoteTable(this.#client, nameOrOptions, this.#dbName);
|
|
86
|
-
}
|
|
87
|
-
async createEmptyTable(name, schema, options) {
|
|
88
|
-
if (options?.mode) {
|
|
89
|
-
console.warn(`mode is not supported on LanceDB Cloud`);
|
|
90
|
-
}
|
|
91
|
-
if (options?.embeddingFunction) {
|
|
92
|
-
console.warn("embeddingFunction is not yet supported on LanceDB Cloud.", "Please vote https://github.com/lancedb/lancedb/issues/626 ", "for this feature.");
|
|
93
|
-
}
|
|
94
|
-
const emptyTable = (0, arrow_1.makeEmptyTable)(schema);
|
|
95
|
-
const buf = await (0, arrow_1.fromTableToStreamBuffer)(emptyTable);
|
|
96
|
-
await this.#client.post(`/v1/table/${encodeURIComponent(name)}/create/`, buf, {
|
|
97
|
-
config: {
|
|
98
|
-
responseType: "arraybuffer",
|
|
99
|
-
},
|
|
100
|
-
headers: { "Content-Type": "application/vnd.apache.arrow.stream" },
|
|
101
|
-
});
|
|
102
|
-
this.#tableCache.set(name, true);
|
|
103
|
-
return new table_2.RemoteTable(this.#client, name, this.#dbName);
|
|
104
|
-
}
|
|
105
|
-
async dropTable(name) {
|
|
106
|
-
await this.#client.post(`/v1/table/${encodeURIComponent(name)}/drop/`);
|
|
107
|
-
this.#tableCache.delete(name);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
exports.RemoteConnection = RemoteConnection;
|
package/dist/remote/index.d.ts
DELETED
package/dist/remote/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RemoteTable = exports.RemoteConnection = exports.RestfulLanceDBClient = void 0;
|
|
4
|
-
var client_1 = require("./client");
|
|
5
|
-
Object.defineProperty(exports, "RestfulLanceDBClient", { enumerable: true, get: function () { return client_1.RestfulLanceDBClient; } });
|
|
6
|
-
var connection_1 = require("./connection");
|
|
7
|
-
Object.defineProperty(exports, "RemoteConnection", { enumerable: true, get: function () { return connection_1.RemoteConnection; } });
|
|
8
|
-
var table_1 = require("./table");
|
|
9
|
-
Object.defineProperty(exports, "RemoteTable", { enumerable: true, get: function () { return table_1.RemoteTable; } });
|
package/dist/remote/table.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Table as ArrowTable } from "apache-arrow";
|
|
2
|
-
import { Data, IntoVector } from "../arrow";
|
|
3
|
-
import { IndexStatistics } from "..";
|
|
4
|
-
import { IndexOptions } from "../indices";
|
|
5
|
-
import { MergeInsertBuilder } from "../merge";
|
|
6
|
-
import { VectorQuery } from "../query";
|
|
7
|
-
import { AddDataOptions, Table, UpdateOptions } from "../table";
|
|
8
|
-
import { IntoSql } from "../util";
|
|
9
|
-
import { RestfulLanceDBClient } from "./client";
|
|
10
|
-
export declare class RemoteTable extends Table {
|
|
11
|
-
#private;
|
|
12
|
-
get name(): string;
|
|
13
|
-
constructor(client: RestfulLanceDBClient, tableName: string, dbName: string);
|
|
14
|
-
isOpen(): boolean;
|
|
15
|
-
close(): void;
|
|
16
|
-
display(): string;
|
|
17
|
-
schema(): Promise<import("apache-arrow").Schema>;
|
|
18
|
-
add(data: Data, options?: Partial<AddDataOptions>): Promise<void>;
|
|
19
|
-
update(optsOrUpdates: (Map<string, string> | Record<string, string>) | ({
|
|
20
|
-
values: Map<string, IntoSql> | Record<string, IntoSql>;
|
|
21
|
-
} & Partial<UpdateOptions>) | ({
|
|
22
|
-
valuesSql: Map<string, string> | Record<string, string>;
|
|
23
|
-
} & Partial<UpdateOptions>), options?: Partial<UpdateOptions>): Promise<void>;
|
|
24
|
-
countRows(filter?: unknown): Promise<number>;
|
|
25
|
-
delete(predicate: unknown): Promise<void>;
|
|
26
|
-
createIndex(column: string, options?: Partial<IndexOptions>): Promise<void>;
|
|
27
|
-
query(): import("..").Query;
|
|
28
|
-
search(_query: string | IntoVector): VectorQuery;
|
|
29
|
-
vectorSearch(_vector: unknown): import("..").VectorQuery;
|
|
30
|
-
addColumns(_newColumnTransforms: unknown): Promise<void>;
|
|
31
|
-
alterColumns(_columnAlterations: unknown): Promise<void>;
|
|
32
|
-
dropColumns(_columnNames: unknown): Promise<void>;
|
|
33
|
-
version(): Promise<number>;
|
|
34
|
-
checkout(_version: unknown): Promise<void>;
|
|
35
|
-
checkoutLatest(): Promise<void>;
|
|
36
|
-
restore(): Promise<void>;
|
|
37
|
-
optimize(_options?: unknown): Promise<import("../native").OptimizeStats>;
|
|
38
|
-
listIndices(): Promise<import("../native").IndexConfig[]>;
|
|
39
|
-
toArrow(): Promise<ArrowTable>;
|
|
40
|
-
mergeInsert(_on: string | string[]): MergeInsertBuilder;
|
|
41
|
-
indexStats(_name: string): Promise<IndexStatistics | undefined>;
|
|
42
|
-
}
|
package/dist/remote/table.js
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
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/native.d.ts
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
|
|
4
|
-
/* auto-generated by NAPI-RS */
|
|
5
|
-
|
|
6
|
-
/** A description of an index currently configured on a column */
|
|
7
|
-
export interface IndexConfig {
|
|
8
|
-
/** The name of the index */
|
|
9
|
-
name: string
|
|
10
|
-
/** The type of the index */
|
|
11
|
-
indexType: string
|
|
12
|
-
/**
|
|
13
|
-
* The columns in the index
|
|
14
|
-
*
|
|
15
|
-
* Currently this is always an array of size 1. In the future there may
|
|
16
|
-
* be more columns to represent composite indices.
|
|
17
|
-
*/
|
|
18
|
-
columns: Array<string>
|
|
19
|
-
}
|
|
20
|
-
/** Statistics about a compaction operation. */
|
|
21
|
-
export interface CompactionStats {
|
|
22
|
-
/** The number of fragments removed */
|
|
23
|
-
fragmentsRemoved: number
|
|
24
|
-
/** The number of new, compacted fragments added */
|
|
25
|
-
fragmentsAdded: number
|
|
26
|
-
/** The number of data files removed */
|
|
27
|
-
filesRemoved: number
|
|
28
|
-
/** The number of new, compacted data files added */
|
|
29
|
-
filesAdded: number
|
|
30
|
-
}
|
|
31
|
-
/** Statistics about a cleanup operation */
|
|
32
|
-
export interface RemovalStats {
|
|
33
|
-
/** The number of bytes removed */
|
|
34
|
-
bytesRemoved: number
|
|
35
|
-
/** The number of old versions removed */
|
|
36
|
-
oldVersionsRemoved: number
|
|
37
|
-
}
|
|
38
|
-
/** Statistics about an optimize operation */
|
|
39
|
-
export interface OptimizeStats {
|
|
40
|
-
/** Statistics about the compaction operation */
|
|
41
|
-
compaction: CompactionStats
|
|
42
|
-
/** Statistics about the removal operation */
|
|
43
|
-
prune: RemovalStats
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* A definition of a column alteration. The alteration changes the column at
|
|
47
|
-
* `path` to have the new name `name`, to be nullable if `nullable` is true,
|
|
48
|
-
* and to have the data type `data_type`. At least one of `rename` or `nullable`
|
|
49
|
-
* must be provided.
|
|
50
|
-
*/
|
|
51
|
-
export interface ColumnAlteration {
|
|
52
|
-
/**
|
|
53
|
-
* The path to the column to alter. This is a dot-separated path to the column.
|
|
54
|
-
* If it is a top-level column then it is just the name of the column. If it is
|
|
55
|
-
* a nested column then it is the path to the column, e.g. "a.b.c" for a column
|
|
56
|
-
* `c` nested inside a column `b` nested inside a column `a`.
|
|
57
|
-
*/
|
|
58
|
-
path: string
|
|
59
|
-
/**
|
|
60
|
-
* The new name of the column. If not provided then the name will not be changed.
|
|
61
|
-
* This must be distinct from the names of all other columns in the table.
|
|
62
|
-
*/
|
|
63
|
-
rename?: string
|
|
64
|
-
/** Set the new nullability. Note that a nullable column cannot be made non-nullable. */
|
|
65
|
-
nullable?: boolean
|
|
66
|
-
}
|
|
67
|
-
/** A definition of a new column to add to a table. */
|
|
68
|
-
export interface AddColumnsSql {
|
|
69
|
-
/** The name of the new column. */
|
|
70
|
-
name: string
|
|
71
|
-
/**
|
|
72
|
-
* The values to populate the new column with, as a SQL expression.
|
|
73
|
-
* The expression can reference other columns in the table.
|
|
74
|
-
*/
|
|
75
|
-
valueSql: string
|
|
76
|
-
}
|
|
77
|
-
export interface IndexStatistics {
|
|
78
|
-
/** The number of rows indexed by the index */
|
|
79
|
-
numIndexedRows: number
|
|
80
|
-
/** The number of rows not indexed */
|
|
81
|
-
numUnindexedRows: number
|
|
82
|
-
/** The type of the index */
|
|
83
|
-
indexType?: string
|
|
84
|
-
/** The metadata for each index */
|
|
85
|
-
indices: Array<IndexMetadata>
|
|
86
|
-
}
|
|
87
|
-
export interface IndexMetadata {
|
|
88
|
-
metricType?: string
|
|
89
|
-
indexType?: string
|
|
90
|
-
}
|
|
91
|
-
export interface ConnectionOptions {
|
|
92
|
-
/**
|
|
93
|
-
* (For LanceDB OSS only): The interval, in seconds, at which to check for
|
|
94
|
-
* updates to the table from other processes. If None, then consistency is not
|
|
95
|
-
* checked. For performance reasons, this is the default. For strong
|
|
96
|
-
* consistency, set this to zero seconds. Then every read will check for
|
|
97
|
-
* updates from other processes. As a compromise, you can set this to a
|
|
98
|
-
* non-zero value for eventual consistency. If more than that interval
|
|
99
|
-
* has passed since the last check, then the table will be checked for updates.
|
|
100
|
-
* Note: this consistency only applies to read operations. Write operations are
|
|
101
|
-
* always consistent.
|
|
102
|
-
*/
|
|
103
|
-
readConsistencyInterval?: number
|
|
104
|
-
/**
|
|
105
|
-
* (For LanceDB OSS only): configuration for object storage.
|
|
106
|
-
*
|
|
107
|
-
* The available options are described at https://lancedb.github.io/lancedb/guides/storage/
|
|
108
|
-
*/
|
|
109
|
-
storageOptions?: Record<string, string>
|
|
110
|
-
}
|
|
111
|
-
/** Write mode for writing a table. */
|
|
112
|
-
export const enum WriteMode {
|
|
113
|
-
Create = 'Create',
|
|
114
|
-
Append = 'Append',
|
|
115
|
-
Overwrite = 'Overwrite'
|
|
116
|
-
}
|
|
117
|
-
/** Write options when creating a Table. */
|
|
118
|
-
export interface WriteOptions {
|
|
119
|
-
/** Write mode for writing to a table. */
|
|
120
|
-
mode?: WriteMode
|
|
121
|
-
}
|
|
122
|
-
export interface OpenTableOptions {
|
|
123
|
-
storageOptions?: Record<string, string>
|
|
124
|
-
}
|
|
125
|
-
export class Connection {
|
|
126
|
-
/** Create a new Connection instance from the given URI. */
|
|
127
|
-
static new(uri: string, options: ConnectionOptions): Promise<Connection>
|
|
128
|
-
display(): string
|
|
129
|
-
isOpen(): boolean
|
|
130
|
-
close(): void
|
|
131
|
-
/** List all tables in the dataset. */
|
|
132
|
-
tableNames(startAfter?: string | undefined | null, limit?: number | undefined | null): Promise<Array<string>>
|
|
133
|
-
/**
|
|
134
|
-
* Create table from a Apache Arrow IPC (file) buffer.
|
|
135
|
-
*
|
|
136
|
-
* Parameters:
|
|
137
|
-
* - name: The name of the table.
|
|
138
|
-
* - buf: The buffer containing the IPC file.
|
|
139
|
-
*
|
|
140
|
-
*/
|
|
141
|
-
createTable(name: string, buf: Buffer, mode: string, storageOptions?: Record<string, string> | undefined | null, useLegacyFormat?: boolean | undefined | null): Promise<Table>
|
|
142
|
-
createEmptyTable(name: string, schemaBuf: Buffer, mode: string, storageOptions?: Record<string, string> | undefined | null, useLegacyFormat?: boolean | undefined | null): Promise<Table>
|
|
143
|
-
openTable(name: string, storageOptions?: Record<string, string> | undefined | null, indexCacheSize?: number | undefined | null): Promise<Table>
|
|
144
|
-
/** Drop table with the name. Or raise an error if the table does not exist. */
|
|
145
|
-
dropTable(name: string): Promise<void>
|
|
146
|
-
}
|
|
147
|
-
export class Index {
|
|
148
|
-
static ivfPq(distanceType?: string | undefined | null, numPartitions?: number | undefined | null, numSubVectors?: number | undefined | null, maxIterations?: number | undefined | null, sampleRate?: number | undefined | null): Index
|
|
149
|
-
static btree(): Index
|
|
150
|
-
}
|
|
151
|
-
/** Typescript-style Async Iterator over RecordBatches */
|
|
152
|
-
export class RecordBatchIterator {
|
|
153
|
-
next(): Promise<Buffer | null>
|
|
154
|
-
}
|
|
155
|
-
/** A builder used to create and run a merge insert operation */
|
|
156
|
-
export class NativeMergeInsertBuilder {
|
|
157
|
-
whenMatchedUpdateAll(condition?: string | undefined | null): NativeMergeInsertBuilder
|
|
158
|
-
whenNotMatchedInsertAll(): NativeMergeInsertBuilder
|
|
159
|
-
whenNotMatchedBySourceDelete(filter?: string | undefined | null): NativeMergeInsertBuilder
|
|
160
|
-
execute(buf: Buffer): Promise<void>
|
|
161
|
-
}
|
|
162
|
-
export class Query {
|
|
163
|
-
onlyIf(predicate: string): void
|
|
164
|
-
select(columns: Array<[string, string]>): void
|
|
165
|
-
limit(limit: number): void
|
|
166
|
-
nearestTo(vector: Float32Array): VectorQuery
|
|
167
|
-
execute(maxBatchLength?: number | undefined | null): Promise<RecordBatchIterator>
|
|
168
|
-
explainPlan(verbose: boolean): Promise<string>
|
|
169
|
-
}
|
|
170
|
-
export class VectorQuery {
|
|
171
|
-
column(column: string): void
|
|
172
|
-
distanceType(distanceType: string): void
|
|
173
|
-
postfilter(): void
|
|
174
|
-
refineFactor(refineFactor: number): void
|
|
175
|
-
nprobes(nprobe: number): void
|
|
176
|
-
bypassVectorIndex(): void
|
|
177
|
-
onlyIf(predicate: string): void
|
|
178
|
-
select(columns: Array<[string, string]>): void
|
|
179
|
-
limit(limit: number): void
|
|
180
|
-
execute(maxBatchLength?: number | undefined | null): Promise<RecordBatchIterator>
|
|
181
|
-
explainPlan(verbose: boolean): Promise<string>
|
|
182
|
-
}
|
|
183
|
-
export class Table {
|
|
184
|
-
name: string
|
|
185
|
-
display(): string
|
|
186
|
-
isOpen(): boolean
|
|
187
|
-
close(): void
|
|
188
|
-
/** Return Schema as empty Arrow IPC file. */
|
|
189
|
-
schema(): Promise<Buffer>
|
|
190
|
-
add(buf: Buffer, mode: string): Promise<void>
|
|
191
|
-
countRows(filter?: string | undefined | null): Promise<number>
|
|
192
|
-
delete(predicate: string): Promise<void>
|
|
193
|
-
createIndex(index: Index | undefined | null, column: string, replace?: boolean | undefined | null): Promise<void>
|
|
194
|
-
update(onlyIf: string | undefined | null, columns: Array<[string, string]>): Promise<void>
|
|
195
|
-
query(): Query
|
|
196
|
-
vectorSearch(vector: Float32Array): VectorQuery
|
|
197
|
-
addColumns(transforms: Array<AddColumnsSql>): Promise<void>
|
|
198
|
-
alterColumns(alterations: Array<ColumnAlteration>): Promise<void>
|
|
199
|
-
dropColumns(columns: Array<string>): Promise<void>
|
|
200
|
-
version(): Promise<number>
|
|
201
|
-
checkout(version: number): Promise<void>
|
|
202
|
-
checkoutLatest(): Promise<void>
|
|
203
|
-
restore(): Promise<void>
|
|
204
|
-
optimize(olderThanMs?: number | undefined | null): Promise<OptimizeStats>
|
|
205
|
-
listIndices(): Promise<Array<IndexConfig>>
|
|
206
|
-
indexStats(indexName: string): Promise<IndexStatistics | null>
|
|
207
|
-
mergeInsert(on: Array<string>): NativeMergeInsertBuilder
|
|
208
|
-
}
|