@lancedb/lancedb 0.27.0-beta.1 → 0.27.0-beta.2

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/native.d.ts CHANGED
@@ -1,181 +1,273 @@
1
- /* tslint:disable */
1
+ /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
+ export declare class Connection {
4
+ /** Create a new Connection instance from the given URI. */
5
+ static new(uri: string, options: ConnectionOptions, headerProvider?: JsHeaderProvider | undefined | null): Promise<Connection>
6
+ display(): string
7
+ isOpen(): boolean
8
+ close(): void
9
+ /** List all tables in the dataset. */
10
+ tableNames(namespace: Array<string>, startAfter?: string | undefined | null, limit?: number | undefined | null): Promise<Array<string>>
11
+ /**
12
+ * Create table from a Apache Arrow IPC (file) buffer.
13
+ *
14
+ * Parameters:
15
+ * - name: The name of the table.
16
+ * - buf: The buffer containing the IPC file.
17
+ */
18
+ createTable(name: string, buf: Buffer, mode: string, namespace: Array<string>, storageOptions?: Record<string, string> | undefined | null): Promise<Table>
19
+ createEmptyTable(name: string, schemaBuf: Buffer, mode: string, namespace: Array<string>, storageOptions?: Record<string, string> | undefined | null): Promise<Table>
20
+ openTable(name: string, namespace: Array<string>, storageOptions?: Record<string, string> | undefined | null, indexCacheSize?: number | undefined | null): Promise<Table>
21
+ cloneTable(targetTableName: string, sourceUri: string, targetNamespace: Array<string>, sourceVersion: number | undefined | null, sourceTag: string | undefined | null, isShallow: boolean): Promise<Table>
22
+ /** Drop table with the name. Or raise an error if the table does not exist. */
23
+ dropTable(name: string, namespace: Array<string>): Promise<void>
24
+ dropAllTables(namespace: Array<string>): Promise<void>
25
+ }
3
26
 
4
- /* auto-generated by NAPI-RS */
27
+ export declare class Index {
28
+ static ivfPq(distanceType?: string | undefined | null, numPartitions?: number | undefined | null, numSubVectors?: number | undefined | null, numBits?: number | undefined | null, maxIterations?: number | undefined | null, sampleRate?: number | undefined | null): Index
29
+ static ivfRq(distanceType?: string | undefined | null, numPartitions?: number | undefined | null, numBits?: number | undefined | null, maxIterations?: number | undefined | null, sampleRate?: number | undefined | null): Index
30
+ static ivfFlat(distanceType?: string | undefined | null, numPartitions?: number | undefined | null, maxIterations?: number | undefined | null, sampleRate?: number | undefined | null): Index
31
+ static btree(): Index
32
+ static bitmap(): Index
33
+ static labelList(): Index
34
+ static fts(withPosition?: boolean | undefined | null, baseTokenizer?: string | undefined | null, language?: string | undefined | null, maxTokenLength?: number | undefined | null, lowerCase?: boolean | undefined | null, stem?: boolean | undefined | null, removeStopWords?: boolean | undefined | null, asciiFolding?: boolean | undefined | null, ngramMinLength?: number | undefined | null, ngramMaxLength?: number | undefined | null, prefixOnly?: boolean | undefined | null): Index
35
+ static hnswPq(distanceType?: string | undefined | null, numPartitions?: number | undefined | null, numSubVectors?: number | undefined | null, maxIterations?: number | undefined | null, sampleRate?: number | undefined | null, m?: number | undefined | null, efConstruction?: number | undefined | null): Index
36
+ static hnswSq(distanceType?: string | undefined | null, numPartitions?: number | undefined | null, maxIterations?: number | undefined | null, sampleRate?: number | undefined | null, m?: number | undefined | null, efConstruction?: number | undefined | null): Index
37
+ }
5
38
 
6
- export interface SplitRandomOptions {
7
- ratios?: Array<number>
8
- counts?: Array<number>
9
- fixed?: number
10
- seed?: number
11
- splitNames?: Array<string>
39
+ export declare class JsFullTextQuery {
40
+ static matchQuery(query: string, column: string, boost: number, fuzziness: number | undefined | null, maxExpansions: number, operator: string, prefixLength: number): JsFullTextQuery
41
+ static phraseQuery(query: string, column: string, slop: number): JsFullTextQuery
42
+ static boostQuery(positive: JsFullTextQuery, negative: JsFullTextQuery, negativeBoost?: number | undefined | null): JsFullTextQuery
43
+ static multiMatchQuery(query: string, columns: Array<string>, boosts: Array<number> | undefined | null, operator: string): JsFullTextQuery
44
+ static booleanQuery(queries: Array<[string, JsFullTextQuery]>): JsFullTextQuery
45
+ get queryType(): string
12
46
  }
13
- export interface SplitHashOptions {
14
- columns: Array<string>
15
- splitWeights: Array<number>
16
- discardWeight?: number
17
- splitNames?: Array<string>
47
+
48
+ /**
49
+ * JavaScript HeaderProvider implementation that wraps a JavaScript callback.
50
+ * This is the only native header provider - all header provider implementations
51
+ * should provide a JavaScript function that returns headers.
52
+ */
53
+ export declare class JsHeaderProvider {
54
+ /** Create a new JsHeaderProvider from a JavaScript callback */
55
+ constructor(getHeadersCallback: () => Promise<Record<string, string>>)
18
56
  }
19
- export interface SplitSequentialOptions {
20
- ratios?: Array<number>
21
- counts?: Array<number>
22
- fixed?: number
23
- splitNames?: Array<string>
57
+
58
+ /** A builder used to create and run a merge insert operation */
59
+ export declare class NativeMergeInsertBuilder {
60
+ whenMatchedUpdateAll(condition?: string | undefined | null): NativeMergeInsertBuilder
61
+ whenNotMatchedInsertAll(): NativeMergeInsertBuilder
62
+ whenNotMatchedBySourceDelete(filter?: string | undefined | null): NativeMergeInsertBuilder
63
+ setTimeout(timeout: number): void
64
+ useIndex(useIndex: boolean): NativeMergeInsertBuilder
65
+ execute(buf: Buffer): Promise<MergeResult>
24
66
  }
25
- export interface SplitCalculatedOptions {
26
- calculation: string
27
- splitNames?: Array<string>
67
+
68
+ export declare class PermutationBuilder {
69
+ persist(connection: Connection, tableName: string): PermutationBuilder
70
+ /** Configure random splits */
71
+ splitRandom(options: SplitRandomOptions): PermutationBuilder
72
+ /** Configure hash-based splits */
73
+ splitHash(options: SplitHashOptions): PermutationBuilder
74
+ /** Configure sequential splits */
75
+ splitSequential(options: SplitSequentialOptions): PermutationBuilder
76
+ /** Configure calculated splits */
77
+ splitCalculated(options: SplitCalculatedOptions): PermutationBuilder
78
+ /** Configure shuffling */
79
+ shuffle(options: ShuffleOptions): PermutationBuilder
80
+ /** Configure filtering */
81
+ filter(filter: string): PermutationBuilder
82
+ /** Execute the permutation builder and create the table */
83
+ execute(): Promise<Table>
28
84
  }
29
- export interface ShuffleOptions {
30
- seed?: number
31
- clumpSize?: number
85
+
86
+ export declare class Query {
87
+ onlyIf(predicate: string): void
88
+ fullTextSearch(query: object): void
89
+ select(columns: Array<[string, string]>): void
90
+ selectColumns(columns: Array<string>): void
91
+ limit(limit: number): void
92
+ offset(offset: number): void
93
+ nearestTo(vector: Float32Array): VectorQuery
94
+ fastSearch(): void
95
+ withRowId(): void
96
+ outputSchema(): Promise<Buffer>
97
+ execute(maxBatchLength?: number | undefined | null, timeoutMs?: number | undefined | null): Promise<RecordBatchIterator>
98
+ explainPlan(verbose: boolean): Promise<string>
99
+ analyzePlan(): Promise<string>
32
100
  }
33
- /** Create a permutation builder for the given table */
34
- export declare function permutationBuilder(table: Table): PermutationBuilder
35
- /** Timeout configuration for remote HTTP client. */
36
- export interface TimeoutConfig {
37
- /**
38
- * The overall timeout for the entire request in seconds. This includes
39
- * connection, send, and read time. If the entire request doesn't complete
40
- * within this time, it will fail. Default is None (no overall timeout).
41
- * This can also be set via the environment variable `LANCE_CLIENT_TIMEOUT`,
42
- * as an integer number of seconds.
43
- */
44
- timeout?: number
45
- /**
46
- * The timeout for establishing a connection in seconds. Default is 120
47
- * seconds (2 minutes). This can also be set via the environment variable
48
- * `LANCE_CLIENT_CONNECT_TIMEOUT`, as an integer number of seconds.
49
- */
50
- connectTimeout?: number
51
- /**
52
- * The timeout for reading data from the server in seconds. Default is 300
53
- * seconds (5 minutes). This can also be set via the environment variable
54
- * `LANCE_CLIENT_READ_TIMEOUT`, as an integer number of seconds.
55
- */
56
- readTimeout?: number
57
- /**
58
- * The timeout for keeping idle connections in the connection pool in seconds.
59
- * Default is 300 seconds (5 minutes). This can also be set via the
60
- * environment variable `LANCE_CLIENT_CONNECTION_TIMEOUT`, as an integer
61
- * number of seconds.
62
- */
63
- poolIdleTimeout?: number
101
+
102
+ /** Typescript-style Async Iterator over RecordBatches */
103
+ export declare class RecordBatchIterator {
104
+ next(): Promise<Buffer | null>
64
105
  }
65
- /** Retry configuration for the remote HTTP client. */
66
- export interface RetryConfig {
67
- /**
68
- * The maximum number of retries for a request. Default is 3. You can also
69
- * set this via the environment variable `LANCE_CLIENT_MAX_RETRIES`.
70
- */
71
- retries?: number
72
- /**
73
- * The maximum number of retries for connection errors. Default is 3. You
74
- * can also set this via the environment variable `LANCE_CLIENT_CONNECT_RETRIES`.
75
- */
76
- connectRetries?: number
77
- /**
78
- * The maximum number of retries for read errors. Default is 3. You can also
79
- * set this via the environment variable `LANCE_CLIENT_READ_RETRIES`.
80
- */
81
- readRetries?: number
82
- /**
83
- * The backoff factor to apply between retries. Default is 0.25. Between each retry
84
- * the client will wait for the amount of seconds:
85
- * `{backoff factor} * (2 ** ({number of previous retries}))`. So for the default
86
- * of 0.25, the first retry will wait 0.25 seconds, the second retry will wait 0.5
87
- * seconds, the third retry will wait 1 second, etc.
88
- *
89
- * You can also set this via the environment variable
90
- * `LANCE_CLIENT_RETRY_BACKOFF_FACTOR`.
91
- */
92
- backoffFactor?: number
106
+
107
+ /** Wrapper around rust RRFReranker */
108
+ export declare class RrfReranker {
109
+ static tryNew(k: Float32Array): Promise<RrfReranker>
110
+ rerankHybrid(query: string, vecResults: Buffer, ftsResults: Buffer): Promise<Buffer>
111
+ }
112
+ export type RRFReranker = RrfReranker
113
+
114
+ /**
115
+ * A session for managing caches and object stores across LanceDB operations.
116
+ *
117
+ * Sessions allow you to configure cache sizes for index and metadata caches,
118
+ * which can significantly impact memory use and performance. They can
119
+ * also be re-used across multiple connections to share the same cache state.
120
+ */
121
+ export declare class Session {
93
122
  /**
94
- * The jitter to apply to the backoff factor, in seconds. Default is 0.25.
123
+ * Create a new session with custom cache sizes.
95
124
  *
96
- * A random value between 0 and `backoff_jitter` will be added to the backoff
97
- * factor in seconds. So for the default of 0.25 seconds, between 0 and 250
98
- * milliseconds will be added to the sleep between each retry.
125
+ * # Parameters
99
126
  *
100
- * You can also set this via the environment variable
101
- * `LANCE_CLIENT_RETRY_BACKOFF_JITTER`.
127
+ * - `index_cache_size_bytes`: The size of the index cache in bytes.
128
+ * Index data is stored in memory in this cache to speed up queries.
129
+ * Defaults to 6GB if not specified.
130
+ * - `metadata_cache_size_bytes`: The size of the metadata cache in bytes.
131
+ * The metadata cache stores file metadata and schema information in memory.
132
+ * This cache improves scan and write performance.
133
+ * Defaults to 1GB if not specified.
102
134
  */
103
- backoffJitter?: number
135
+ constructor(indexCacheSizeBytes?: bigint | undefined | null, metadataCacheSizeBytes?: bigint | undefined | null)
104
136
  /**
105
- * The HTTP status codes for which to retry the request. Default is
106
- * [429, 500, 502, 503].
137
+ * Create a session with default cache sizes.
107
138
  *
108
- * You can also set this via the environment variable
109
- * `LANCE_CLIENT_RETRY_STATUSES`. Use a comma-separated list of integers.
139
+ * This is equivalent to creating a session with 6GB index cache
140
+ * and 1GB metadata cache.
110
141
  */
111
- statuses?: Array<number>
112
- }
113
- /** TLS/mTLS configuration for the remote HTTP client. */
114
- export interface TlsConfig {
115
- /** Path to the client certificate file (PEM format) for mTLS authentication. */
116
- certFile?: string
117
- /** Path to the client private key file (PEM format) for mTLS authentication. */
118
- keyFile?: string
119
- /** Path to the CA certificate file (PEM format) for server verification. */
120
- sslCaCert?: string
121
- /** Whether to verify the hostname in the server's certificate. */
122
- assertHostname?: boolean
123
- }
124
- export interface ClientConfig {
125
- userAgent?: string
126
- retryConfig?: RetryConfig
127
- timeoutConfig?: TimeoutConfig
128
- extraHeaders?: Record<string, string>
129
- idDelimiter?: string
130
- tlsConfig?: TlsConfig
131
- }
132
- export interface RerankerCallbacks {
133
- rerankHybrid: (...args: any[]) => any
134
- }
135
- export interface RerankHybridCallbackArgs {
136
- query: string
137
- vecResults: Array<number>
138
- ftsResults: Array<number>
142
+ static default(): Session
143
+ /** Get the current size of the session caches in bytes. */
144
+ sizeBytes(): bigint
145
+ /** Get the approximate number of items cached in the session. */
146
+ approxNumItems(): number
139
147
  }
140
- /** A description of an index currently configured on a column */
141
- export interface IndexConfig {
142
- /** The name of the index */
148
+
149
+ export declare class Table {
143
150
  name: string
144
- /** The type of the index */
145
- indexType: string
146
- /**
147
- * The columns in the index
148
- *
149
- * Currently this is always an array of size 1. In the future there may
150
- * be more columns to represent composite indices.
151
- */
152
- columns: Array<string>
153
- }
154
- /** Statistics about a compaction operation. */
155
- export interface CompactionStats {
156
- /** The number of fragments removed */
157
- fragmentsRemoved: number
158
- /** The number of new, compacted fragments added */
159
- fragmentsAdded: number
160
- /** The number of data files removed */
161
- filesRemoved: number
162
- /** The number of new, compacted data files added */
163
- filesAdded: number
151
+ display(): string
152
+ isOpen(): boolean
153
+ close(): void
154
+ /** Return Schema as empty Arrow IPC file. */
155
+ schema(): Promise<Buffer>
156
+ add(buf: Buffer, mode: string): Promise<AddResult>
157
+ countRows(filter?: string | undefined | null): Promise<number>
158
+ delete(predicate: string): Promise<DeleteResult>
159
+ createIndex(index: Index | undefined | null, column: string, replace?: boolean | undefined | null, waitTimeoutS?: number | undefined | null, name?: string | undefined | null, train?: boolean | undefined | null): Promise<void>
160
+ dropIndex(indexName: string): Promise<void>
161
+ prewarmIndex(indexName: string): Promise<void>
162
+ waitForIndex(indexNames: Array<string>, timeoutS: number): Promise<void>
163
+ stats(): Promise<TableStatistics>
164
+ initialStorageOptions(): Promise<Record<string, string> | null>
165
+ latestStorageOptions(): Promise<Record<string, string> | null>
166
+ update(onlyIf: string | undefined | null, columns: Array<[string, string]>): Promise<UpdateResult>
167
+ query(): Query
168
+ takeOffsets(offsets: Array<number>): TakeQuery
169
+ takeRowIds(rowIds: Array<bigint>): TakeQuery
170
+ vectorSearch(vector: Float32Array): VectorQuery
171
+ addColumns(transforms: Array<AddColumnsSql>): Promise<AddColumnsResult>
172
+ alterColumns(alterations: Array<ColumnAlteration>): Promise<AlterColumnsResult>
173
+ dropColumns(columns: Array<string>): Promise<DropColumnsResult>
174
+ version(): Promise<number>
175
+ checkout(version: number): Promise<void>
176
+ checkoutTag(tag: string): Promise<void>
177
+ checkoutLatest(): Promise<void>
178
+ listVersions(): Promise<Array<Version>>
179
+ restore(): Promise<void>
180
+ tags(): Promise<Tags>
181
+ optimize(olderThanMs?: number | undefined | null, deleteUnverified?: boolean | undefined | null): Promise<OptimizeStats>
182
+ listIndices(): Promise<Array<IndexConfig>>
183
+ indexStats(indexName: string): Promise<IndexStatistics | null>
184
+ mergeInsert(on: Array<string>): NativeMergeInsertBuilder
185
+ usesV2ManifestPaths(): Promise<boolean>
186
+ migrateManifestPathsV2(): Promise<void>
164
187
  }
165
- /** Statistics about a cleanup operation */
166
- export interface RemovalStats {
167
- /** The number of bytes removed */
168
- bytesRemoved: number
169
- /** The number of old versions removed */
170
- oldVersionsRemoved: number
188
+
189
+ export declare class TagContents {
190
+ version: number
191
+ manifestSize: number
171
192
  }
172
- /** Statistics about an optimize operation */
173
- export interface OptimizeStats {
174
- /** Statistics about the compaction operation */
175
- compaction: CompactionStats
176
- /** Statistics about the removal operation */
177
- prune: RemovalStats
193
+
194
+ export declare class Tags {
195
+ list(): Promise<Record<string, TagContents>>
196
+ getVersion(tag: string): Promise<number>
197
+ create(tag: string, version: number): Promise<void>
198
+ delete(tag: string): Promise<void>
199
+ update(tag: string, version: number): Promise<void>
200
+ }
201
+
202
+ export declare class TakeQuery {
203
+ select(columns: Array<[string, string]>): void
204
+ selectColumns(columns: Array<string>): void
205
+ withRowId(): void
206
+ outputSchema(): Promise<Buffer>
207
+ execute(maxBatchLength?: number | undefined | null, timeoutMs?: number | undefined | null): Promise<RecordBatchIterator>
208
+ explainPlan(verbose: boolean): Promise<string>
209
+ analyzePlan(): Promise<string>
210
+ }
211
+
212
+ export declare class VectorQuery {
213
+ column(column: string): void
214
+ addQueryVector(vector: Float32Array): void
215
+ distanceType(distanceType: string): void
216
+ postfilter(): void
217
+ refineFactor(refineFactor: number): void
218
+ nprobes(nprobe: number): void
219
+ minimumNprobes(minimumNprobe: number): void
220
+ maximumNprobes(maximumNprobes: number): void
221
+ distanceRange(lowerBound?: number | undefined | null, upperBound?: number | undefined | null): void
222
+ ef(ef: number): void
223
+ bypassVectorIndex(): void
224
+ onlyIf(predicate: string): void
225
+ fullTextSearch(query: object): void
226
+ select(columns: Array<[string, string]>): void
227
+ selectColumns(columns: Array<string>): void
228
+ limit(limit: number): void
229
+ offset(offset: number): void
230
+ fastSearch(): void
231
+ withRowId(): void
232
+ rerank(rerankHybrid: (arg: RerankHybridCallbackArgs) => Promise<Buffer>): void
233
+ outputSchema(): Promise<Buffer>
234
+ execute(maxBatchLength?: number | undefined | null, timeoutMs?: number | undefined | null): Promise<RecordBatchIterator>
235
+ explainPlan(verbose: boolean): Promise<string>
236
+ analyzePlan(): Promise<string>
237
+ }
238
+
239
+ export interface AddColumnsResult {
240
+ version: number
241
+ }
242
+
243
+ /** A definition of a new column to add to a table. */
244
+ export interface AddColumnsSql {
245
+ /** The name of the new column. */
246
+ name: string
247
+ /**
248
+ * The values to populate the new column with, as a SQL expression.
249
+ * The expression can reference other columns in the table.
250
+ */
251
+ valueSql: string
252
+ }
253
+
254
+ export interface AddResult {
255
+ version: number
256
+ }
257
+
258
+ export interface AlterColumnsResult {
259
+ version: number
260
+ }
261
+
262
+ export interface ClientConfig {
263
+ userAgent?: string
264
+ retryConfig?: RetryConfig
265
+ timeoutConfig?: TimeoutConfig
266
+ extraHeaders?: Record<string, string>
267
+ idDelimiter?: string
268
+ tlsConfig?: TlsConfig
178
269
  }
270
+
179
271
  /**
180
272
  * A definition of a column alteration. The alteration changes the column at
181
273
  * `path` to have the new name `name`, to be nullable if `nullable` is true,
@@ -210,102 +302,19 @@ export interface ColumnAlteration {
210
302
  /** Set the new nullability. Note that a nullable column cannot be made non-nullable. */
211
303
  nullable?: boolean
212
304
  }
213
- /** A definition of a new column to add to a table. */
214
- export interface AddColumnsSql {
215
- /** The name of the new column. */
216
- name: string
217
- /**
218
- * The values to populate the new column with, as a SQL expression.
219
- * The expression can reference other columns in the table.
220
- */
221
- valueSql: string
222
- }
223
- export interface IndexStatistics {
224
- /** The number of rows indexed by the index */
225
- numIndexedRows: number
226
- /** The number of rows not indexed */
227
- numUnindexedRows: number
228
- /** The type of the index */
229
- indexType: string
230
- /**
231
- * The type of the distance function used by the index. This is only
232
- * present for vector indices. Scalar and full text search indices do
233
- * not have a distance function.
234
- */
235
- distanceType?: string
236
- /** The number of parts this index is split into. */
237
- numIndices?: number
238
- /**
239
- * The KMeans loss value of the index,
240
- * it is only present for vector indices.
241
- */
242
- loss?: number
243
- }
244
- export interface TableStatistics {
245
- /** The total number of bytes in the table */
246
- totalBytes: number
247
- /** The number of rows in the table */
248
- numRows: number
249
- /** The number of indices in the table */
250
- numIndices: number
251
- /** Statistics on table fragments */
252
- fragmentStats: FragmentStatistics
253
- }
254
- export interface FragmentStatistics {
255
- /** The number of fragments in the table */
256
- numFragments: number
257
- /** The number of uncompacted fragments in the table */
258
- numSmallFragments: number
259
- /** Statistics on the number of rows in the table fragments */
260
- lengths: FragmentSummaryStats
261
- }
262
- export interface FragmentSummaryStats {
263
- /** The number of rows in the fragment with the fewest rows */
264
- min: number
265
- /** The number of rows in the fragment with the most rows */
266
- max: number
267
- /** The mean number of rows in the fragments */
268
- mean: number
269
- /** The 25th percentile of number of rows in the fragments */
270
- p25: number
271
- /** The 50th percentile of number of rows in the fragments */
272
- p50: number
273
- /** The 75th percentile of number of rows in the fragments */
274
- p75: number
275
- /** The 99th percentile of number of rows in the fragments */
276
- p99: number
277
- }
278
- export interface Version {
279
- version: number
280
- timestamp: number
281
- metadata: Record<string, string>
282
- }
283
- export interface UpdateResult {
284
- rowsUpdated: number
285
- version: number
286
- }
287
- export interface AddResult {
288
- version: number
289
- }
290
- export interface DeleteResult {
291
- version: number
292
- }
293
- export interface MergeResult {
294
- version: number
295
- numInsertedRows: number
296
- numUpdatedRows: number
297
- numDeletedRows: number
298
- numAttempts: number
299
- }
300
- export interface AddColumnsResult {
301
- version: number
302
- }
303
- export interface AlterColumnsResult {
304
- version: number
305
- }
306
- export interface DropColumnsResult {
307
- version: number
305
+
306
+ /** Statistics about a compaction operation. */
307
+ export interface CompactionStats {
308
+ /** The number of fragments removed */
309
+ fragmentsRemoved: number
310
+ /** The number of new, compacted fragments added */
311
+ fragmentsAdded: number
312
+ /** The number of data files removed */
313
+ filesRemoved: number
314
+ /** The number of new, compacted data files added */
315
+ filesAdded: number
308
316
  }
317
+
309
318
  export interface ConnectionOptions {
310
319
  /**
311
320
  * (For LanceDB OSS only): The interval, in seconds, at which to check for
@@ -349,237 +358,257 @@ export interface ConnectionOptions {
349
358
  */
350
359
  hostOverride?: string
351
360
  }
352
- export interface OpenTableOptions {
353
- storageOptions?: Record<string, string>
361
+
362
+ export interface DeleteResult {
363
+ version: number
354
364
  }
355
- export class Connection {
356
- /** Create a new Connection instance from the given URI. */
357
- static new(uri: string, options: ConnectionOptions, headerProvider?: JsHeaderProvider | undefined | null): Promise<Connection>
358
- display(): string
359
- isOpen(): boolean
360
- close(): void
361
- /** List all tables in the dataset. */
362
- tableNames(namespace: Array<string>, startAfter?: string | undefined | null, limit?: number | undefined | null): Promise<Array<string>>
363
- /**
364
- * Create table from a Apache Arrow IPC (file) buffer.
365
- *
366
- * Parameters:
367
- * - name: The name of the table.
368
- * - buf: The buffer containing the IPC file.
369
- *
370
- */
371
- createTable(name: string, buf: Buffer, mode: string, namespace: Array<string>, storageOptions?: Record<string, string> | undefined | null): Promise<Table>
372
- createEmptyTable(name: string, schemaBuf: Buffer, mode: string, namespace: Array<string>, storageOptions?: Record<string, string> | undefined | null): Promise<Table>
373
- openTable(name: string, namespace: Array<string>, storageOptions?: Record<string, string> | undefined | null, indexCacheSize?: number | undefined | null): Promise<Table>
374
- cloneTable(targetTableName: string, sourceUri: string, targetNamespace: Array<string>, sourceVersion: number | undefined | null, sourceTag: string | undefined | null, isShallow: boolean): Promise<Table>
375
- /** Drop table with the name. Or raise an error if the table does not exist. */
376
- dropTable(name: string, namespace: Array<string>): Promise<void>
377
- dropAllTables(namespace: Array<string>): Promise<void>
378
- }
379
- /**
380
- * JavaScript HeaderProvider implementation that wraps a JavaScript callback.
381
- * This is the only native header provider - all header provider implementations
382
- * should provide a JavaScript function that returns headers.
383
- */
384
- export class JsHeaderProvider {
385
- /** Create a new JsHeaderProvider from a JavaScript callback */
386
- constructor(getHeadersCallback: (...args: any[]) => any)
387
- }
388
- export class Index {
389
- static ivfPq(distanceType?: string | undefined | null, numPartitions?: number | undefined | null, numSubVectors?: number | undefined | null, numBits?: number | undefined | null, maxIterations?: number | undefined | null, sampleRate?: number | undefined | null): Index
390
- static ivfRq(distanceType?: string | undefined | null, numPartitions?: number | undefined | null, numBits?: number | undefined | null, maxIterations?: number | undefined | null, sampleRate?: number | undefined | null): Index
391
- static ivfFlat(distanceType?: string | undefined | null, numPartitions?: number | undefined | null, maxIterations?: number | undefined | null, sampleRate?: number | undefined | null): Index
392
- static btree(): Index
393
- static bitmap(): Index
394
- static labelList(): Index
395
- static fts(withPosition?: boolean | undefined | null, baseTokenizer?: string | undefined | null, language?: string | undefined | null, maxTokenLength?: number | undefined | null, lowerCase?: boolean | undefined | null, stem?: boolean | undefined | null, removeStopWords?: boolean | undefined | null, asciiFolding?: boolean | undefined | null, ngramMinLength?: number | undefined | null, ngramMaxLength?: number | undefined | null, prefixOnly?: boolean | undefined | null): Index
396
- static hnswPq(distanceType?: string | undefined | null, numPartitions?: number | undefined | null, numSubVectors?: number | undefined | null, maxIterations?: number | undefined | null, sampleRate?: number | undefined | null, m?: number | undefined | null, efConstruction?: number | undefined | null): Index
397
- static hnswSq(distanceType?: string | undefined | null, numPartitions?: number | undefined | null, maxIterations?: number | undefined | null, sampleRate?: number | undefined | null, m?: number | undefined | null, efConstruction?: number | undefined | null): Index
365
+
366
+ export interface DropColumnsResult {
367
+ version: number
398
368
  }
399
- /** Typescript-style Async Iterator over RecordBatches */
400
- export class RecordBatchIterator {
401
- next(): Promise<Buffer | null>
369
+
370
+ export interface FragmentStatistics {
371
+ /** The number of fragments in the table */
372
+ numFragments: number
373
+ /** The number of uncompacted fragments in the table */
374
+ numSmallFragments: number
375
+ /** Statistics on the number of rows in the table fragments */
376
+ lengths: FragmentSummaryStats
402
377
  }
403
- /** A builder used to create and run a merge insert operation */
404
- export class NativeMergeInsertBuilder {
405
- whenMatchedUpdateAll(condition?: string | undefined | null): NativeMergeInsertBuilder
406
- whenNotMatchedInsertAll(): NativeMergeInsertBuilder
407
- whenNotMatchedBySourceDelete(filter?: string | undefined | null): NativeMergeInsertBuilder
408
- setTimeout(timeout: number): void
409
- useIndex(useIndex: boolean): NativeMergeInsertBuilder
410
- execute(buf: Buffer): Promise<MergeResult>
378
+
379
+ export interface FragmentSummaryStats {
380
+ /** The number of rows in the fragment with the fewest rows */
381
+ min: number
382
+ /** The number of rows in the fragment with the most rows */
383
+ max: number
384
+ /** The mean number of rows in the fragments */
385
+ mean: number
386
+ /** The 25th percentile of number of rows in the fragments */
387
+ p25: number
388
+ /** The 50th percentile of number of rows in the fragments */
389
+ p50: number
390
+ /** The 75th percentile of number of rows in the fragments */
391
+ p75: number
392
+ /** The 99th percentile of number of rows in the fragments */
393
+ p99: number
411
394
  }
412
- export class PermutationBuilder {
413
- persist(connection: Connection, tableName: string): PermutationBuilder
414
- /** Configure random splits */
415
- splitRandom(options: SplitRandomOptions): PermutationBuilder
416
- /** Configure hash-based splits */
417
- splitHash(options: SplitHashOptions): PermutationBuilder
418
- /** Configure sequential splits */
419
- splitSequential(options: SplitSequentialOptions): PermutationBuilder
420
- /** Configure calculated splits */
421
- splitCalculated(options: SplitCalculatedOptions): PermutationBuilder
422
- /** Configure shuffling */
423
- shuffle(options: ShuffleOptions): PermutationBuilder
424
- /** Configure filtering */
425
- filter(filter: string): PermutationBuilder
426
- /** Execute the permutation builder and create the table */
427
- execute(): Promise<Table>
395
+
396
+ /** A description of an index currently configured on a column */
397
+ export interface IndexConfig {
398
+ /** The name of the index */
399
+ name: string
400
+ /** The type of the index */
401
+ indexType: string
402
+ /**
403
+ * The columns in the index
404
+ *
405
+ * Currently this is always an array of size 1. In the future there may
406
+ * be more columns to represent composite indices.
407
+ */
408
+ columns: Array<string>
428
409
  }
429
- export class Query {
430
- onlyIf(predicate: string): void
431
- fullTextSearch(query: object): void
432
- select(columns: Array<[string, string]>): void
433
- selectColumns(columns: Array<string>): void
434
- limit(limit: number): void
435
- offset(offset: number): void
436
- nearestTo(vector: Float32Array): VectorQuery
437
- fastSearch(): void
438
- withRowId(): void
439
- outputSchema(): Promise<Buffer>
440
- execute(maxBatchLength?: number | undefined | null, timeoutMs?: number | undefined | null): Promise<RecordBatchIterator>
441
- explainPlan(verbose: boolean): Promise<string>
442
- analyzePlan(): Promise<string>
410
+
411
+ export interface IndexStatistics {
412
+ /** The number of rows indexed by the index */
413
+ numIndexedRows: number
414
+ /** The number of rows not indexed */
415
+ numUnindexedRows: number
416
+ /** The type of the index */
417
+ indexType: string
418
+ /**
419
+ * The type of the distance function used by the index. This is only
420
+ * present for vector indices. Scalar and full text search indices do
421
+ * not have a distance function.
422
+ */
423
+ distanceType?: string
424
+ /** The number of parts this index is split into. */
425
+ numIndices?: number
426
+ /**
427
+ * The KMeans loss value of the index,
428
+ * it is only present for vector indices.
429
+ */
430
+ loss?: number
443
431
  }
444
- export class VectorQuery {
445
- column(column: string): void
446
- addQueryVector(vector: Float32Array): void
447
- distanceType(distanceType: string): void
448
- postfilter(): void
449
- refineFactor(refineFactor: number): void
450
- nprobes(nprobe: number): void
451
- minimumNprobes(minimumNprobe: number): void
452
- maximumNprobes(maximumNprobes: number): void
453
- distanceRange(lowerBound?: number | undefined | null, upperBound?: number | undefined | null): void
454
- ef(ef: number): void
455
- bypassVectorIndex(): void
456
- onlyIf(predicate: string): void
457
- fullTextSearch(query: object): void
458
- select(columns: Array<[string, string]>): void
459
- selectColumns(columns: Array<string>): void
460
- limit(limit: number): void
461
- offset(offset: number): void
462
- fastSearch(): void
463
- withRowId(): void
464
- rerank(callbacks: RerankerCallbacks): void
465
- outputSchema(): Promise<Buffer>
466
- execute(maxBatchLength?: number | undefined | null, timeoutMs?: number | undefined | null): Promise<RecordBatchIterator>
467
- explainPlan(verbose: boolean): Promise<string>
468
- analyzePlan(): Promise<string>
432
+
433
+ export interface MergeResult {
434
+ version: number
435
+ numInsertedRows: number
436
+ numUpdatedRows: number
437
+ numDeletedRows: number
438
+ numAttempts: number
469
439
  }
470
- export class TakeQuery {
471
- select(columns: Array<[string, string]>): void
472
- selectColumns(columns: Array<string>): void
473
- withRowId(): void
474
- outputSchema(): Promise<Buffer>
475
- execute(maxBatchLength?: number | undefined | null, timeoutMs?: number | undefined | null): Promise<RecordBatchIterator>
476
- explainPlan(verbose: boolean): Promise<string>
477
- analyzePlan(): Promise<string>
440
+
441
+ export interface OpenTableOptions {
442
+ storageOptions?: Record<string, string>
478
443
  }
479
- export class JsFullTextQuery {
480
- static matchQuery(query: string, column: string, boost: number, fuzziness: number | undefined | null, maxExpansions: number, operator: string, prefixLength: number): JsFullTextQuery
481
- static phraseQuery(query: string, column: string, slop: number): JsFullTextQuery
482
- static boostQuery(positive: JsFullTextQuery, negative: JsFullTextQuery, negativeBoost?: number | undefined | null): JsFullTextQuery
483
- static multiMatchQuery(query: string, columns: Array<string>, boosts: Array<number> | undefined | null, operator: string): JsFullTextQuery
484
- static booleanQuery(queries: Array<[string, JsFullTextQuery]>): JsFullTextQuery
485
- get queryType(): string
444
+
445
+ /** Statistics about an optimize operation */
446
+ export interface OptimizeStats {
447
+ /** Statistics about the compaction operation */
448
+ compaction: CompactionStats
449
+ /** Statistics about the removal operation */
450
+ prune: RemovalStats
486
451
  }
487
- /**
488
- * Reranker implementation that "wraps" a NodeJS Reranker implementation.
489
- * This contains references to the callbacks that can be used to invoke the
490
- * reranking methods on the NodeJS implementation and handles serializing the
491
- * record batches to Arrow IPC buffers.
492
- */
493
- export class Reranker {
494
- static new(callbacks: RerankerCallbacks): Reranker
452
+
453
+ /** Create a permutation builder for the given table */
454
+ export declare function permutationBuilder(table: Table): PermutationBuilder
455
+
456
+ /** Statistics about a cleanup operation */
457
+ export interface RemovalStats {
458
+ /** The number of bytes removed */
459
+ bytesRemoved: number
460
+ /** The number of old versions removed */
461
+ oldVersionsRemoved: number
495
462
  }
496
- export type RRFReranker = RrfReranker
497
- /** Wrapper around rust RRFReranker */
498
- export class RrfReranker {
499
- static tryNew(k: Float32Array): Promise<RrfReranker>
500
- rerankHybrid(query: string, vecResults: Buffer, ftsResults: Buffer): Promise<Buffer>
463
+
464
+ export interface RerankHybridCallbackArgs {
465
+ query: string
466
+ vecResults: Buffer
467
+ ftsResults: Buffer
501
468
  }
502
- /**
503
- * A session for managing caches and object stores across LanceDB operations.
504
- *
505
- * Sessions allow you to configure cache sizes for index and metadata caches,
506
- * which can significantly impact memory use and performance. They can
507
- * also be re-used across multiple connections to share the same cache state.
508
- */
509
- export class Session {
469
+
470
+ /** Retry configuration for the remote HTTP client. */
471
+ export interface RetryConfig {
510
472
  /**
511
- * Create a new session with custom cache sizes.
473
+ * The maximum number of retries for a request. Default is 3. You can also
474
+ * set this via the environment variable `LANCE_CLIENT_MAX_RETRIES`.
475
+ */
476
+ retries?: number
477
+ /**
478
+ * The maximum number of retries for connection errors. Default is 3. You
479
+ * can also set this via the environment variable `LANCE_CLIENT_CONNECT_RETRIES`.
480
+ */
481
+ connectRetries?: number
482
+ /**
483
+ * The maximum number of retries for read errors. Default is 3. You can also
484
+ * set this via the environment variable `LANCE_CLIENT_READ_RETRIES`.
485
+ */
486
+ readRetries?: number
487
+ /**
488
+ * The backoff factor to apply between retries. Default is 0.25. Between each retry
489
+ * the client will wait for the amount of seconds:
490
+ * `{backoff factor} * (2 ** ({number of previous retries}))`. So for the default
491
+ * of 0.25, the first retry will wait 0.25 seconds, the second retry will wait 0.5
492
+ * seconds, the third retry will wait 1 second, etc.
512
493
  *
513
- * # Parameters
494
+ * You can also set this via the environment variable
495
+ * `LANCE_CLIENT_RETRY_BACKOFF_FACTOR`.
496
+ */
497
+ backoffFactor?: number
498
+ /**
499
+ * The jitter to apply to the backoff factor, in seconds. Default is 0.25.
514
500
  *
515
- * - `index_cache_size_bytes`: The size of the index cache in bytes.
516
- * Index data is stored in memory in this cache to speed up queries.
517
- * Defaults to 6GB if not specified.
518
- * - `metadata_cache_size_bytes`: The size of the metadata cache in bytes.
519
- * The metadata cache stores file metadata and schema information in memory.
520
- * This cache improves scan and write performance.
521
- * Defaults to 1GB if not specified.
501
+ * A random value between 0 and `backoff_jitter` will be added to the backoff
502
+ * factor in seconds. So for the default of 0.25 seconds, between 0 and 250
503
+ * milliseconds will be added to the sleep between each retry.
504
+ *
505
+ * You can also set this via the environment variable
506
+ * `LANCE_CLIENT_RETRY_BACKOFF_JITTER`.
522
507
  */
523
- constructor(indexCacheSizeBytes?: bigint | undefined | null, metadataCacheSizeBytes?: bigint | undefined | null)
508
+ backoffJitter?: number
524
509
  /**
525
- * Create a session with default cache sizes.
510
+ * The HTTP status codes for which to retry the request. Default is
511
+ * [429, 500, 502, 503].
526
512
  *
527
- * This is equivalent to creating a session with 6GB index cache
528
- * and 1GB metadata cache.
513
+ * You can also set this via the environment variable
514
+ * `LANCE_CLIENT_RETRY_STATUSES`. Use a comma-separated list of integers.
529
515
  */
530
- static default(): Session
531
- /** Get the current size of the session caches in bytes. */
532
- sizeBytes(): bigint
533
- /** Get the approximate number of items cached in the session. */
534
- approxNumItems(): number
516
+ statuses?: Array<number>
535
517
  }
536
- export class Table {
537
- name: string
538
- display(): string
539
- isOpen(): boolean
540
- close(): void
541
- /** Return Schema as empty Arrow IPC file. */
542
- schema(): Promise<Buffer>
543
- add(buf: Buffer, mode: string): Promise<AddResult>
544
- countRows(filter?: string | undefined | null): Promise<number>
545
- delete(predicate: string): Promise<DeleteResult>
546
- createIndex(index: Index | undefined | null, column: string, replace?: boolean | undefined | null, waitTimeoutS?: number | undefined | null, name?: string | undefined | null, train?: boolean | undefined | null): Promise<void>
547
- dropIndex(indexName: string): Promise<void>
548
- prewarmIndex(indexName: string): Promise<void>
549
- waitForIndex(indexNames: Array<string>, timeoutS: number): Promise<void>
550
- stats(): Promise<TableStatistics>
551
- initialStorageOptions(): Promise<Record<string, string> | null>
552
- latestStorageOptions(): Promise<Record<string, string> | null>
553
- update(onlyIf: string | undefined | null, columns: Array<[string, string]>): Promise<UpdateResult>
554
- query(): Query
555
- takeOffsets(offsets: Array<number>): TakeQuery
556
- takeRowIds(rowIds: Array<bigint>): TakeQuery
557
- vectorSearch(vector: Float32Array): VectorQuery
558
- addColumns(transforms: Array<AddColumnsSql>): Promise<AddColumnsResult>
559
- alterColumns(alterations: Array<ColumnAlteration>): Promise<AlterColumnsResult>
560
- dropColumns(columns: Array<string>): Promise<DropColumnsResult>
561
- version(): Promise<number>
562
- checkout(version: number): Promise<void>
563
- checkoutTag(tag: string): Promise<void>
564
- checkoutLatest(): Promise<void>
565
- listVersions(): Promise<Array<Version>>
566
- restore(): Promise<void>
567
- tags(): Promise<Tags>
568
- optimize(olderThanMs?: number | undefined | null, deleteUnverified?: boolean | undefined | null): Promise<OptimizeStats>
569
- listIndices(): Promise<Array<IndexConfig>>
570
- indexStats(indexName: string): Promise<IndexStatistics | null>
571
- mergeInsert(on: Array<string>): NativeMergeInsertBuilder
572
- usesV2ManifestPaths(): Promise<boolean>
573
- migrateManifestPathsV2(): Promise<void>
518
+
519
+ export interface ShuffleOptions {
520
+ seed?: number
521
+ clumpSize?: number
522
+ }
523
+
524
+ export interface SplitCalculatedOptions {
525
+ calculation: string
526
+ splitNames?: Array<string>
527
+ }
528
+
529
+ export interface SplitHashOptions {
530
+ columns: Array<string>
531
+ splitWeights: Array<number>
532
+ discardWeight?: number
533
+ splitNames?: Array<string>
534
+ }
535
+
536
+ export interface SplitRandomOptions {
537
+ ratios?: Array<number>
538
+ counts?: Array<number>
539
+ fixed?: number
540
+ seed?: number
541
+ splitNames?: Array<string>
542
+ }
543
+
544
+ export interface SplitSequentialOptions {
545
+ ratios?: Array<number>
546
+ counts?: Array<number>
547
+ fixed?: number
548
+ splitNames?: Array<string>
574
549
  }
575
- export class TagContents {
550
+
551
+ export interface TableStatistics {
552
+ /** The total number of bytes in the table */
553
+ totalBytes: number
554
+ /** The number of rows in the table */
555
+ numRows: number
556
+ /** The number of indices in the table */
557
+ numIndices: number
558
+ /** Statistics on table fragments */
559
+ fragmentStats: FragmentStatistics
560
+ }
561
+
562
+ /** Timeout configuration for remote HTTP client. */
563
+ export interface TimeoutConfig {
564
+ /**
565
+ * The overall timeout for the entire request in seconds. This includes
566
+ * connection, send, and read time. If the entire request doesn't complete
567
+ * within this time, it will fail. Default is None (no overall timeout).
568
+ * This can also be set via the environment variable `LANCE_CLIENT_TIMEOUT`,
569
+ * as an integer number of seconds.
570
+ */
571
+ timeout?: number
572
+ /**
573
+ * The timeout for establishing a connection in seconds. Default is 120
574
+ * seconds (2 minutes). This can also be set via the environment variable
575
+ * `LANCE_CLIENT_CONNECT_TIMEOUT`, as an integer number of seconds.
576
+ */
577
+ connectTimeout?: number
578
+ /**
579
+ * The timeout for reading data from the server in seconds. Default is 300
580
+ * seconds (5 minutes). This can also be set via the environment variable
581
+ * `LANCE_CLIENT_READ_TIMEOUT`, as an integer number of seconds.
582
+ */
583
+ readTimeout?: number
584
+ /**
585
+ * The timeout for keeping idle connections in the connection pool in seconds.
586
+ * Default is 300 seconds (5 minutes). This can also be set via the
587
+ * environment variable `LANCE_CLIENT_CONNECTION_TIMEOUT`, as an integer
588
+ * number of seconds.
589
+ */
590
+ poolIdleTimeout?: number
591
+ }
592
+
593
+ /** TLS/mTLS configuration for the remote HTTP client. */
594
+ export interface TlsConfig {
595
+ /** Path to the client certificate file (PEM format) for mTLS authentication. */
596
+ certFile?: string
597
+ /** Path to the client private key file (PEM format) for mTLS authentication. */
598
+ keyFile?: string
599
+ /** Path to the CA certificate file (PEM format) for server verification. */
600
+ sslCaCert?: string
601
+ /** Whether to verify the hostname in the server's certificate. */
602
+ assertHostname?: boolean
603
+ }
604
+
605
+ export interface UpdateResult {
606
+ rowsUpdated: number
576
607
  version: number
577
- manifestSize: number
578
608
  }
579
- export class Tags {
580
- list(): Promise<Record<string, TagContents>>
581
- getVersion(tag: string): Promise<number>
582
- create(tag: string, version: number): Promise<void>
583
- delete(tag: string): Promise<void>
584
- update(tag: string, version: number): Promise<void>
609
+
610
+ export interface Version {
611
+ version: number
612
+ timestamp: number
613
+ metadata: Record<string, string>
585
614
  }