Movatterモバイル変換


[0]ホーム

URL:


Skip to content

vectordb /Exports / LocalTable

Class: LocalTable\<T>

A LanceDB Table is the collection of Records. Each Record has one or more vector fields.

Type parameters

NameType
Tnumber[]

Implements

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new LocalTable\<T>(tbl,name,options)

Type parameters

NameType
Tnumber[]

Parameters

NameType
tblany
namestring
optionsConnectionOptions

Defined in

index.ts:900

new LocalTable\<T>(tbl,name,options,embeddings)

Type parameters

NameType
Tnumber[]

Parameters

NameTypeDescription
tblany
namestring
optionsConnectionOptions
embeddingsEmbeddingFunction\<T>An embedding function to use when interacting with this table

Defined in

index.ts:907

Properties

_embeddings

PrivateOptionalReadonly_embeddings:EmbeddingFunction\<T>

Defined in

index.ts:897


_isElectron

PrivateReadonly_isElectron:boolean

Defined in

index.ts:896


_name

PrivateReadonly_name:string

Defined in

index.ts:895


_options

PrivateReadonly_options: () =>ConnectionOptions

Type declaration

▸ ():ConnectionOptions

Returns

ConnectionOptions

Defined in

index.ts:898


_tbl

Private_tbl:any

Defined in

index.ts:894


where

where: (value:string) =>Query\<T>

Type declaration

▸ (value):Query\<T>

Creates a filter query to find all rows matching the specified criteria

Parameters
NameTypeDescription
valuestringThe filter criteria (like SQL where clause syntax)
Returns

Query\<T>

Defined in

index.ts:946

Accessors

name

getname():string

Returns

string

Implementation of

Table.name

Defined in

index.ts:926


schema

getschema():Promise\<Schema\<any>>

Returns

Promise\<Schema\<any>>

Implementation of

Table.schema

Defined in

index.ts:1179

Methods

add

add(data):Promise\<number>

Insert records into this Table.

Parameters

NameTypeDescription
dataTable\<any> |Record\<string,unknown>[]Records to be inserted into the Table

Returns

Promise\<number>

The number of rows added to the table

Implementation of

Table.add

Defined in

index.ts:954


addColumns

addColumns(newColumnTransforms):Promise\<void>

Add new columns with defined values.

Parameters

NameTypeDescription
newColumnTransforms{name:string ;valueSql:string }[]pairs of column names and the SQL expression to use to calculate the value of the new column. These expressions will be evaluated for each row in the table, and can reference existing columns in the table.

Returns

Promise\<void>

Implementation of

Table.addColumns

Defined in

index.ts:1203


alterColumns

alterColumns(columnAlterations):Promise\<void>

Alter the name or nullability of columns.

Parameters

NameTypeDescription
columnAlterationsColumnAlteration[]One or more alterations to apply to columns.

Returns

Promise\<void>

Implementation of

Table.alterColumns

Defined in

index.ts:1209


checkElectron

PrivatecheckElectron():boolean

Returns

boolean

Defined in

index.ts:1191


cleanupOldVersions

cleanupOldVersions(olderThan?,deleteUnverified?):Promise\<CleanupStats>

Clean up old versions of the table, freeing disk space.

Parameters

NameTypeDescription
olderThan?numberThe minimum age in minutes of the versions to delete. If not provided, defaults to two weeks.
deleteUnverified?booleanBecause 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 totrue, 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

index.ts:1138


compactFiles

compactFiles(options?):Promise\<CompactionMetrics>

Run the compaction process on the table.

This can be run after making several small appends to optimize the tablefor faster reads.

Parameters

NameTypeDescription
options?CompactionOptionsAdvanced 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

index.ts:1161


countRows

countRows(filter?):Promise\<number>

Returns the number of rows in this table.

Parameters

NameType
filter?string

Returns

Promise\<number>

Implementation of

Table.countRows

Defined in

index.ts:1029


createIndex

createIndex(indexParams):Promise\<any>

Create an ANN index on this Table vector index.

Parameters

NameTypeDescription
indexParamsIvfPQIndexConfigThe parameters of this Index,

Returns

Promise\<any>

See

VectorIndexParams.

Implementation of

Table.createIndex

Defined in

index.ts:1011


createScalarIndex

createScalarIndex(column,replace?):Promise\<void>

Create a scalar index on this Table for the given column

Parameters

NameTypeDescription
columnstringThe column to index
replace?booleanIf false, fail if an index already exists on the column it is always set to true for remote connections 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 columnmy_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 columnnot_indexed does not have a scalar index then the filtermy_col = 0 OR not_indexed = 1 will not be able to use any scalar index onmy_col.

Returns

Promise\<void>

Examples

constcon=awaitlancedb.connect('././lancedb')consttable=awaitcon.openTable('images')awaittable.createScalarIndex('my_col')

Implementation of

Table.createScalarIndex

Defined in

index.ts:1019


delete

delete(filter):Promise\<void>

Delete rows from this table.

Parameters

NameTypeDescription
filterstringA filter in the same format used by a sql WHERE clause.

Returns

Promise\<void>

Implementation of

Table.delete

Defined in

index.ts:1038


dropColumns

dropColumns(columnNames):Promise\<void>

Drop one or more columns from the dataset

This is a metadata-only operation and does not remove the data from theunderlying storage. In order to remove the data, you must subsequentlycallcompact_files to rewrite the data without the removed columns andthen callcleanup_files to remove the old files.

Parameters

NameTypeDescription
columnNamesstring[]The names of the columns to drop. These can be nested column references (e.g. "a.b.c") or top-level column names (e.g. "a").

Returns

Promise\<void>

Implementation of

Table.dropColumns

Defined in

index.ts:1213


dropIndex

dropIndex(indexName):Promise\<void>

Drop an index from the table

Parameters

NameTypeDescription
indexNamestringThe name of the index to drop

Returns

Promise\<void>

Implementation of

Table.dropIndex

Defined in

index.ts:1217


filter

filter(value):Query\<T>

Creates a filter query to find all rows matching the specified criteria

Parameters

NameTypeDescription
valuestringThe filter criteria (like SQL where clause syntax)

Returns

Query\<T>

Implementation of

Table.filter

Defined in

index.ts:942


getSchema

PrivategetSchema():Promise\<Schema\<any>>

Returns

Promise\<Schema\<any>>

Defined in

index.ts:1184


indexStats

indexStats(indexName):Promise\<IndexStats>

Get statistics about an index.

Parameters

NameType
indexNamestring

Returns

Promise\<IndexStats>

Implementation of

Table.indexStats

Defined in

index.ts:1175


listIndices

listIndices():Promise\<VectorIndex[]>

List the indicies on this table.

Returns

Promise\<VectorIndex[]>

Implementation of

Table.listIndices

Defined in

index.ts:1171


mergeInsert

mergeInsert(on,data,args):Promise\<void>

Runs a "merge insert" operation on the table

This operation can add rows, update rows, and remove rows all in a singletransaction. It is a very generic tool that can be used to createbehaviors like "insert if not exists", "update or insert (i.e. upsert)",or even replace a portion of existing data with new data (e.g. replaceall data where month="january")

The merge insert operation works by combining new data from asource table with existing data in atarget table by using ajoin. There are three categories of records.

"Matched" records are records that exist in both the source table andthe target table. "Not matched" records exist only in the source table(e.g. these are new data) "Not matched by source" records exist onlyin the target table (this is old data)

The MergeInsertArgs can be used to customize what should happen foreach category of data.

Please note that the data may appear to be reordered as part of thisoperation. This is because updated rows will be deleted from thedataset and then reinserted at the end with the new values.

Parameters

NameTypeDescription
onstringa column to join on. This is how records from the source table and target table are matched.
dataTable\<any> |Record\<string,unknown>[]the new data to insert
argsMergeInsertArgsparameters controlling how the operation should behave

Returns

Promise\<void>

Implementation of

Table.mergeInsert

Defined in

index.ts:1073


overwrite

overwrite(data):Promise\<number>

Insert records into this Table, replacing its contents.

Parameters

NameTypeDescription
dataTable\<any> |Record\<string,unknown>[]Records to be inserted into the Table

Returns

Promise\<number>

The number of rows added to the table

Implementation of

Table.overwrite

Defined in

index.ts:985


search

search(query):Query\<T>

Creates a search query to find the nearest neighbors of the given search term

Parameters

NameTypeDescription
queryTThe query search term

Returns

Query\<T>

Implementation of

Table.search

Defined in

index.ts:934


update

update(args):Promise\<void>

Update rows in this table.

Parameters

NameTypeDescription
argsUpdateArgs |UpdateSqlArgsseeUpdateArgs andUpdateSqlArgs for more details

Returns

Promise\<void>

Implementation of

Table.update

Defined in

index.ts:1051


withMiddleware

withMiddleware(middleware):Table\<T>

Instrument the behavior of this Table with middleware.

The middleware will be called in the order they are added.

Currently this functionality is only supported for remote tables.

Parameters

NameType
middlewareHttpMiddleware

Returns

Table\<T>

  • this Table instrumented by the passed middleware

Implementation of

Table.withMiddleware

Defined in

index.ts:1221


[8]ページ先頭

©2009-2025 Movatter.jp