* improve the docstring for NodeJS connect functions and `ConnectOptions` parameters. * Simplify `npm run build` steps.
14 KiB
vectordb / Exports / LocalTable
Class: LocalTable<T>
A LanceDB Table is the collection of Records. Each Record has one or more vector fields.
Type parameters
| Name | Type |
|---|---|
T |
number[] |
Implements
Table<T>
Table of contents
Constructors
Properties
Accessors
Methods
- add
- checkElectron
- cleanupOldVersions
- compactFiles
- countRows
- createIndex
- createScalarIndex
- delete
- filter
- getSchema
- indexStats
- listIndices
- overwrite
- search
- update
Constructors
constructor
• new LocalTable<T>(tbl, name, options)
Type parameters
| Name | Type |
|---|---|
T |
number[] |
Parameters
| Name | Type |
|---|---|
tbl |
any |
name |
string |
options |
ConnectionOptions |
Defined in
• new LocalTable<T>(tbl, name, options, embeddings)
Type parameters
| Name | Type |
|---|---|
T |
number[] |
Parameters
| Name | Type | Description |
|---|---|---|
tbl |
any |
|
name |
string |
|
options |
ConnectionOptions |
|
embeddings |
EmbeddingFunction<T> |
An embedding function to use when interacting with this table |
Defined in
Properties
_embeddings
• Private Optional Readonly _embeddings: EmbeddingFunction<T>
Defined in
_isElectron
• Private Readonly _isElectron: boolean
Defined in
_name
• Private Readonly _name: string
Defined in
_options
• Private Readonly _options: () => ConnectionOptions
Type declaration
▸ (): ConnectionOptions
Returns
Defined in
_tbl
• Private _tbl: any
Defined in
where
• where: (value: string) => Query<T>
Type declaration
▸ (value): Query<T>
Creates a filter query to find all rows matching the specified criteria
Parameters
| Name | Type | Description |
|---|---|---|
value |
string |
The filter criteria (like SQL where clause syntax) |
Returns
Query<T>
Defined in
Accessors
name
• get name(): string
Returns
string
Implementation of
Defined in
schema
• get schema(): Promise<Schema<any>>
Returns
Promise<Schema<any>>
Implementation of
Defined in
Methods
add
▸ add(data): Promise<number>
Insert records into this Table.
Parameters
| Name | Type | Description |
|---|---|---|
data |
Record<string, unknown>[] |
Records to be inserted into the Table |
Returns
Promise<number>
The number of rows added to the table
Implementation of
Defined in
checkElectron
▸ Private checkElectron(): boolean
Returns
boolean
Defined in
cleanupOldVersions
▸ cleanupOldVersions(olderThan?, deleteUnverified?): Promise<CleanupStats>
Clean up old versions of the table, freeing disk space.
Parameters
| Name | Type | Description |
|---|---|---|
olderThan? |
number |
The minimum age in minutes of the versions to delete. If not provided, defaults to two weeks. |
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. |
Returns
Promise<CleanupStats>
Defined in
compactFiles
▸ compactFiles(options?): Promise<CompactionMetrics>
Run the compaction process on the table.
This can be run after making several small appends to optimize the table for faster reads.
Parameters
| Name | Type | Description |
|---|---|---|
options? |
CompactionOptions |
Advanced options configuring compaction. In most cases, you can omit this arguments, as the default options are sensible for most tables. |
Returns
Promise<CompactionMetrics>
Metrics about the compaction operation.
Defined in
countRows
▸ countRows(): Promise<number>
Returns the number of rows in this table.
Returns
Promise<number>
Implementation of
Defined in
createIndex
▸ createIndex(indexParams): Promise<any>
Create an ANN index on this Table vector index.
Parameters
| Name | Type | Description |
|---|---|---|
indexParams |
IvfPQIndexConfig |
The parameters of this Index, |
Returns
Promise<any>
See
VectorIndexParams.
Implementation of
Defined in
createScalarIndex
▸ createScalarIndex(column, replace): Promise<void>
Create a scalar index on this Table for the given column
Parameters
| Name | Type | Description |
|---|---|---|
column |
string |
The column to index |
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. |
Returns
Promise<void>
Examples
const con = await lancedb.connect('././lancedb')
const table = await con.openTable('images')
await table.createScalarIndex('my_col')
Implementation of
Defined in
delete
▸ delete(filter): Promise<void>
Delete rows from this table.
Parameters
| Name | Type | Description |
|---|---|---|
filter |
string |
A filter in the same format used by a sql WHERE clause. |
Returns
Promise<void>
Implementation of
Defined in
filter
▸ filter(value): Query<T>
Creates a filter query to find all rows matching the specified criteria
Parameters
| Name | Type | Description |
|---|---|---|
value |
string |
The filter criteria (like SQL where clause syntax) |
Returns
Query<T>
Defined in
getSchema
▸ Private getSchema(): Promise<Schema<any>>
Returns
Promise<Schema<any>>
Defined in
indexStats
▸ indexStats(indexUuid): Promise<IndexStats>
Get statistics about an index.
Parameters
| Name | Type |
|---|---|
indexUuid |
string |
Returns
Promise<IndexStats>
Implementation of
Defined in
listIndices
▸ listIndices(): Promise<VectorIndex[]>
List the indicies on this table.
Returns
Promise<VectorIndex[]>
Implementation of
Defined in
overwrite
▸ overwrite(data): Promise<number>
Insert records into this Table, replacing its contents.
Parameters
| Name | Type | Description |
|---|---|---|
data |
Record<string, unknown>[] |
Records to be inserted into the Table |
Returns
Promise<number>
The number of rows added to the table
Implementation of
Defined in
search
▸ search(query): Query<T>
Creates a search query to find the nearest neighbors of the given search term
Parameters
| Name | Type | Description |
|---|---|---|
query |
T |
The query search term |
Returns
Query<T>
Implementation of
Defined in
update
▸ update(args): Promise<void>
Update rows in this table.
Parameters
| Name | Type | Description |
|---|---|---|
args |
UpdateArgs | UpdateSqlArgs |
see UpdateArgs and UpdateSqlArgs for more details |
Returns
Promise<void>