Elffuss BraidHub

kikocis/lancedb public

85830ec79fd2 · 13.8 KiBRenderedRawPermalink
1[vectordb](../README.md) / [Exports](../modules.md) / LocalTable
2
3# Class: LocalTable\<T\>
4
5A LanceDB Table is the collection of Records. Each Record has one or more vector fields.
6
7## Type parameters
8
9| Name | Type |
10| :------ | :------ |
11| `T` | `number`[] |
12
13## Implements
14
15- [`Table`](../interfaces/Table.md)\<`T`\>
16
17## Table of contents
18
19### Constructors
20
21- [constructor](LocalTable.md#constructor)
22
23### Properties
24
25- [\_embeddings](LocalTable.md#_embeddings)
26- [\_isElectron](LocalTable.md#_iselectron)
27- [\_name](LocalTable.md#_name)
28- [\_options](LocalTable.md#_options)
29- [\_tbl](LocalTable.md#_tbl)
30- [where](LocalTable.md#where)
31
32### Accessors
33
34- [name](LocalTable.md#name)
35- [schema](LocalTable.md#schema)
36
37### Methods
38
39- [add](LocalTable.md#add)
40- [checkElectron](LocalTable.md#checkelectron)
41- [cleanupOldVersions](LocalTable.md#cleanupoldversions)
42- [compactFiles](LocalTable.md#compactfiles)
43- [countRows](LocalTable.md#countrows)
44- [createIndex](LocalTable.md#createindex)
45- [createScalarIndex](LocalTable.md#createscalarindex)
46- [delete](LocalTable.md#delete)
47- [filter](LocalTable.md#filter)
48- [getSchema](LocalTable.md#getschema)
49- [indexStats](LocalTable.md#indexstats)
50- [listIndices](LocalTable.md#listindices)
51- [overwrite](LocalTable.md#overwrite)
52- [search](LocalTable.md#search)
53- [update](LocalTable.md#update)
54
55## Constructors
56
57### constructor
58
59• **new LocalTable**\<`T`\>(`tbl`, `name`, `options`)
60
61#### Type parameters
62
63| Name | Type |
64| :------ | :------ |
65| `T` | `number`[] |
66
67#### Parameters
68
69| Name | Type |
70| :------ | :------ |
71| `tbl` | `any` |
72| `name` | `string` |
73| `options` | [`ConnectionOptions`](../interfaces/ConnectionOptions.md) |
74
75#### Defined in
76
77[index.ts:642](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L642)
78
79• **new LocalTable**\<`T`\>(`tbl`, `name`, `options`, `embeddings`)
80
81#### Type parameters
82
83| Name | Type |
84| :------ | :------ |
85| `T` | `number`[] |
86
87#### Parameters
88
89| Name | Type | Description |
90| :------ | :------ | :------ |
91| `tbl` | `any` | |
92| `name` | `string` | |
93| `options` | [`ConnectionOptions`](../interfaces/ConnectionOptions.md) | |
94| `embeddings` | [`EmbeddingFunction`](../interfaces/EmbeddingFunction.md)\<`T`\> | An embedding function to use when interacting with this table |
95
96#### Defined in
97
98[index.ts:649](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L649)
99
100## Properties
101
102### \_embeddings
103
104• `Private` `Optional` `Readonly` **\_embeddings**: [`EmbeddingFunction`](../interfaces/EmbeddingFunction.md)\<`T`\>
105
106#### Defined in
107
108[index.ts:639](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L639)
109
110___
111
112### \_isElectron
113
114• `Private` `Readonly` **\_isElectron**: `boolean`
115
116#### Defined in
117
118[index.ts:638](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L638)
119
120___
121
122### \_name
123
124• `Private` `Readonly` **\_name**: `string`
125
126#### Defined in
127
128[index.ts:637](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L637)
129
130___
131
132### \_options
133
134• `Private` `Readonly` **\_options**: () => [`ConnectionOptions`](../interfaces/ConnectionOptions.md)
135
136#### Type declaration
137
138▸ (): [`ConnectionOptions`](../interfaces/ConnectionOptions.md)
139
140##### Returns
141
142[`ConnectionOptions`](../interfaces/ConnectionOptions.md)
143
144#### Defined in
145
146[index.ts:640](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L640)
147
148___
149
150### \_tbl
151
152• `Private` **\_tbl**: `any`
153
154#### Defined in
155
156[index.ts:636](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L636)
157
158___
159
160### where
161
162• **where**: (`value`: `string`) => [`Query`](Query.md)\<`T`\>
163
164#### Type declaration
165
166▸ (`value`): [`Query`](Query.md)\<`T`\>
167
168Creates a filter query to find all rows matching the specified criteria
169
170##### Parameters
171
172| Name | Type | Description |
173| :------ | :------ | :------ |
174| `value` | `string` | The filter criteria (like SQL where clause syntax) |
175
176##### Returns
177
178[`Query`](Query.md)\<`T`\>
179
180#### Defined in
181
182[index.ts:688](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L688)
183
184## Accessors
185
186### name
187
188• `get` **name**(): `string`
189
190#### Returns
191
192`string`
193
194#### Implementation of
195
196[Table](../interfaces/Table.md).[name](../interfaces/Table.md#name)
197
198#### Defined in
199
200[index.ts:668](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L668)
201
202___
203
204### schema
205
206• `get` **schema**(): `Promise`\<`Schema`\<`any`\>\>
207
208#### Returns
209
210`Promise`\<`Schema`\<`any`\>\>
211
212#### Implementation of
213
214[Table](../interfaces/Table.md).[schema](../interfaces/Table.md#schema)
215
216#### Defined in
217
218[index.ts:849](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L849)
219
220## Methods
221
222### add
223
224▸ **add**(`data`): `Promise`\<`number`\>
225
226Insert records into this Table.
227
228#### Parameters
229
230| Name | Type | Description |
231| :------ | :------ | :------ |
232| `data` | `Record`\<`string`, `unknown`\>[] | Records to be inserted into the Table |
233
234#### Returns
235
236`Promise`\<`number`\>
237
238The number of rows added to the table
239
240#### Implementation of
241
242[Table](../interfaces/Table.md).[add](../interfaces/Table.md#add)
243
244#### Defined in
245
246[index.ts:696](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L696)
247
248___
249
250### checkElectron
251
252▸ `Private` **checkElectron**(): `boolean`
253
254#### Returns
255
256`boolean`
257
258#### Defined in
259
260[index.ts:861](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L861)
261
262___
263
264### cleanupOldVersions
265
266▸ **cleanupOldVersions**(`olderThan?`, `deleteUnverified?`): `Promise`\<[`CleanupStats`](../interfaces/CleanupStats.md)\>
267
268Clean up old versions of the table, freeing disk space.
269
270#### Parameters
271
272| Name | Type | Description |
273| :------ | :------ | :------ |
274| `olderThan?` | `number` | The minimum age in minutes of the versions to delete. If not provided, defaults to two weeks. |
275| `deleteUnverified?` | `boolean` | Because they may be part of an in-progress transaction, uncommitted files newer than 7 days old are not deleted by default. This means that failed transactions can leave around data that takes up disk space for up to 7 days. You can override this safety mechanism by setting this option to `true`, only if you promise there are no in progress writes while you run this operation. Failure to uphold this promise can lead to corrupted tables. |
276
277#### Returns
278
279`Promise`\<[`CleanupStats`](../interfaces/CleanupStats.md)\>
280
281#### Defined in
282
283[index.ts:808](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L808)
284
285___
286
287### compactFiles
288
289▸ **compactFiles**(`options?`): `Promise`\<[`CompactionMetrics`](../interfaces/CompactionMetrics.md)\>
290
291Run the compaction process on the table.
292
293This can be run after making several small appends to optimize the table
294for faster reads.
295
296#### Parameters
297
298| Name | Type | Description |
299| :------ | :------ | :------ |
300| `options?` | [`CompactionOptions`](../interfaces/CompactionOptions.md) | Advanced options configuring compaction. In most cases, you can omit this arguments, as the default options are sensible for most tables. |
301
302#### Returns
303
304`Promise`\<[`CompactionMetrics`](../interfaces/CompactionMetrics.md)\>
305
306Metrics about the compaction operation.
307
308#### Defined in
309
310[index.ts:831](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L831)
311
312___
313
314### countRows
315
316▸ **countRows**(): `Promise`\<`number`\>
317
318Returns the number of rows in this table.
319
320#### Returns
321
322`Promise`\<`number`\>
323
324#### Implementation of
325
326[Table](../interfaces/Table.md).[countRows](../interfaces/Table.md#countrows)
327
328#### Defined in
329
330[index.ts:749](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L749)
331
332___
333
334### createIndex
335
336▸ **createIndex**(`indexParams`): `Promise`\<`any`\>
337
338Create an ANN index on this Table vector index.
339
340#### Parameters
341
342| Name | Type | Description |
343| :------ | :------ | :------ |
344| `indexParams` | [`IvfPQIndexConfig`](../interfaces/IvfPQIndexConfig.md) | The parameters of this Index, |
345
346#### Returns
347
348`Promise`\<`any`\>
349
350**`See`**
351
352VectorIndexParams.
353
354#### Implementation of
355
356[Table](../interfaces/Table.md).[createIndex](../interfaces/Table.md#createindex)
357
358#### Defined in
359
360[index.ts:734](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L734)
361
362___
363
364### createScalarIndex
365
366▸ **createScalarIndex**(`column`, `replace`): `Promise`\<`void`\>
367
368Create a scalar index on this Table for the given column
369
370#### Parameters
371
372| Name | Type | Description |
373| :------ | :------ | :------ |
374| `column` | `string` | The column to index |
375| `replace` | `boolean` | If false, fail if an index already exists on the column Scalar indices, like vector indices, can be used to speed up scans. A scalar index can speed up scans that contain filter expressions on the indexed column. For example, the following scan will be faster if the column `my_col` has a scalar index: ```ts const con = await lancedb.connect('./.lancedb'); const table = await con.openTable('images'); const results = await table.where('my_col = 7').execute(); ``` Scalar indices can also speed up scans containing a vector search and a prefilter: ```ts const con = await lancedb.connect('././lancedb'); const table = await con.openTable('images'); const results = await table.search([1.0, 2.0]).where('my_col != 7').prefilter(true); ``` Scalar indices can only speed up scans for basic filters using equality, comparison, range (e.g. `my_col BETWEEN 0 AND 100`), and set membership (e.g. `my_col IN (0, 1, 2)`) Scalar indices can be used if the filter contains multiple indexed columns and the filter criteria are AND'd or OR'd together (e.g. `my_col < 0 AND other_col> 100`) Scalar indices may be used if the filter contains non-indexed columns but, depending on the structure of the filter, they may not be usable. For example, if the column `not_indexed` does not have a scalar index then the filter `my_col = 0 OR not_indexed = 1` will not be able to use any scalar index on `my_col`. |
376
377#### Returns
378
379`Promise`\<`void`\>
380
381**`Examples`**
382
383```ts
384const con = await lancedb.connect('././lancedb')
385const table = await con.openTable('images')
386await table.createScalarIndex('my_col')
387```
388
389#### Implementation of
390
391[Table](../interfaces/Table.md).[createScalarIndex](../interfaces/Table.md#createscalarindex)
392
393#### Defined in
394
395[index.ts:742](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L742)
396
397___
398
399### delete
400
401▸ **delete**(`filter`): `Promise`\<`void`\>
402
403Delete rows from this table.
404
405#### Parameters
406
407| Name | Type | Description |
408| :------ | :------ | :------ |
409| `filter` | `string` | A filter in the same format used by a sql WHERE clause. |
410
411#### Returns
412
413`Promise`\<`void`\>
414
415#### Implementation of
416
417[Table](../interfaces/Table.md).[delete](../interfaces/Table.md#delete)
418
419#### Defined in
420
421[index.ts:758](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L758)
422
423___
424
425### filter
426
427▸ **filter**(`value`): [`Query`](Query.md)\<`T`\>
428
429Creates a filter query to find all rows matching the specified criteria
430
431#### Parameters
432
433| Name | Type | Description |
434| :------ | :------ | :------ |
435| `value` | `string` | The filter criteria (like SQL where clause syntax) |
436
437#### Returns
438
439[`Query`](Query.md)\<`T`\>
440
441#### Defined in
442
443[index.ts:684](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L684)
444
445___
446
447### getSchema
448
449▸ `Private` **getSchema**(): `Promise`\<`Schema`\<`any`\>\>
450
451#### Returns
452
453`Promise`\<`Schema`\<`any`\>\>
454
455#### Defined in
456
457[index.ts:854](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L854)
458
459___
460
461### indexStats
462
463▸ **indexStats**(`indexUuid`): `Promise`\<[`IndexStats`](../interfaces/IndexStats.md)\>
464
465Get statistics about an index.
466
467#### Parameters
468
469| Name | Type |
470| :------ | :------ |
471| `indexUuid` | `string` |
472
473#### Returns
474
475`Promise`\<[`IndexStats`](../interfaces/IndexStats.md)\>
476
477#### Implementation of
478
479[Table](../interfaces/Table.md).[indexStats](../interfaces/Table.md#indexstats)
480
481#### Defined in
482
483[index.ts:845](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L845)
484
485___
486
487### listIndices
488
489▸ **listIndices**(): `Promise`\<[`VectorIndex`](../interfaces/VectorIndex.md)[]\>
490
491List the indicies on this table.
492
493#### Returns
494
495`Promise`\<[`VectorIndex`](../interfaces/VectorIndex.md)[]\>
496
497#### Implementation of
498
499[Table](../interfaces/Table.md).[listIndices](../interfaces/Table.md#listindices)
500
501#### Defined in
502
503[index.ts:841](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L841)
504
505___
506
507### overwrite
508
509▸ **overwrite**(`data`): `Promise`\<`number`\>
510
511Insert records into this Table, replacing its contents.
512
513#### Parameters
514
515| Name | Type | Description |
516| :------ | :------ | :------ |
517| `data` | `Record`\<`string`, `unknown`\>[] | Records to be inserted into the Table |
518
519#### Returns
520
521`Promise`\<`number`\>
522
523The number of rows added to the table
524
525#### Implementation of
526
527[Table](../interfaces/Table.md).[overwrite](../interfaces/Table.md#overwrite)
528
529#### Defined in
530
531[index.ts:716](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L716)
532
533___
534
535### search
536
537▸ **search**(`query`): [`Query`](Query.md)\<`T`\>
538
539Creates a search query to find the nearest neighbors of the given search term
540
541#### Parameters
542
543| Name | Type | Description |
544| :------ | :------ | :------ |
545| `query` | `T` | The query search term |
546
547#### Returns
548
549[`Query`](Query.md)\<`T`\>
550
551#### Implementation of
552
553[Table](../interfaces/Table.md).[search](../interfaces/Table.md#search)
554
555#### Defined in
556
557[index.ts:676](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L676)
558
559___
560
561### update
562
563▸ **update**(`args`): `Promise`\<`void`\>
564
565Update rows in this table.
566
567#### Parameters
568
569| Name | Type | Description |
570| :------ | :------ | :------ |
571| `args` | [`UpdateArgs`](../interfaces/UpdateArgs.md) \| [`UpdateSqlArgs`](../interfaces/UpdateSqlArgs.md) | see [UpdateArgs](../interfaces/UpdateArgs.md) and [UpdateSqlArgs](../interfaces/UpdateSqlArgs.md) for more details |
572
573#### Returns
574
575`Promise`\<`void`\>
576
577#### Implementation of
578
579[Table](../interfaces/Table.md).[update](../interfaces/Table.md#update)
580
581#### Defined in
582
583[index.ts:771](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L771)