Compare commits

..

4 Commits

Author SHA1 Message Date
qzhu
1023a5754b separate local and cloud connect 2024-01-31 11:33:02 -08:00
qzhu
7808f28ec7 exclude storage.js for tests 2024-01-25 17:08:27 -08:00
qzhu
157fb9ea72 fix lint 2024-01-25 16:29:06 -08:00
qzhu
7a5e65d437 website api doc rework 2024-01-25 16:16:50 -08:00
59 changed files with 1193 additions and 886 deletions

View File

@@ -1,5 +1,5 @@
[bumpversion] [bumpversion]
current_version = 0.4.6 current_version = 0.4.4
commit = True commit = True
message = Bump version: {current_version} → {new_version} message = Bump version: {current_version} → {new_version}
tag = True tag = True

View File

@@ -61,6 +61,7 @@ jobs:
working-directory: node working-directory: node
run: | run: |
npx typedoc --plugin typedoc-plugin-markdown --out ../docs/src/javascript src/index.ts npx typedoc --plugin typedoc-plugin-markdown --out ../docs/src/javascript src/index.ts
cp ../docs/src/javascript.md ../docs/src/javascript/javascript.md
- name: Build docs - name: Build docs
run: | run: |
PYTHONPATH=. mkdocs build -f docs/mkdocs.yml PYTHONPATH=. mkdocs build -f docs/mkdocs.yml
@@ -72,4 +73,4 @@ jobs:
path: "docs/site" path: "docs/site"
- name: Deploy to GitHub Pages - name: Deploy to GitHub Pages
id: deployment id: deployment
uses: actions/deploy-pages@v1 uses: actions/deploy-pages@v1

View File

@@ -129,12 +129,9 @@ nav:
- 💭 FAQs: faq.md - 💭 FAQs: faq.md
- ⚙️ API reference: - ⚙️ API reference:
- 🐍 Python: python/python.md - 🐍 Python: python/python.md
- 👾 JavaScript: javascript/modules.md - 👾 JavaScript: javascript/javascript.md
- ☁️ LanceDB Cloud: - ☁️ LanceDB Cloud:
- Overview: cloud/index.md - Overview: cloud/index.md
- API reference:
- 🐍 Python: python/saas-python.md
- 👾 JavaScript: javascript/saas-modules.md
- Quick start: basic.md - Quick start: basic.md
@@ -184,12 +181,9 @@ nav:
- TransformersJS Embedding Search: examples/transformerjs_embedding_search_nodejs.md - TransformersJS Embedding Search: examples/transformerjs_embedding_search_nodejs.md
- API reference: - API reference:
- Python: python/python.md - Python: python/python.md
- Javascript: javascript/modules.md - Javascript: javascript/javascript.md
- LanceDB Cloud: - LanceDB Cloud:
- Overview: cloud/index.md - Overview: cloud/index.md
- API reference:
- 🐍 Python: python/saas-python.md
- 👾 JavaScript: javascript/saas-modules.md
extra_css: extra_css:
- styles/global.css - styles/global.css

62
docs/src/javascript.md Normal file
View File

@@ -0,0 +1,62 @@
# Javascript API Reference
This section contains the API reference for LanceDB Javascript API.
## Installation
```bash
npm install vectordb
```
This will download the appropriate native library for your platform. We currently
support:
* Linux (x86_64 and aarch64)
* MacOS (Intel and ARM/M1/M2)
* Windows (x86_64 only)
We do not yet support musl-based Linux (such as Alpine Linux) or arch64 Windows.
## Usage
### Basic Example
Connect to a local directory
```javascript
const lancedb = require('vectordb');
//connect to a local database
const db = await lancedb.connect('data/sample-lancedb');
```
Connect to LancdDB cloud
```javascript
connect to LanceDB Cloud
const db = await lancedb.connect({
uri: "db://my-database",
apiKey: "sk_...",
region: "us-east-1"
});
```
Create a table followed by a search
```javascript
const table = await db.createTable("my_table",
[{ id: 1, vector: [0.1, 1.0], item: "foo", price: 10.0 },
{ id: 2, vector: [3.9, 0.5], item: "bar", price: 20.0 }])
const results = await table.search([0.1, 0.3]).limit(20).execute();
console.log(results);
```
The [examples](./examples) folder contains complete examples.
## Table of contents
### Connection
Connect to a LanceDB database.
- [Connection](interfaces/Connection.md)
### Table
A Table is a collection of Records in a LanceDB Database.
- [Table](interfaces/Table.md)
### Query
The LanceDB Query
- [Query](classes/Query.md)

View File

@@ -38,4 +38,4 @@ A [WriteMode](../enums/WriteMode.md) to use on this operation
#### Defined in #### Defined in
[index.ts:1019](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L1019) [index.ts:1070](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L1070)

View File

@@ -46,7 +46,7 @@ A connection to a LanceDB database.
#### Defined in #### Defined in
[index.ts:489](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L489) [index.ts:496](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L496)
## Properties ## Properties
@@ -56,7 +56,7 @@ A connection to a LanceDB database.
#### Defined in #### Defined in
[index.ts:487](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L487) [index.ts:494](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L494)
___ ___
@@ -74,7 +74,7 @@ ___
#### Defined in #### Defined in
[index.ts:486](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L486) [index.ts:493](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L493)
## Accessors ## Accessors
@@ -92,7 +92,7 @@ ___
#### Defined in #### Defined in
[index.ts:494](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L494) [index.ts:501](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L501)
## Methods ## Methods
@@ -113,7 +113,7 @@ Creates a new Table, optionally initializing it with new data.
| Name | Type | | Name | Type |
| :------ | :------ | | :------ | :------ |
| `name` | `string` \| [`CreateTableOptions`](../interfaces/CreateTableOptions.md)\<`T`\> | | `name` | `string` \| [`CreateTableOptions`](../interfaces/CreateTableOptions.md)\<`T`\> |
| `data?` | `Record`\<`string`, `unknown`\>[] | | `data?` | `Table`\<`any`\> \| `Record`\<`string`, `unknown`\>[] |
| `optsOrEmbedding?` | [`WriteOptions`](../interfaces/WriteOptions.md) \| [`EmbeddingFunction`](../interfaces/EmbeddingFunction.md)\<`T`\> | | `optsOrEmbedding?` | [`WriteOptions`](../interfaces/WriteOptions.md) \| [`EmbeddingFunction`](../interfaces/EmbeddingFunction.md)\<`T`\> |
| `opt?` | [`WriteOptions`](../interfaces/WriteOptions.md) | | `opt?` | [`WriteOptions`](../interfaces/WriteOptions.md) |
@@ -127,7 +127,7 @@ Creates a new Table, optionally initializing it with new data.
#### Defined in #### Defined in
[index.ts:542](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L542) [index.ts:549](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L549)
___ ___
@@ -158,7 +158,7 @@ ___
#### Defined in #### Defined in
[index.ts:576](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L576) [index.ts:583](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L583)
___ ___
@@ -184,7 +184,7 @@ Drop an existing table.
#### Defined in #### Defined in
[index.ts:630](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L630) [index.ts:637](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L637)
___ ___
@@ -210,7 +210,7 @@ Open a table in the database.
#### Defined in #### Defined in
[index.ts:510](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L510) [index.ts:517](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L517)
**openTable**\<`T`\>(`name`, `embeddings`): `Promise`\<[`Table`](../interfaces/Table.md)\<`T`\>\> **openTable**\<`T`\>(`name`, `embeddings`): `Promise`\<[`Table`](../interfaces/Table.md)\<`T`\>\>
@@ -239,7 +239,7 @@ Connection.openTable
#### Defined in #### Defined in
[index.ts:518](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L518) [index.ts:525](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L525)
**openTable**\<`T`\>(`name`, `embeddings?`): `Promise`\<[`Table`](../interfaces/Table.md)\<`T`\>\> **openTable**\<`T`\>(`name`, `embeddings?`): `Promise`\<[`Table`](../interfaces/Table.md)\<`T`\>\>
@@ -266,7 +266,7 @@ Connection.openTable
#### Defined in #### Defined in
[index.ts:522](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L522) [index.ts:529](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L529)
___ ___
@@ -286,4 +286,4 @@ Get the names of all tables in the database.
#### Defined in #### Defined in
[index.ts:501](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L501) [index.ts:508](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L508)

View File

@@ -74,7 +74,7 @@ A LanceDB Table is the collection of Records. Each Record has one or more vector
#### Defined in #### Defined in
[index.ts:642](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L642) [index.ts:649](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L649)
**new LocalTable**\<`T`\>(`tbl`, `name`, `options`, `embeddings`) **new LocalTable**\<`T`\>(`tbl`, `name`, `options`, `embeddings`)
@@ -95,7 +95,7 @@ A LanceDB Table is the collection of Records. Each Record has one or more vector
#### Defined in #### Defined in
[index.ts:649](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L649) [index.ts:656](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L656)
## Properties ## Properties
@@ -105,7 +105,7 @@ A LanceDB Table is the collection of Records. Each Record has one or more vector
#### Defined in #### Defined in
[index.ts:639](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L639) [index.ts:646](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L646)
___ ___
@@ -115,7 +115,7 @@ ___
#### Defined in #### Defined in
[index.ts:638](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L638) [index.ts:645](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L645)
___ ___
@@ -125,7 +125,7 @@ ___
#### Defined in #### Defined in
[index.ts:637](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L637) [index.ts:644](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L644)
___ ___
@@ -143,7 +143,7 @@ ___
#### Defined in #### Defined in
[index.ts:640](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L640) [index.ts:647](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L647)
___ ___
@@ -153,7 +153,7 @@ ___
#### Defined in #### Defined in
[index.ts:636](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L636) [index.ts:643](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L643)
___ ___
@@ -179,7 +179,7 @@ Creates a filter query to find all rows matching the specified criteria
#### Defined in #### Defined in
[index.ts:688](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L688) [index.ts:695](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L695)
## Accessors ## Accessors
@@ -197,7 +197,7 @@ Creates a filter query to find all rows matching the specified criteria
#### Defined in #### Defined in
[index.ts:668](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L668) [index.ts:675](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L675)
___ ___
@@ -215,7 +215,7 @@ ___
#### Defined in #### Defined in
[index.ts:849](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L849) [index.ts:875](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L875)
## Methods ## Methods
@@ -229,7 +229,7 @@ Insert records into this Table.
| Name | Type | Description | | Name | Type | Description |
| :------ | :------ | :------ | | :------ | :------ | :------ |
| `data` | `Record`\<`string`, `unknown`\>[] | Records to be inserted into the Table | | `data` | `Table`\<`any`\> \| `Record`\<`string`, `unknown`\>[] | Records to be inserted into the Table |
#### Returns #### Returns
@@ -243,7 +243,7 @@ The number of rows added to the table
#### Defined in #### Defined in
[index.ts:696](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L696) [index.ts:703](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L703)
___ ___
@@ -257,7 +257,7 @@ ___
#### Defined in #### Defined in
[index.ts:861](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L861) [index.ts:887](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L887)
___ ___
@@ -267,6 +267,8 @@ ___
Clean up old versions of the table, freeing disk space. Clean up old versions of the table, freeing disk space.
Note: this API is not yet available on LanceDB Cloud
#### Parameters #### Parameters
| Name | Type | Description | | Name | Type | Description |
@@ -280,7 +282,7 @@ Clean up old versions of the table, freeing disk space.
#### Defined in #### Defined in
[index.ts:808](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L808) [index.ts:833](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L833)
___ ___
@@ -293,6 +295,8 @@ Run the compaction process on the table.
This can be run after making several small appends to optimize the table This can be run after making several small appends to optimize the table
for faster reads. for faster reads.
Note: this API is not yet available on LanceDB Cloud
#### Parameters #### Parameters
| Name | Type | Description | | Name | Type | Description |
@@ -307,7 +311,7 @@ Metrics about the compaction operation.
#### Defined in #### Defined in
[index.ts:831](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L831) [index.ts:857](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L857)
___ ___
@@ -327,7 +331,7 @@ Returns the number of rows in this table.
#### Defined in #### Defined in
[index.ts:749](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L749) [index.ts:773](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L773)
___ ___
@@ -357,7 +361,7 @@ VectorIndexParams.
#### Defined in #### Defined in
[index.ts:734](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L734) [index.ts:758](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L758)
___ ___
@@ -392,7 +396,7 @@ await table.createScalarIndex('my_col')
#### Defined in #### Defined in
[index.ts:742](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L742) [index.ts:766](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L766)
___ ___
@@ -418,7 +422,7 @@ Delete rows from this table.
#### Defined in #### Defined in
[index.ts:758](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L758) [index.ts:782](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L782)
___ ___
@@ -440,7 +444,7 @@ Creates a filter query to find all rows matching the specified criteria
#### Defined in #### Defined in
[index.ts:684](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L684) [index.ts:691](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L691)
___ ___
@@ -454,7 +458,7 @@ ___
#### Defined in #### Defined in
[index.ts:854](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L854) [index.ts:880](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L880)
___ ___
@@ -480,7 +484,7 @@ Get statistics about an index.
#### Defined in #### Defined in
[index.ts:845](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L845) [index.ts:871](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L871)
___ ___
@@ -500,7 +504,7 @@ List the indicies on this table.
#### Defined in #### Defined in
[index.ts:841](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L841) [index.ts:867](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L867)
___ ___
@@ -514,7 +518,7 @@ Insert records into this Table, replacing its contents.
| Name | Type | Description | | Name | Type | Description |
| :------ | :------ | :------ | | :------ | :------ | :------ |
| `data` | `Record`\<`string`, `unknown`\>[] | Records to be inserted into the Table | | `data` | `Table`\<`any`\> \| `Record`\<`string`, `unknown`\>[] | Records to be inserted into the Table Type Table is ArrowTable |
#### Returns #### Returns
@@ -528,7 +532,7 @@ The number of rows added to the table
#### Defined in #### Defined in
[index.ts:716](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L716) [index.ts:732](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L732)
___ ___
@@ -554,7 +558,7 @@ Creates a search query to find the nearest neighbors of the given search term
#### Defined in #### Defined in
[index.ts:676](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L676) [index.ts:683](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L683)
___ ___
@@ -580,4 +584,4 @@ Update rows in this table.
#### Defined in #### Defined in
[index.ts:771](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L771) [index.ts:795](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L795)

View File

@@ -0,0 +1,56 @@
[vectordb](../README.md) / [Exports](../modules.md) / MakeArrowTableOptions
# Class: MakeArrowTableOptions
Options to control the makeArrowTable call.
## Table of contents
### Constructors
- [constructor](MakeArrowTableOptions.md#constructor)
### Properties
- [schema](MakeArrowTableOptions.md#schema)
- [vectorColumns](MakeArrowTableOptions.md#vectorcolumns)
## Constructors
### constructor
**new MakeArrowTableOptions**(`values?`)
#### Parameters
| Name | Type |
| :------ | :------ |
| `values?` | `Partial`\<[`MakeArrowTableOptions`](MakeArrowTableOptions.md)\> |
#### Defined in
[arrow.ts:56](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/arrow.ts#L56)
## Properties
### schema
`Optional` **schema**: `Schema`\<`any`\>
Provided schema.
#### Defined in
[arrow.ts:49](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/arrow.ts#L49)
___
### vectorColumns
**vectorColumns**: `Record`\<`string`, `VectorColumnOptions`\>
Vector columns
#### Defined in
[arrow.ts:52](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/arrow.ts#L52)

View File

@@ -40,7 +40,7 @@ An embedding function that automatically creates vector representation for a giv
#### Defined in #### Defined in
[embedding/openai.ts:21](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/embedding/openai.ts#L21) [embedding/openai.ts:22](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/embedding/openai.ts#L22)
## Properties ## Properties
@@ -50,17 +50,17 @@ An embedding function that automatically creates vector representation for a giv
#### Defined in #### Defined in
[embedding/openai.ts:19](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/embedding/openai.ts#L19) [embedding/openai.ts:20](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/embedding/openai.ts#L20)
___ ___
### \_openai ### \_openai
`Private` `Readonly` **\_openai**: `any` `Private` `Readonly` **\_openai**: `OpenAI`
#### Defined in #### Defined in
[embedding/openai.ts:18](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/embedding/openai.ts#L18) [embedding/openai.ts:19](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/embedding/openai.ts#L19)
___ ___
@@ -76,7 +76,7 @@ The name of the column that will be used as input for the Embedding Function.
#### Defined in #### Defined in
[embedding/openai.ts:50](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/embedding/openai.ts#L50) [embedding/openai.ts:56](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/embedding/openai.ts#L56)
## Methods ## Methods
@@ -102,4 +102,4 @@ Creates a vector representation for the given values.
#### Defined in #### Defined in
[embedding/openai.ts:38](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/embedding/openai.ts#L38) [embedding/openai.ts:43](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/embedding/openai.ts#L43)

View File

@@ -65,7 +65,7 @@ A builder for nearest neighbor queries for LanceDB.
#### Defined in #### Defined in
[query.ts:38](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/query.ts#L38) [query.ts:38](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/query.ts#L38)
## Properties ## Properties
@@ -75,7 +75,7 @@ A builder for nearest neighbor queries for LanceDB.
#### Defined in #### Defined in
[query.ts:36](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/query.ts#L36) [query.ts:36](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/query.ts#L36)
___ ___
@@ -85,7 +85,7 @@ ___
#### Defined in #### Defined in
[query.ts:33](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/query.ts#L33) [query.ts:33](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/query.ts#L33)
___ ___
@@ -95,7 +95,7 @@ ___
#### Defined in #### Defined in
[query.ts:29](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/query.ts#L29) [query.ts:29](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/query.ts#L29)
___ ___
@@ -105,7 +105,7 @@ ___
#### Defined in #### Defined in
[query.ts:34](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/query.ts#L34) [query.ts:34](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/query.ts#L34)
___ ___
@@ -115,7 +115,7 @@ ___
#### Defined in #### Defined in
[query.ts:31](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/query.ts#L31) [query.ts:31](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/query.ts#L31)
___ ___
@@ -125,7 +125,7 @@ ___
#### Defined in #### Defined in
[query.ts:35](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/query.ts#L35) [query.ts:35](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/query.ts#L35)
___ ___
@@ -135,7 +135,7 @@ ___
#### Defined in #### Defined in
[query.ts:26](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/query.ts#L26) [query.ts:26](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/query.ts#L26)
___ ___
@@ -145,7 +145,7 @@ ___
#### Defined in #### Defined in
[query.ts:28](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/query.ts#L28) [query.ts:28](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/query.ts#L28)
___ ___
@@ -155,7 +155,7 @@ ___
#### Defined in #### Defined in
[query.ts:30](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/query.ts#L30) [query.ts:30](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/query.ts#L30)
___ ___
@@ -165,7 +165,7 @@ ___
#### Defined in #### Defined in
[query.ts:32](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/query.ts#L32) [query.ts:32](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/query.ts#L32)
___ ___
@@ -175,7 +175,7 @@ ___
#### Defined in #### Defined in
[query.ts:27](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/query.ts#L27) [query.ts:27](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/query.ts#L27)
___ ___
@@ -201,7 +201,7 @@ A filter statement to be applied to this query.
#### Defined in #### Defined in
[query.ts:87](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/query.ts#L87) [query.ts:87](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/query.ts#L87)
## Methods ## Methods
@@ -223,7 +223,7 @@ Execute the query and return the results as an Array of Objects
#### Defined in #### Defined in
[query.ts:115](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/query.ts#L115) [query.ts:115](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/query.ts#L115)
___ ___
@@ -245,7 +245,7 @@ A filter statement to be applied to this query.
#### Defined in #### Defined in
[query.ts:82](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/query.ts#L82) [query.ts:82](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/query.ts#L82)
___ ___
@@ -259,7 +259,7 @@ ___
#### Defined in #### Defined in
[query.ts:142](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/query.ts#L142) [query.ts:143](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/query.ts#L143)
___ ___
@@ -281,7 +281,7 @@ Sets the number of results that will be returned
#### Defined in #### Defined in
[query.ts:55](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/query.ts#L55) [query.ts:55](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/query.ts#L55)
___ ___
@@ -307,7 +307,7 @@ MetricType for the different options
#### Defined in #### Defined in
[query.ts:102](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/query.ts#L102) [query.ts:102](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/query.ts#L102)
___ ___
@@ -329,7 +329,7 @@ The number of probes used. A higher number makes search more accurate but also s
#### Defined in #### Defined in
[query.ts:73](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/query.ts#L73) [query.ts:73](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/query.ts#L73)
___ ___
@@ -349,7 +349,7 @@ ___
#### Defined in #### Defined in
[query.ts:107](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/query.ts#L107) [query.ts:107](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/query.ts#L107)
___ ___
@@ -371,7 +371,7 @@ Refine the results by reading extra elements and re-ranking them in memory.
#### Defined in #### Defined in
[query.ts:64](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/query.ts#L64) [query.ts:64](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/query.ts#L64)
___ ___
@@ -393,4 +393,4 @@ Return only the specified columns.
#### Defined in #### Defined in
[query.ts:93](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/query.ts#L93) [query.ts:93](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/query.ts#L93)

View File

@@ -0,0 +1,224 @@
[vectordb](../README.md) / [Exports](../modules.md) / RemoteConnection
# Class: RemoteConnection
Remote connection.
## Implements
- [`Connection`](../interfaces/Connection.md)
## Table of contents
### Constructors
- [constructor](RemoteConnection.md#constructor)
### Properties
- [\_client](RemoteConnection.md#_client)
- [\_dbName](RemoteConnection.md#_dbname)
### Accessors
- [uri](RemoteConnection.md#uri)
### Methods
- [createTable](RemoteConnection.md#createtable)
- [dropTable](RemoteConnection.md#droptable)
- [openTable](RemoteConnection.md#opentable)
- [tableNames](RemoteConnection.md#tablenames)
## Constructors
### constructor
**new RemoteConnection**(`opts`)
#### Parameters
| Name | Type |
| :------ | :------ |
| `opts` | [`ConnectionOptions`](../interfaces/ConnectionOptions.md) |
#### Defined in
[remote/index.ts:48](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L48)
## Properties
### \_client
`Private` `Readonly` **\_client**: `HttpLancedbClient`
#### Defined in
[remote/index.ts:45](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L45)
___
### \_dbName
`Private` `Readonly` **\_dbName**: `string`
#### Defined in
[remote/index.ts:46](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L46)
## Accessors
### uri
`get` **uri**(): `string`
#### Returns
`string`
#### Implementation of
[Connection](../interfaces/Connection.md).[uri](../interfaces/Connection.md#uri)
#### Defined in
[remote/index.ts:75](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L75)
## Methods
### createTable
**createTable**\<`T`\>(`nameOrOpts`, `data?`, `optsOrEmbedding?`, `opt?`): `Promise`\<[`Table`](../interfaces/Table.md)\<`T`\>\>
Creates a new Table, optionally initializing it with new data.
#### Type parameters
| Name |
| :------ |
| `T` |
#### Parameters
| Name | Type |
| :------ | :------ |
| `nameOrOpts` | `string` \| [`CreateTableOptions`](../interfaces/CreateTableOptions.md)\<`T`\> |
| `data?` | `Table`\<`any`\> \| `Record`\<`string`, `unknown`\>[] |
| `optsOrEmbedding?` | [`WriteOptions`](../interfaces/WriteOptions.md) \| [`EmbeddingFunction`](../interfaces/EmbeddingFunction.md)\<`T`\> |
| `opt?` | [`WriteOptions`](../interfaces/WriteOptions.md) |
#### Returns
`Promise`\<[`Table`](../interfaces/Table.md)\<`T`\>\>
#### Implementation of
[Connection](../interfaces/Connection.md).[createTable](../interfaces/Connection.md#createtable)
#### Defined in
[remote/index.ts:107](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L107)
___
### dropTable
**dropTable**(`name`): `Promise`\<`void`\>
Drop an existing table.
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `name` | `string` | The name of the table to drop. |
#### Returns
`Promise`\<`void`\>
#### Implementation of
[Connection](../interfaces/Connection.md).[dropTable](../interfaces/Connection.md#droptable)
#### Defined in
[remote/index.ts:175](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L175)
___
### openTable
**openTable**(`name`): `Promise`\<[`Table`](../interfaces/Table.md)\<`number`[]\>\>
Open a table in the database.
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `name` | `string` | The name of the table. |
#### Returns
`Promise`\<[`Table`](../interfaces/Table.md)\<`number`[]\>\>
#### Implementation of
[Connection](../interfaces/Connection.md).[openTable](../interfaces/Connection.md#opentable)
#### Defined in
[remote/index.ts:91](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L91)
**openTable**\<`T`\>(`name`, `embeddings`): `Promise`\<[`Table`](../interfaces/Table.md)\<`T`\>\>
#### Type parameters
| Name |
| :------ |
| `T` |
#### Parameters
| Name | Type |
| :------ | :------ |
| `name` | `string` |
| `embeddings` | [`EmbeddingFunction`](../interfaces/EmbeddingFunction.md)\<`T`\> |
#### Returns
`Promise`\<[`Table`](../interfaces/Table.md)\<`T`\>\>
#### Implementation of
Connection.openTable
#### Defined in
[remote/index.ts:92](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L92)
___
### tableNames
**tableNames**(`pageToken?`, `limit?`): `Promise`\<`string`[]\>
#### Parameters
| Name | Type | Default value |
| :------ | :------ | :------ |
| `pageToken` | `string` | `''` |
| `limit` | `number` | `10` |
#### Returns
`Promise`\<`string`[]\>
#### Implementation of
[Connection](../interfaces/Connection.md).[tableNames](../interfaces/Connection.md#tablenames)
#### Defined in
[remote/index.ts:80](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L80)

View File

@@ -0,0 +1,470 @@
[vectordb](../README.md) / [Exports](../modules.md) / RemoteTable
# Class: RemoteTable\<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`](../interfaces/Table.md)\<`T`\>
## Table of contents
### Constructors
- [constructor](RemoteTable.md#constructor)
### Properties
- [\_client](RemoteTable.md#_client)
- [\_embeddings](RemoteTable.md#_embeddings)
- [\_name](RemoteTable.md#_name)
### Accessors
- [name](RemoteTable.md#name)
- [schema](RemoteTable.md#schema)
### Methods
- [add](RemoteTable.md#add)
- [countRows](RemoteTable.md#countrows)
- [createIndex](RemoteTable.md#createindex)
- [createScalarIndex](RemoteTable.md#createscalarindex)
- [delete](RemoteTable.md#delete)
- [indexStats](RemoteTable.md#indexstats)
- [listIndices](RemoteTable.md#listindices)
- [overwrite](RemoteTable.md#overwrite)
- [search](RemoteTable.md#search)
- [update](RemoteTable.md#update)
## Constructors
### constructor
**new RemoteTable**\<`T`\>(`client`, `name`)
#### Type parameters
| Name | Type |
| :------ | :------ |
| `T` | `number`[] |
#### Parameters
| Name | Type |
| :------ | :------ |
| `client` | `HttpLancedbClient` |
| `name` | `string` |
#### Defined in
[remote/index.ts:234](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L234)
**new RemoteTable**\<`T`\>(`client`, `name`, `embeddings`)
#### Type parameters
| Name | Type |
| :------ | :------ |
| `T` | `number`[] |
#### Parameters
| Name | Type |
| :------ | :------ |
| `client` | `HttpLancedbClient` |
| `name` | `string` |
| `embeddings` | [`EmbeddingFunction`](../interfaces/EmbeddingFunction.md)\<`T`\> |
#### Defined in
[remote/index.ts:235](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L235)
## Properties
### \_client
`Private` `Readonly` **\_client**: `HttpLancedbClient`
#### Defined in
[remote/index.ts:230](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L230)
___
### \_embeddings
`Private` `Optional` `Readonly` **\_embeddings**: [`EmbeddingFunction`](../interfaces/EmbeddingFunction.md)\<`T`\>
#### Defined in
[remote/index.ts:231](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L231)
___
### \_name
`Private` `Readonly` **\_name**: `string`
#### Defined in
[remote/index.ts:232](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L232)
## Accessors
### name
`get` **name**(): `string`
#### Returns
`string`
#### Implementation of
[Table](../interfaces/Table.md).[name](../interfaces/Table.md#name)
#### Defined in
[remote/index.ts:250](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L250)
___
### schema
`get` **schema**(): `Promise`\<`any`\>
#### Returns
`Promise`\<`any`\>
#### Implementation of
[Table](../interfaces/Table.md).[schema](../interfaces/Table.md#schema)
#### Defined in
[remote/index.ts:254](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L254)
## Methods
### add
**add**(`data`): `Promise`\<`number`\>
Insert records into this Table.
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `data` | `Table`\<`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](../interfaces/Table.md).[add](../interfaces/Table.md#add)
#### Defined in
[remote/index.ts:273](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L273)
___
### countRows
**countRows**(): `Promise`\<`number`\>
Returns the number of rows in this table.
#### Returns
`Promise`\<`number`\>
#### Implementation of
[Table](../interfaces/Table.md).[countRows](../interfaces/Table.md#countrows)
#### Defined in
[remote/index.ts:372](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L372)
___
### createIndex
**createIndex**(`indexParams`): `Promise`\<`void`\>
Create an ANN index on this Table vector index.
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `indexParams` | [`IvfPQIndexConfig`](../interfaces/IvfPQIndexConfig.md) | The parameters of this Index, |
#### Returns
`Promise`\<`void`\>
**`See`**
VectorIndexParams.
#### Implementation of
[Table](../interfaces/Table.md).[createIndex](../interfaces/Table.md#createindex)
#### Defined in
[remote/index.ts:326](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L326)
___
### 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`**
```ts
const con = await lancedb.connect('././lancedb')
const table = await con.openTable('images')
await table.createScalarIndex('my_col')
```
#### Implementation of
[Table](../interfaces/Table.md).[createScalarIndex](../interfaces/Table.md#createscalarindex)
#### Defined in
[remote/index.ts:368](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L368)
___
### delete
▸ **delete**(`filter`): `Promise`\<`void`\>
Delete rows from this table.
This can be used to delete a single row, many rows, all rows, or
sometimes no rows (if your predicate matches nothing).
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `filter` | `string` | A filter in the same format used by a sql WHERE clause. The filter must not be empty. |
#### Returns
`Promise`\<`void`\>
**`Examples`**
```ts
const con = await lancedb.connect("./.lancedb")
const data = [
{id: 1, vector: [1, 2]},
{id: 2, vector: [3, 4]},
{id: 3, vector: [5, 6]},
];
const tbl = await con.createTable("my_table", data)
await tbl.delete("id = 2")
await tbl.countRows() // Returns 2
```
If you have a list of values to delete, you can combine them into a
stringified list and use the `IN` operator:
```ts
const to_remove = [1, 5];
await tbl.delete(`id IN (${to_remove.join(",")})`)
await tbl.countRows() // Returns 1
```
#### Implementation of
[Table](../interfaces/Table.md).[delete](../interfaces/Table.md#delete)
#### Defined in
[remote/index.ts:377](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L377)
___
### indexStats
▸ **indexStats**(`indexUuid`): `Promise`\<[`IndexStats`](../interfaces/IndexStats.md)\>
Get statistics about an index.
#### Parameters
| Name | Type |
| :------ | :------ |
| `indexUuid` | `string` |
#### Returns
`Promise`\<[`IndexStats`](../interfaces/IndexStats.md)\>
#### Implementation of
[Table](../interfaces/Table.md).[indexStats](../interfaces/Table.md#indexstats)
#### Defined in
[remote/index.ts:414](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L414)
___
### listIndices
▸ **listIndices**(): `Promise`\<[`VectorIndex`](../interfaces/VectorIndex.md)[]\>
List the indicies on this table.
#### Returns
`Promise`\<[`VectorIndex`](../interfaces/VectorIndex.md)[]\>
#### Implementation of
[Table](../interfaces/Table.md).[listIndices](../interfaces/Table.md#listindices)
#### Defined in
[remote/index.ts:403](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L403)
___
### overwrite
▸ **overwrite**(`data`): `Promise`\<`number`\>
Insert records into this Table, replacing its contents.
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `data` | `Table`\<`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](../interfaces/Table.md).[overwrite](../interfaces/Table.md#overwrite)
#### Defined in
[remote/index.ts:300](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L300)
___
### search
▸ **search**(`query`): [`Query`](Query.md)\<`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`](Query.md)\<`T`\>
#### Implementation of
[Table](../interfaces/Table.md).[search](../interfaces/Table.md#search)
#### Defined in
[remote/index.ts:269](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L269)
___
### update
▸ **update**(`args`): `Promise`\<`void`\>
Update rows in this table.
This can be used to update a single row, many rows, all rows, or
sometimes no rows (if your predicate matches nothing).
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `args` | [`UpdateArgs`](../interfaces/UpdateArgs.md) \| [`UpdateSqlArgs`](../interfaces/UpdateSqlArgs.md) | see [UpdateArgs](../interfaces/UpdateArgs.md) and [UpdateSqlArgs](../interfaces/UpdateSqlArgs.md) for more details |
#### Returns
`Promise`\<`void`\>
**`Examples`**
```ts
const con = await lancedb.connect("./.lancedb")
const data = [
{id: 1, vector: [3, 3], name: 'Ye'},
{id: 2, vector: [4, 4], name: 'Mike'},
];
const tbl = await con.createTable("my_table", data)
await tbl.update({
where: "id = 2",
values: { vector: [2, 2], name: "Michael" },
})
let results = await tbl.search([1, 1]).execute();
// Returns [
// {id: 2, vector: [2, 2], name: 'Michael'}
// {id: 1, vector: [3, 3], name: 'Ye'}
// ]
```
#### Implementation of
[Table](../interfaces/Table.md).[update](../interfaces/Table.md#update)
#### Defined in
[remote/index.ts:383](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/remote/index.ts#L383)

View File

@@ -22,7 +22,7 @@ Cosine distance
#### Defined in #### Defined in
[index.ts:1041](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L1041) [index.ts:1092](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L1092)
___ ___
@@ -34,7 +34,7 @@ Dot product
#### Defined in #### Defined in
[index.ts:1046](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L1046) [index.ts:1097](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L1097)
___ ___
@@ -46,4 +46,4 @@ Euclidean distance
#### Defined in #### Defined in
[index.ts:1036](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L1036) [index.ts:1087](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L1087)

View File

@@ -22,7 +22,7 @@ Append new data to the table.
#### Defined in #### Defined in
[index.ts:1007](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L1007) [index.ts:1058](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L1058)
___ ___
@@ -34,7 +34,7 @@ Create a new [Table](../interfaces/Table.md).
#### Defined in #### Defined in
[index.ts:1003](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L1003) [index.ts:1054](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L1054)
___ ___
@@ -46,4 +46,4 @@ Overwrite the existing [Table](../interfaces/Table.md) if presented.
#### Defined in #### Defined in
[index.ts:1005](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L1005) [index.ts:1056](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L1056)

View File

@@ -18,7 +18,7 @@
#### Defined in #### Defined in
[index.ts:54](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L54) [index.ts:57](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L57)
___ ___
@@ -28,7 +28,7 @@ ___
#### Defined in #### Defined in
[index.ts:56](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L56) [index.ts:59](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L59)
___ ___
@@ -38,4 +38,4 @@ ___
#### Defined in #### Defined in
[index.ts:58](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L58) [index.ts:61](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L61)

View File

@@ -19,7 +19,7 @@ The number of bytes removed from disk.
#### Defined in #### Defined in
[index.ts:878](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L878) [index.ts:904](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L904)
___ ___
@@ -31,4 +31,4 @@ The number of old table versions removed.
#### Defined in #### Defined in
[index.ts:882](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L882) [index.ts:908](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L908)

View File

@@ -22,7 +22,7 @@ fragments added.
#### Defined in #### Defined in
[index.ts:933](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L933) [index.ts:959](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L959)
___ ___
@@ -35,7 +35,7 @@ file.
#### Defined in #### Defined in
[index.ts:928](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L928) [index.ts:954](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L954)
___ ___
@@ -47,7 +47,7 @@ The number of new fragments that were created.
#### Defined in #### Defined in
[index.ts:923](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L923) [index.ts:949](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L949)
___ ___
@@ -59,4 +59,4 @@ The number of fragments that were removed.
#### Defined in #### Defined in
[index.ts:919](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L919) [index.ts:945](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L945)

View File

@@ -24,7 +24,7 @@ Default is true.
#### Defined in #### Defined in
[index.ts:901](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L901) [index.ts:927](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L927)
___ ___
@@ -38,7 +38,7 @@ the deleted rows. Default is 10%.
#### Defined in #### Defined in
[index.ts:907](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L907) [index.ts:933](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L933)
___ ___
@@ -50,7 +50,7 @@ The maximum number of rows per group. Defaults to 1024.
#### Defined in #### Defined in
[index.ts:895](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L895) [index.ts:921](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L921)
___ ___
@@ -63,7 +63,7 @@ the number of cores on the machine.
#### Defined in #### Defined in
[index.ts:912](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L912) [index.ts:938](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L938)
___ ___
@@ -77,4 +77,4 @@ Defaults to 1024 * 1024.
#### Defined in #### Defined in
[index.ts:891](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L891) [index.ts:917](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L917)

View File

@@ -9,6 +9,7 @@ Connection could be local against filesystem or remote against a server.
## Implemented by ## Implemented by
- [`LocalConnection`](../classes/LocalConnection.md) - [`LocalConnection`](../classes/LocalConnection.md)
- [`RemoteConnection`](../classes/RemoteConnection.md)
## Table of contents ## Table of contents
@@ -31,7 +32,7 @@ Connection could be local against filesystem or remote against a server.
#### Defined in #### Defined in
[index.ts:183](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L183) [index.ts:188](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L188)
## Methods ## Methods
@@ -59,7 +60,7 @@ Creates a new Table, optionally initializing it with new data.
#### Defined in #### Defined in
[index.ts:207](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L207) [index.ts:212](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L212)
**createTable**(`name`, `data`): `Promise`\<[`Table`](Table.md)\<`number`[]\>\> **createTable**(`name`, `data`): `Promise`\<[`Table`](Table.md)\<`number`[]\>\>
@@ -70,7 +71,7 @@ Creates a new Table and initialize it with new data.
| Name | Type | Description | | Name | Type | Description |
| :------ | :------ | :------ | | :------ | :------ | :------ |
| `name` | `string` | The name of the table. | | `name` | `string` | The name of the table. |
| `data` | `Record`\<`string`, `unknown`\>[] | Non-empty Array of Records to be inserted into the table | | `data` | `Table`\<`any`\> \| `Record`\<`string`, `unknown`\>[] | Non-empty Array of Records to be inserted into the table |
#### Returns #### Returns
@@ -78,7 +79,7 @@ Creates a new Table and initialize it with new data.
#### Defined in #### Defined in
[index.ts:221](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L221) [index.ts:226](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L226)
**createTable**(`name`, `data`, `options`): `Promise`\<[`Table`](Table.md)\<`number`[]\>\> **createTable**(`name`, `data`, `options`): `Promise`\<[`Table`](Table.md)\<`number`[]\>\>
@@ -89,7 +90,7 @@ Creates a new Table and initialize it with new data.
| Name | Type | Description | | Name | Type | Description |
| :------ | :------ | :------ | | :------ | :------ | :------ |
| `name` | `string` | The name of the table. | | `name` | `string` | The name of the table. |
| `data` | `Record`\<`string`, `unknown`\>[] | Non-empty Array of Records to be inserted into the table | | `data` | `Table`\<`any`\> \| `Record`\<`string`, `unknown`\>[] | Non-empty Array of Records to be inserted into the table |
| `options` | [`WriteOptions`](WriteOptions.md) | The write options to use when creating the table. | | `options` | [`WriteOptions`](WriteOptions.md) | The write options to use when creating the table. |
#### Returns #### Returns
@@ -98,7 +99,7 @@ Creates a new Table and initialize it with new data.
#### Defined in #### Defined in
[index.ts:233](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L233) [index.ts:238](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L238)
**createTable**\<`T`\>(`name`, `data`, `embeddings`): `Promise`\<[`Table`](Table.md)\<`T`\>\> **createTable**\<`T`\>(`name`, `data`, `embeddings`): `Promise`\<[`Table`](Table.md)\<`T`\>\>
@@ -115,7 +116,7 @@ Creates a new Table and initialize it with new data.
| Name | Type | Description | | Name | Type | Description |
| :------ | :------ | :------ | | :------ | :------ | :------ |
| `name` | `string` | The name of the table. | | `name` | `string` | The name of the table. |
| `data` | `Record`\<`string`, `unknown`\>[] | Non-empty Array of Records to be inserted into the table | | `data` | `Table`\<`any`\> \| `Record`\<`string`, `unknown`\>[] | Non-empty Array of Records to be inserted into the table |
| `embeddings` | [`EmbeddingFunction`](EmbeddingFunction.md)\<`T`\> | An embedding function to use on this table | | `embeddings` | [`EmbeddingFunction`](EmbeddingFunction.md)\<`T`\> | An embedding function to use on this table |
#### Returns #### Returns
@@ -124,7 +125,7 @@ Creates a new Table and initialize it with new data.
#### Defined in #### Defined in
[index.ts:246](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L246) [index.ts:251](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L251)
**createTable**\<`T`\>(`name`, `data`, `embeddings`, `options`): `Promise`\<[`Table`](Table.md)\<`T`\>\> **createTable**\<`T`\>(`name`, `data`, `embeddings`, `options`): `Promise`\<[`Table`](Table.md)\<`T`\>\>
@@ -141,7 +142,7 @@ Creates a new Table and initialize it with new data.
| Name | Type | Description | | Name | Type | Description |
| :------ | :------ | :------ | | :------ | :------ | :------ |
| `name` | `string` | The name of the table. | | `name` | `string` | The name of the table. |
| `data` | `Record`\<`string`, `unknown`\>[] | Non-empty Array of Records to be inserted into the table | | `data` | `Table`\<`any`\> \| `Record`\<`string`, `unknown`\>[] | Non-empty Array of Records to be inserted into the table |
| `embeddings` | [`EmbeddingFunction`](EmbeddingFunction.md)\<`T`\> | An embedding function to use on this table | | `embeddings` | [`EmbeddingFunction`](EmbeddingFunction.md)\<`T`\> | An embedding function to use on this table |
| `options` | [`WriteOptions`](WriteOptions.md) | The write options to use when creating the table. | | `options` | [`WriteOptions`](WriteOptions.md) | The write options to use when creating the table. |
@@ -151,7 +152,7 @@ Creates a new Table and initialize it with new data.
#### Defined in #### Defined in
[index.ts:259](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L259) [index.ts:264](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L264)
___ ___
@@ -173,7 +174,7 @@ Drop an existing table.
#### Defined in #### Defined in
[index.ts:270](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L270) [index.ts:275](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L275)
___ ___
@@ -202,7 +203,7 @@ Open a table in the database.
#### Defined in #### Defined in
[index.ts:193](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L193) [index.ts:198](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L198)
___ ___
@@ -216,4 +217,4 @@ ___
#### Defined in #### Defined in
[index.ts:185](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L185) [index.ts:190](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L190)

View File

@@ -19,9 +19,13 @@
`Optional` **apiKey**: `string` `Optional` **apiKey**: `string`
API key for the remote connections
Can also be passed by setting environment variable `LANCEDB_API_KEY`
#### Defined in #### Defined in
[index.ts:81](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L81) [index.ts:88](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L88)
___ ___
@@ -35,7 +39,7 @@ If not provided, LanceDB will use the default credentials provider chain.
#### Defined in #### Defined in
[index.ts:75](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L75) [index.ts:78](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L78)
___ ___
@@ -47,7 +51,7 @@ AWS region to connect to. Default is defaultAwsRegion.
#### Defined in #### Defined in
[index.ts:78](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L78) [index.ts:81](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L81)
___ ___
@@ -55,13 +59,13 @@ ___
`Optional` **hostOverride**: `string` `Optional` **hostOverride**: `string`
Override the host URL for the remote connections. Override the host URL for the remote connection.
This is useful for local testing. This is useful for local testing.
#### Defined in #### Defined in
[index.ts:91](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L91) [index.ts:98](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L98)
___ ___
@@ -73,7 +77,7 @@ Region to connect
#### Defined in #### Defined in
[index.ts:84](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L84) [index.ts:91](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L91)
___ ___
@@ -85,8 +89,8 @@ LanceDB database URI.
- `/path/to/database` - local database - `/path/to/database` - local database
- `s3://bucket/path/to/database` or `gs://bucket/path/to/database` - database on cloud storage - `s3://bucket/path/to/database` or `gs://bucket/path/to/database` - database on cloud storage
- `db://host:port` - remote database (SaaS) - `db://host:port` - remote database (LanceDB cloud)
#### Defined in #### Defined in
[index.ts:69](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L69) [index.ts:72](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L72)

View File

@@ -26,7 +26,7 @@
#### Defined in #### Defined in
[index.ts:116](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L116) [index.ts:121](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L121)
___ ___
@@ -36,7 +36,7 @@ ___
#### Defined in #### Defined in
[index.ts:122](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L122) [index.ts:127](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L127)
___ ___
@@ -46,7 +46,7 @@ ___
#### Defined in #### Defined in
[index.ts:113](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L113) [index.ts:118](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L118)
___ ___
@@ -56,7 +56,7 @@ ___
#### Defined in #### Defined in
[index.ts:119](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L119) [index.ts:124](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L124)
___ ___
@@ -66,4 +66,4 @@ ___
#### Defined in #### Defined in
[index.ts:125](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L125) [index.ts:130](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L130)

View File

@@ -45,7 +45,7 @@ Creates a vector representation for the given values.
#### Defined in #### Defined in
[embedding/embedding_function.ts:27](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/embedding/embedding_function.ts#L27) [embedding/embedding_function.ts:27](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/embedding/embedding_function.ts#L27)
___ ___
@@ -57,4 +57,4 @@ The name of the column that will be used as input for the Embedding Function.
#### Defined in #### Defined in
[embedding/embedding_function.ts:22](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/embedding/embedding_function.ts#L22) [embedding/embedding_function.ts:22](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/embedding/embedding_function.ts#L22)

View File

@@ -17,7 +17,7 @@
#### Defined in #### Defined in
[index.ts:478](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L478) [index.ts:485](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L485)
___ ___
@@ -27,4 +27,4 @@ ___
#### Defined in #### Defined in
[index.ts:479](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L479) [index.ts:486](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L486)

View File

@@ -29,7 +29,7 @@ The column to be indexed
#### Defined in #### Defined in
[index.ts:942](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L942) [index.ts:968](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L968)
___ ___
@@ -41,7 +41,7 @@ Cache size of the index
#### Defined in #### Defined in
[index.ts:991](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L991) [index.ts:1042](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L1042)
___ ___
@@ -49,11 +49,11 @@ ___
`Optional` **index\_name**: `string` `Optional` **index\_name**: `string`
A unique name for the index Note: this parameter is not supported on LanceDB Cloud
#### Defined in #### Defined in
[index.ts:947](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L947) [index.ts:976](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L976)
___ ___
@@ -61,11 +61,11 @@ ___
`Optional` **max\_iters**: `number` `Optional` **max\_iters**: `number`
The max number of iterations for kmeans training. Note: this parameter is not yet supported on LanceDB Cloud
#### Defined in #### Defined in
[index.ts:962](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L962) [index.ts:997](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L997)
___ ___
@@ -73,11 +73,11 @@ ___
`Optional` **max\_opq\_iters**: `number` `Optional` **max\_opq\_iters**: `number`
Max number of iterations to train OPQ, if `use_opq` is true. Note: this parameter is not yet supported on LanceDB Cloud
#### Defined in #### Defined in
[index.ts:981](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L981) [index.ts:1029](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L1029)
___ ___
@@ -89,7 +89,7 @@ Metric type, L2 or Cosine
#### Defined in #### Defined in
[index.ts:952](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L952) [index.ts:981](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L981)
___ ___
@@ -97,11 +97,11 @@ ___
`Optional` **num\_bits**: `number` `Optional` **num\_bits**: `number`
The number of bits to present one PQ centroid. Note: this parameter is not yet supported on LanceDB Cloud
#### Defined in #### Defined in
[index.ts:976](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L976) [index.ts:1021](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L1021)
___ ___
@@ -109,11 +109,11 @@ ___
`Optional` **num\_partitions**: `number` `Optional` **num\_partitions**: `number`
The number of partitions this index Note: this parameter is not yet supported on LanceDB Cloud
#### Defined in #### Defined in
[index.ts:957](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L957) [index.ts:989](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L989)
___ ___
@@ -121,11 +121,11 @@ ___
`Optional` **num\_sub\_vectors**: `number` `Optional` **num\_sub\_vectors**: `number`
Number of subvectors to build PQ code Note: this parameter is not yet supported on LanceDB Cloud
#### Defined in #### Defined in
[index.ts:972](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L972) [index.ts:1013](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L1013)
___ ___
@@ -133,11 +133,11 @@ ___
`Optional` **replace**: `boolean` `Optional` **replace**: `boolean`
Replace an existing index with the same name if it exists. Note: this parameter is not yet supported on LanceDB Cloud
#### Defined in #### Defined in
[index.ts:986](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L986) [index.ts:1037](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L1037)
___ ___
@@ -147,7 +147,7 @@ ___
#### Defined in #### Defined in
[index.ts:993](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L993) [index.ts:1044](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L1044)
___ ___
@@ -155,8 +155,8 @@ ___
• `Optional` **use\_opq**: `boolean` • `Optional` **use\_opq**: `boolean`
Train as optimized product quantization. Note: this parameter is not yet supported on LanceDB Cloud
#### Defined in #### Defined in
[index.ts:967](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L967) [index.ts:1005](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L1005)

View File

@@ -13,6 +13,7 @@ A LanceDB Table is the collection of Records. Each Record has one or more vector
## Implemented by ## Implemented by
- [`LocalTable`](../classes/LocalTable.md) - [`LocalTable`](../classes/LocalTable.md)
- [`RemoteTable`](../classes/RemoteTable.md)
## Table of contents ## Table of contents
@@ -35,7 +36,7 @@ A LanceDB Table is the collection of Records. Each Record has one or more vector
### add ### add
**add**: (`data`: `Record`\<`string`, `unknown`\>[]) => `Promise`\<`number`\> **add**: (`data`: `Table`\<`any`\> \| `Record`\<`string`, `unknown`\>[]) => `Promise`\<`number`\>
#### Type declaration #### Type declaration
@@ -47,7 +48,7 @@ Insert records into this Table.
| Name | Type | Description | | Name | Type | Description |
| :------ | :------ | :------ | | :------ | :------ | :------ |
| `data` | `Record`\<`string`, `unknown`\>[] | Records to be inserted into the Table | | `data` | `Table`\<`any`\> \| `Record`\<`string`, `unknown`\>[] | Records to be inserted into the Table |
##### Returns ##### Returns
@@ -57,7 +58,7 @@ The number of rows added to the table
#### Defined in #### Defined in
[index.ts:291](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L291) [index.ts:296](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L296)
___ ___
@@ -77,7 +78,7 @@ Returns the number of rows in this table.
#### Defined in #### Defined in
[index.ts:361](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L361) [index.ts:368](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L368)
___ ___
@@ -107,7 +108,7 @@ VectorIndexParams.
#### Defined in #### Defined in
[index.ts:306](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L306) [index.ts:313](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L313)
___ ___
@@ -142,7 +143,7 @@ await table.createScalarIndex('my_col')
#### Defined in #### Defined in
[index.ts:356](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L356) [index.ts:363](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L363)
___ ___
@@ -194,7 +195,7 @@ await tbl.countRows() // Returns 1
#### Defined in #### Defined in
[index.ts:395](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L395) [index.ts:402](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L402)
___ ___
@@ -220,7 +221,7 @@ Get statistics about an index.
#### Defined in #### Defined in
[index.ts:438](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L438) [index.ts:445](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L445)
___ ___
@@ -240,7 +241,7 @@ List the indicies on this table.
#### Defined in #### Defined in
[index.ts:433](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L433) [index.ts:440](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L440)
___ ___
@@ -250,13 +251,13 @@ ___
#### Defined in #### Defined in
[index.ts:277](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L277) [index.ts:282](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L282)
___ ___
### overwrite ### overwrite
• **overwrite**: (`data`: `Record`\<`string`, `unknown`\>[]) => `Promise`\<`number`\> • **overwrite**: (`data`: `Table`\<`any`\> \| `Record`\<`string`, `unknown`\>[]) => `Promise`\<`number`\>
#### Type declaration #### Type declaration
@@ -268,7 +269,7 @@ Insert records into this Table, replacing its contents.
| Name | Type | Description | | Name | Type | Description |
| :------ | :------ | :------ | | :------ | :------ | :------ |
| `data` | `Record`\<`string`, `unknown`\>[] | Records to be inserted into the Table | | `data` | `Table`\<`any`\> \| `Record`\<`string`, `unknown`\>[] | Records to be inserted into the Table |
##### Returns ##### Returns
@@ -278,7 +279,7 @@ The number of rows added to the table
#### Defined in #### Defined in
[index.ts:299](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L299) [index.ts:304](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L304)
___ ___
@@ -288,7 +289,7 @@ ___
#### Defined in #### Defined in
[index.ts:440](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L440) [index.ts:447](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L447)
___ ___
@@ -314,7 +315,7 @@ Creates a search query to find the nearest neighbors of the given search term
#### Defined in #### Defined in
[index.ts:283](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L283) [index.ts:288](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L288)
___ ___
@@ -365,4 +366,4 @@ let results = await tbl.search([1, 1]).execute();
#### Defined in #### Defined in
[index.ts:428](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L428) [index.ts:435](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L435)

View File

@@ -20,7 +20,7 @@ new values to set
#### Defined in #### Defined in
[index.ts:454](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L454) [index.ts:461](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L461)
___ ___
@@ -33,4 +33,4 @@ in which case all rows will be updated.
#### Defined in #### Defined in
[index.ts:448](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L448) [index.ts:455](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L455)

View File

@@ -20,7 +20,7 @@ new values to set as SQL expressions.
#### Defined in #### Defined in
[index.ts:468](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L468) [index.ts:475](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L475)
___ ___
@@ -33,4 +33,4 @@ in which case all rows will be updated.
#### Defined in #### Defined in
[index.ts:462](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L462) [index.ts:469](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L469)

View File

@@ -18,7 +18,7 @@
#### Defined in #### Defined in
[index.ts:472](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L472) [index.ts:479](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L479)
___ ___
@@ -28,7 +28,7 @@ ___
#### Defined in #### Defined in
[index.ts:473](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L473) [index.ts:480](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L480)
___ ___
@@ -38,4 +38,4 @@ ___
#### Defined in #### Defined in
[index.ts:474](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L474) [index.ts:481](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L481)

View File

@@ -24,4 +24,4 @@ A [WriteMode](../enums/WriteMode.md) to use on this operation
#### Defined in #### Defined in
[index.ts:1015](https://github.com/lancedb/lancedb/blob/c89d5e6/node/src/index.ts#L1015) [index.ts:1066](https://github.com/lancedb/lancedb/blob/5228ca4/node/src/index.ts#L1066)

View File

@@ -1,20 +0,0 @@
# Python API Reference (SaaS)
This section contains the API reference for the SaaS Python API.
## Installation
```shell
pip install lancedb
```
## Connection
::: lancedb.connect
::: lancedb.remote.db.RemoteDBConnection
## Table
::: lancedb.remote.table.RemoteTable

View File

@@ -9,6 +9,7 @@ const excludedGlobs = [
"../src/embedding.md", "../src/embedding.md",
"../src/examples/*.md", "../src/examples/*.md",
"../src/guides/tables.md", "../src/guides/tables.md",
"../src/guides/storage.md",
"../src/embeddings/*.md", "../src/embeddings/*.md",
]; ];

74
node/package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "vectordb", "name": "vectordb",
"version": "0.4.5", "version": "0.4.4",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "vectordb", "name": "vectordb",
"version": "0.4.5", "version": "0.4.4",
"cpu": [ "cpu": [
"x64", "x64",
"arm64" "arm64"
@@ -53,11 +53,11 @@
"uuid": "^9.0.0" "uuid": "^9.0.0"
}, },
"optionalDependencies": { "optionalDependencies": {
"@lancedb/vectordb-darwin-arm64": "0.4.5", "@lancedb/vectordb-darwin-arm64": "0.4.4",
"@lancedb/vectordb-darwin-x64": "0.4.5", "@lancedb/vectordb-darwin-x64": "0.4.4",
"@lancedb/vectordb-linux-arm64-gnu": "0.4.5", "@lancedb/vectordb-linux-arm64-gnu": "0.4.4",
"@lancedb/vectordb-linux-x64-gnu": "0.4.5", "@lancedb/vectordb-linux-x64-gnu": "0.4.4",
"@lancedb/vectordb-win32-x64-msvc": "0.4.5" "@lancedb/vectordb-win32-x64-msvc": "0.4.4"
} }
}, },
"node_modules/@75lb/deep-merge": { "node_modules/@75lb/deep-merge": {
@@ -328,66 +328,6 @@
"@jridgewell/sourcemap-codec": "^1.4.10" "@jridgewell/sourcemap-codec": "^1.4.10"
} }
}, },
"node_modules/@lancedb/vectordb-darwin-arm64": {
"version": "0.4.5",
"resolved": "https://registry.npmjs.org/@lancedb/vectordb-darwin-arm64/-/vectordb-darwin-arm64-0.4.5.tgz",
"integrity": "sha512-sR+Q9dRBzMm+NGqM7EiK07c7pQz/V4J//23p05CeO/YATjKYyU3jE/dmVenLjJGW2UUrRYiyUQ9X6Up+OOgdhA==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"darwin"
]
},
"node_modules/@lancedb/vectordb-darwin-x64": {
"version": "0.4.5",
"resolved": "https://registry.npmjs.org/@lancedb/vectordb-darwin-x64/-/vectordb-darwin-x64-0.4.5.tgz",
"integrity": "sha512-/BIyUeVkLaUlOEQN4HUQ9J9ZdNWkDpZPUUS9kfz5iYIjotgwpSfznF8Q1GY5BVuXa2ke7GC3tnkwwd5ZMOuDsA==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"darwin"
]
},
"node_modules/@lancedb/vectordb-linux-arm64-gnu": {
"version": "0.4.5",
"resolved": "https://registry.npmjs.org/@lancedb/vectordb-linux-arm64-gnu/-/vectordb-linux-arm64-gnu-0.4.5.tgz",
"integrity": "sha512-bq8vX7znIf2Dap41YIbB5uA/YahwaLvFPNH0WmwqeBWxF64/AJ74DsZk51ftwczQMsyLK74M8f1PzniapMAR+Q==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"linux"
]
},
"node_modules/@lancedb/vectordb-linux-x64-gnu": {
"version": "0.4.5",
"resolved": "https://registry.npmjs.org/@lancedb/vectordb-linux-x64-gnu/-/vectordb-linux-x64-gnu-0.4.5.tgz",
"integrity": "sha512-5qCWFyxihyMDYIGRAdQ7zv3enBEDxPR08dCmXr2Bu9yYI3SUqfuSvFX1NwflVeB+RzRMMbeG4xiaEbo7H7/H3Q==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"linux"
]
},
"node_modules/@lancedb/vectordb-win32-x64-msvc": {
"version": "0.4.5",
"resolved": "https://registry.npmjs.org/@lancedb/vectordb-win32-x64-msvc/-/vectordb-win32-x64-msvc-0.4.5.tgz",
"integrity": "sha512-z3dZ6TDzm2EU5gNuejshArs3o84v1rdXnds22TTuc9fVhwg5JG87FyHFZKU1MGuyLuZW22Me0YDuS9VR+eAp0Q==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"win32"
]
},
"node_modules/@neon-rs/cli": { "node_modules/@neon-rs/cli": {
"version": "0.0.160", "version": "0.0.160",
"resolved": "https://registry.npmjs.org/@neon-rs/cli/-/cli-0.0.160.tgz", "resolved": "https://registry.npmjs.org/@neon-rs/cli/-/cli-0.0.160.tgz",

View File

@@ -1,12 +1,12 @@
{ {
"name": "vectordb", "name": "vectordb",
"version": "0.4.6", "version": "0.4.4",
"description": " Serverless, low-latency vector database for AI applications", "description": " Serverless, low-latency vector database for AI applications",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
"scripts": { "scripts": {
"tsc": "tsc -b", "tsc": "tsc -b",
"build": "npm run tsc && cargo-cp-artifact --artifact cdylib vectordb-node index.node -- cargo build --message-format=json", "build": "cargo-cp-artifact --artifact cdylib vectordb-node index.node -- cargo build --message-format=json && tsc -b",
"build-release": "npm run build -- --release", "build-release": "npm run build -- --release",
"test": "npm run tsc && mocha -recursive dist/test", "test": "npm run tsc && mocha -recursive dist/test",
"integration-test": "npm run tsc && mocha -recursive dist/integration_test", "integration-test": "npm run tsc && mocha -recursive dist/integration_test",
@@ -81,10 +81,10 @@
} }
}, },
"optionalDependencies": { "optionalDependencies": {
"@lancedb/vectordb-darwin-arm64": "0.4.6", "@lancedb/vectordb-darwin-arm64": "0.4.4",
"@lancedb/vectordb-darwin-x64": "0.4.6", "@lancedb/vectordb-darwin-x64": "0.4.4",
"@lancedb/vectordb-linux-arm64-gnu": "0.4.6", "@lancedb/vectordb-linux-arm64-gnu": "0.4.4",
"@lancedb/vectordb-linux-x64-gnu": "0.4.6", "@lancedb/vectordb-linux-x64-gnu": "0.4.4",
"@lancedb/vectordb-win32-x64-msvc": "0.4.6" "@lancedb/vectordb-win32-x64-msvc": "0.4.4"
} }
} }

View File

@@ -1,6 +1,6 @@
// Copyright 2023 Lance Developers. // Copyright 2023 Lance Developers.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License")
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
@@ -49,6 +49,7 @@ export { Query }
export type { EmbeddingFunction } export type { EmbeddingFunction }
export { OpenAIEmbeddingFunction } from './embedding/openai' export { OpenAIEmbeddingFunction } from './embedding/openai'
export { makeArrowTable, type MakeArrowTableOptions } from './arrow' export { makeArrowTable, type MakeArrowTableOptions } from './arrow'
export { RemoteConnection, RemoteTable } from './remote'
const defaultAwsRegion = 'us-west-2' const defaultAwsRegion = 'us-west-2'
@@ -725,6 +726,7 @@ export class LocalTable<T = number[]> implements Table<T> {
* Insert records into this Table, replacing its contents. * Insert records into this Table, replacing its contents.
* *
* @param data Records to be inserted into the Table * @param data Records to be inserted into the Table
* Type Table is ArrowTable
* @return The number of rows added to the table * @return The number of rows added to the table
*/ */
async overwrite ( async overwrite (
@@ -815,6 +817,7 @@ export class LocalTable<T = number[]> implements Table<T> {
/** /**
* Clean up old versions of the table, freeing disk space. * Clean up old versions of the table, freeing disk space.
* *
* Note: this API is not yet available on LanceDB Cloud
* @param olderThan The minimum age in minutes of the versions to delete. If not * @param olderThan The minimum age in minutes of the versions to delete. If not
* provided, defaults to two weeks. * provided, defaults to two weeks.
* @param deleteUnverified Because they may be part of an in-progress * @param deleteUnverified Because they may be part of an in-progress
@@ -845,6 +848,7 @@ export class LocalTable<T = number[]> implements Table<T> {
* This can be run after making several small appends to optimize the table * This can be run after making several small appends to optimize the table
* for faster reads. * for faster reads.
* *
* Note: this API is not yet available on LanceDB Cloud
* @param options Advanced options configuring compaction. In most cases, you * @param options Advanced options configuring compaction. In most cases, you
* can omit this arguments, as the default options are sensible * can omit this arguments, as the default options are sensible
* for most tables. * for most tables.
@@ -966,6 +970,9 @@ export interface IvfPQIndexConfig {
/** /**
* A unique name for the index * A unique name for the index
*/ */
/**
* Note: this parameter is not supported on LanceDB Cloud
*/
index_name?: string index_name?: string
/** /**
@@ -976,35 +983,57 @@ export interface IvfPQIndexConfig {
/** /**
* The number of partitions this index * The number of partitions this index
*/ */
/**
* Note: this parameter is not yet supported on LanceDB Cloud
*/
num_partitions?: number num_partitions?: number
/** /**
* The max number of iterations for kmeans training. * The max number of iterations for kmeans training.
*/ */
/**
* Note: this parameter is not yet supported on LanceDB Cloud
*/
max_iters?: number max_iters?: number
/** /**
* Train as optimized product quantization. * Train as optimized product quantization.
*/ */
/**
* Note: this parameter is not yet supported on LanceDB Cloud
*/
use_opq?: boolean use_opq?: boolean
/** /**
* Number of subvectors to build PQ code * Number of subvectors to build PQ code
*/ */
/**
* Note: this parameter is not yet supported on LanceDB Cloud
*/
num_sub_vectors?: number num_sub_vectors?: number
/** /**
* The number of bits to present one PQ centroid. * The number of bits to present one PQ centroid.
*/ */
/**
* Note: this parameter is not yet supported on LanceDB Cloud
*/
num_bits?: number num_bits?: number
/** /**
* Max number of iterations to train OPQ, if `use_opq` is true. * Max number of iterations to train OPQ, if `use_opq` is true.
*/ */
/**
* Note: this parameter is not yet supported on LanceDB Cloud
*/
max_opq_iters?: number max_opq_iters?: number
/** /**
* Replace an existing index with the same name if it exists. * Replace an existing index with the same name if it exists.
*/ */
/**
* Note: this parameter is not yet supported on LanceDB Cloud
*/
replace?: boolean replace?: boolean
/** /**

View File

@@ -391,6 +391,24 @@ describe('LanceDB client', function () {
}) })
}).timeout(120000) }).timeout(120000)
it('fails to create a new table when the vector column is missing', async function () {
const dir = await track().mkdir('lancejs')
const con = await lancedb.connect(dir)
const data = [
{
id: 1,
price: 10
}
]
const create = con.createTable('missing_vector', data)
await expect(create).to.be.rejectedWith(
Error,
"column 'vector' is missing"
)
})
it('use overwrite flag to overwrite existing table', async function () { it('use overwrite flag to overwrite existing table', async function () {
const dir = await track().mkdir('lancejs') const dir = await track().mkdir('lancejs')
const con = await lancedb.connect(dir) const con = await lancedb.connect(dir)

View File

@@ -10,15 +10,14 @@ crate-type = ["cdylib"]
[dependencies] [dependencies]
arrow-ipc.workspace = true arrow-ipc.workspace = true
futures.workspace = true
lance-linalg.workspace = true
lance.workspace = true
vectordb = { path = "../rust/vectordb" }
napi = { version = "2.14", default-features = false, features = [ napi = { version = "2.14", default-features = false, features = [
"napi7", "napi7",
"async" "async"
] } ] }
napi-derive = "2.14" napi-derive = "2.14"
vectordb = { path = "../rust/vectordb" }
lance.workspace = true
lance-linalg.workspace = true
[build-dependencies] [build-dependencies]
napi-build = "2.1" napi-build = "2.1"

View File

@@ -53,16 +53,6 @@ describe("Test creating index", () => {
const indexDir = path.join(tmpDir, "test.lance", "_indices"); const indexDir = path.join(tmpDir, "test.lance", "_indices");
expect(fs.readdirSync(indexDir)).toHaveLength(1); expect(fs.readdirSync(indexDir)).toHaveLength(1);
// TODO: check index type. // TODO: check index type.
// Search without specifying the column
let query_vector = data.toArray()[5].vec.toJSON();
let rst = await tbl.query().nearestTo(query_vector).limit(2).toArrow();
expect(rst.numRows).toBe(2);
// Search with specifying the column
let rst2 = await tbl.search(query_vector, "vec").limit(2).toArrow();
expect(rst2.numRows).toBe(2);
expect(rst.toString()).toEqual(rst2.toString());
}); });
test("no vector column available", async () => { test("no vector column available", async () => {
@@ -81,80 +71,6 @@ describe("Test creating index", () => {
await tbl.createIndex("val").build(); await tbl.createIndex("val").build();
const indexDir = path.join(tmpDir, "no_vec.lance", "_indices"); const indexDir = path.join(tmpDir, "no_vec.lance", "_indices");
expect(fs.readdirSync(indexDir)).toHaveLength(1); expect(fs.readdirSync(indexDir)).toHaveLength(1);
for await (const r of tbl.query().filter("id > 1").select(["id"])) {
expect(r.numRows).toBe(1);
}
});
test("two columns with different dimensions", async () => {
const db = await connect(tmpDir);
const schema = new Schema([
new Field("id", new Int32(), true),
new Field("vec", new FixedSizeList(32, new Field("item", new Float32()))),
new Field(
"vec2",
new FixedSizeList(64, new Field("item", new Float32()))
),
]);
const tbl = await db.createTable(
"two_vectors",
makeArrowTable(
Array(300)
.fill(1)
.map((_, i) => ({
id: i,
vec: Array(32)
.fill(1)
.map(() => Math.random()),
vec2: Array(64) // different dimension
.fill(1)
.map(() => Math.random()),
})),
{ schema }
)
);
// Only build index over v1
await expect(tbl.createIndex().build()).rejects.toThrow(
/.*More than one vector columns found.*/
);
tbl
.createIndex("vec")
.ivf_pq({ num_partitions: 2, num_sub_vectors: 2 })
.build();
const rst = await tbl
.query()
.nearestTo(
Array(32)
.fill(1)
.map(() => Math.random())
)
.limit(2)
.toArrow();
expect(rst.numRows).toBe(2);
// Search with specifying the column
await expect(
tbl
.search(
Array(64)
.fill(1)
.map(() => Math.random()),
"vec"
)
.limit(2)
.toArrow()
).rejects.toThrow(/.*does not match the dimension.*/);
const query64 = Array(64)
.fill(1)
.map(() => Math.random());
const rst64_1 = await tbl.query().nearestTo(query64).limit(2).toArrow();
const rst64_2 = await tbl.search(query64, "vec2").limit(2).toArrow();
expect(rst64_1.toString()).toEqual(rst64_2.toString());
expect(rst64_1.numRows).toBe(2);
}); });
test("create scalar index", async () => { test("create scalar index", async () => {

View File

@@ -91,6 +91,7 @@ impl IndexBuilder {
#[napi] #[napi]
pub async fn build(&self) -> napi::Result<()> { pub async fn build(&self) -> napi::Result<()> {
println!("nodejs::index.rs : build");
self.inner self.inner
.build() .build()
.await .await

View File

@@ -1,47 +0,0 @@
// Copyright 2024 Lance Developers.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use futures::StreamExt;
use lance::io::RecordBatchStream;
use napi::bindgen_prelude::*;
use napi_derive::napi;
use vectordb::ipc::batches_to_ipc_file;
/** Typescript-style Async Iterator over RecordBatches */
#[napi]
pub struct RecordBatchIterator {
inner: Box<dyn RecordBatchStream + Unpin>,
}
#[napi]
impl RecordBatchIterator {
pub(crate) fn new(inner: Box<dyn RecordBatchStream + Unpin>) -> Self {
Self { inner }
}
#[napi]
pub async unsafe fn next(&mut self) -> napi::Result<Option<Buffer>> {
if let Some(rst) = self.inner.next().await {
let batch = rst.map_err(|e| {
napi::Error::from_reason(format!("Failed to get next batch from stream: {}", e))
})?;
batches_to_ipc_file(&[batch])
.map_err(|e| napi::Error::from_reason(format!("Failed to write IPC file: {}", e)))
.map(|buf| Some(Buffer::from(buf)))
} else {
// We are done with the stream.
Ok(None)
}
}
}

View File

@@ -17,7 +17,6 @@ use napi_derive::*;
mod connection; mod connection;
mod index; mod index;
mod iterator;
mod query; mod query;
mod table; mod table;

View File

@@ -16,7 +16,7 @@ use napi::bindgen_prelude::*;
use napi_derive::napi; use napi_derive::napi;
use vectordb::query::Query as LanceDBQuery; use vectordb::query::Query as LanceDBQuery;
use crate::{iterator::RecordBatchIterator, table::Table}; use crate::table::Table;
#[napi] #[napi]
pub struct Query { pub struct Query {
@@ -32,50 +32,17 @@ impl Query {
} }
#[napi] #[napi]
pub fn column(&mut self, column: String) { pub fn vector(&mut self, vector: Float32Array) {
self.inner = self.inner.clone().column(&column); let inn = self.inner.clone().nearest_to(&vector);
self.inner = inn;
} }
#[napi] #[napi]
pub fn filter(&mut self, filter: String) { pub fn to_arrow(&self) -> napi::Result<()> {
self.inner = self.inner.clone().filter(filter); // let buf = self.inner.to_arrow().map_err(|e| {
} // napi::Error::from_reason(format!("Failed to convert query to arrow: {}", e))
// })?;
#[napi] // Ok(buf)
pub fn select(&mut self, columns: Vec<String>) { todo!()
self.inner = self.inner.clone().select(&columns);
}
#[napi]
pub fn limit(&mut self, limit: u32) {
self.inner = self.inner.clone().limit(limit as usize);
}
#[napi]
pub fn prefilter(&mut self, prefilter: bool) {
self.inner = self.inner.clone().prefilter(prefilter);
}
#[napi]
pub fn nearest_to(&mut self, vector: Float32Array) {
self.inner = self.inner.clone().nearest_to(&vector);
}
#[napi]
pub fn refine_factor(&mut self, refine_factor: u32) {
self.inner = self.inner.clone().refine_factor(refine_factor);
}
#[napi]
pub fn nprobes(&mut self, nprobe: u32) {
self.inner = self.inner.clone().nprobes(nprobe as usize);
}
#[napi]
pub async fn execute_stream(&self) -> napi::Result<RecordBatchIterator> {
let inner_stream = self.inner.execute_stream().await.map_err(|e| {
napi::Error::from_reason(format!("Failed to execute query stream: {}", e))
})?;
Ok(RecordBatchIterator::new(Box::new(inner_stream)))
} }
} }

View File

@@ -54,20 +54,9 @@ export class IndexBuilder {
scalar(): void scalar(): void
build(): Promise<void> build(): Promise<void>
} }
/** Typescript-style Async Iterator over RecordBatches */
export class RecordBatchIterator {
next(): Promise<Buffer | null>
}
export class Query { export class Query {
column(column: string): void vector(vector: Float32Array): void
filter(filter: string): void toArrow(): void
select(columns: Array<string>): void
limit(limit: number): void
prefilter(prefilter: boolean): void
nearestTo(vector: Float32Array): void
refineFactor(refineFactor: number): void
nprobes(nprobe: number): void
executeStream(): Promise<RecordBatchIterator>
} }
export class Table { export class Table {
/** Return Schema as empty Arrow IPC file. */ /** Return Schema as empty Arrow IPC file. */

View File

@@ -295,13 +295,12 @@ if (!nativeBinding) {
throw new Error(`Failed to load native binding`) throw new Error(`Failed to load native binding`)
} }
const { Connection, IndexType, MetricType, IndexBuilder, RecordBatchIterator, Query, Table, WriteMode, connect } = nativeBinding const { Connection, IndexType, MetricType, IndexBuilder, Query, Table, WriteMode, connect } = nativeBinding
module.exports.Connection = Connection module.exports.Connection = Connection
module.exports.IndexType = IndexType module.exports.IndexType = IndexType
module.exports.MetricType = MetricType module.exports.MetricType = MetricType
module.exports.IndexBuilder = IndexBuilder module.exports.IndexBuilder = IndexBuilder
module.exports.RecordBatchIterator = RecordBatchIterator
module.exports.Query = Query module.exports.Query = Query
module.exports.Table = Table module.exports.Table = Table
module.exports.WriteMode = WriteMode module.exports.WriteMode = WriteMode

View File

@@ -12,73 +12,46 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { RecordBatch, tableFromIPC, Table as ArrowTable } from "apache-arrow"; import { RecordBatch } from "apache-arrow";
import { import { Table } from "./table";
RecordBatchIterator as NativeBatchIterator,
Query as NativeQuery,
Table as NativeTable,
} from "./native";
// TODO: re-eanble eslint once we have a real implementation
/* eslint-disable */
class RecordBatchIterator implements AsyncIterator<RecordBatch> { class RecordBatchIterator implements AsyncIterator<RecordBatch> {
private promised_inner?: Promise<NativeBatchIterator>; next(
private inner?: NativeBatchIterator; ...args: [] | [undefined]
): Promise<IteratorResult<RecordBatch<any>, any>> {
constructor( throw new Error("Method not implemented.");
inner?: NativeBatchIterator,
promise?: Promise<NativeBatchIterator>
) {
// TODO: check promise reliably so we dont need to pass two arguments.
this.inner = inner;
this.promised_inner = promise;
} }
return?(value?: any): Promise<IteratorResult<RecordBatch<any>, any>> {
async next(): Promise<IteratorResult<RecordBatch<any>, any>> { throw new Error("Method not implemented.");
if (this.inner === undefined) { }
this.inner = await this.promised_inner; throw?(e?: any): Promise<IteratorResult<RecordBatch<any>, any>> {
} throw new Error("Method not implemented.");
if (this.inner === undefined) {
throw new Error("Invalid iterator state state");
}
const n = await this.inner.next();
if (n == null) {
return Promise.resolve({ done: true, value: null });
}
const tbl = tableFromIPC(n);
if (tbl.batches.length != 1) {
throw new Error("Expected only one batch");
}
return Promise.resolve({ done: false, value: tbl.batches[0] });
} }
} }
/* eslint-enable */ /* eslint-enable */
/** Query executor */ /** Query executor */
export class Query implements AsyncIterable<RecordBatch> { export class Query implements AsyncIterable<RecordBatch> {
private readonly inner: NativeQuery; private readonly tbl: Table;
private _filter?: string;
private _limit?: number;
constructor(tbl: NativeTable) { // Vector search
this.inner = tbl.query(); private _vector?: Float32Array;
} private _nprobes?: number;
private _refine_factor?: number = 1;
/** Set the column to run query. */ constructor(tbl: Table) {
column(column: string): Query { this.tbl = tbl;
this.inner.column(column);
return this;
} }
/** Set the filter predicate, only returns the results that satisfy the filter. /** Set the filter predicate, only returns the results that satisfy the filter.
* *
*/ */
filter(predicate: string): Query { filter(predicate: string): Query {
this.inner.filter(predicate); this._filter = predicate;
return this;
}
/**
* Select the columns to return. If not set, all columns are returned.
*/
select(columns: string[]): Query {
this.inner.select(columns);
return this; return this;
} }
@@ -86,67 +59,35 @@ export class Query implements AsyncIterable<RecordBatch> {
* Set the limit of rows to return. * Set the limit of rows to return.
*/ */
limit(limit: number): Query { limit(limit: number): Query {
this.inner.limit(limit); this._limit = limit;
return this;
}
prefilter(prefilter: boolean): Query {
this.inner.prefilter(prefilter);
return this; return this;
} }
/** /**
* Set the query vector. * Set the query vector.
*/ */
nearestTo(vector: number[]): Query { vector(vector: number[]): Query {
this.inner.nearestTo(Float32Array.from(vector)); this._vector = Float32Array.from(vector);
return this; return this;
} }
/** /**
* Set the number of IVF partitions to use for the query. * Set the number of probes to use for the query.
*/ */
nprobes(nprobes: number): Query { nprobes(nprobes: number): Query {
this.inner.nprobes(nprobes); this._nprobes = nprobes;
return this; return this;
} }
/** /**
* Set the refine factor for the query. * Set the refine factor for the query.
*/ */
refineFactor(refine_factor: number): Query { refine_factor(refine_factor: number): Query {
this.inner.refineFactor(refine_factor); this._refine_factor = refine_factor;
return this; return this;
} }
/** [Symbol.asyncIterator](): AsyncIterator<RecordBatch<any>, any, undefined> {
* Execute the query and return the results as an AsyncIterator. throw new RecordBatchIterator();
*/
async executeStream(): Promise<RecordBatchIterator> {
const inner = await this.inner.executeStream();
return new RecordBatchIterator(inner);
}
/** Collect the results as an Arrow Table. */
async toArrow(): Promise<ArrowTable> {
const batches = [];
for await (const batch of this) {
batches.push(batch);
}
return new ArrowTable(batches);
}
/** Returns a JSON Array of All results.
*
*/
async toArray(): Promise<any[]> {
const tbl = await this.toArrow();
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return tbl.toArray();
}
[Symbol.asyncIterator](): AsyncIterator<RecordBatch<any>> {
const promise = this.inner.executeStream();
return new RecordBatchIterator(undefined, promise);
} }
} }

View File

@@ -95,58 +95,10 @@ export class Table {
return builder; return builder;
} }
/** search(vector?: number[]): Query {
* Create a generic {@link Query} Builder. const q = new Query(this);
* if (vector !== undefined) {
* When appropriate, various indices and statistics based pruning will be used to q.vector(vector);
* accelerate the query.
*
* @example
*
* ### Run a SQL-style query
* ```typescript
* for await (const batch of table.query()
* .filter("id > 1").select(["id"]).limit(20)) {
* console.log(batch);
* }
* ```
*
* ### Run Top-10 vector similarity search
* ```typescript
* for await (const batch of table.query()
* .nearestTo([1, 2, 3])
* .refineFactor(5).nprobe(10)
* .limit(10)) {
* console.log(batch);
* }
*```
*
* ### Scan the full dataset
* ```typescript
* for await (const batch of table.query()) {
* console.log(batch);
* }
*
* ### Return the full dataset as Arrow Table
* ```typescript
* let arrowTbl = await table.query().nearestTo([1.0, 2.0, 0.5, 6.7]).toArrow();
* ```
*
* @returns {@link Query}
*/
query(): Query {
return new Query(this.inner);
}
/** Search the table with a given query vector.
*
* This is a convenience method for preparing an ANN {@link Query}.
*/
search(vector: number[], column?: string): Query {
const q = this.query();
q.nearestTo(vector);
if (column !== undefined) {
q.column(column);
} }
return q; return q;
} }

View File

@@ -87,16 +87,25 @@ class DBConnection(EnforceOverrides):
Can be either "create" or "overwrite". Can be either "create" or "overwrite".
By default, if the table already exists, an exception is raised. By default, if the table already exists, an exception is raised.
If you want to overwrite the table, use mode="overwrite". If you want to overwrite the table, use mode="overwrite".
**Note: this parameter is not yet supported on LanceDB Cloud**
exist_ok: bool, default False exist_ok: bool, default False
If a table by the same name already exists, then raise an exception If a table by the same name already exists, then raise an exception
if exist_ok=False. If exist_ok=True, then open the existing table; if exist_ok=False. If exist_ok=True, then open the existing table;
it will not add the provided data but will validate against any it will not add the provided data but will validate against any
schema that's specified. schema that's specified.
**Note: this parameter is not yet supported on LanceDB Cloud**
on_bad_vectors: str, default "error" on_bad_vectors: str, default "error"
What to do if any of the vectors are not the same size or contains NaNs. What to do if any of the vectors are not the same size or contains NaNs.
One of "error", "drop", "fill". One of "error", "drop", "fill".
fill_value: float fill_value: float
The value to use when filling vectors. Only used if on_bad_vectors="fill". The value to use when filling vectors. Only used if on_bad_vectors="fill".
embedding_functions: List[EmbeddingFunctionConfig], default None
The embedding functions to be applied before inserting data to
LanceDB table.
**Note: this parameter is not yet supported on LanceDB Cloud**
Returns Returns
------- -------
@@ -230,7 +239,9 @@ class DBConnection(EnforceOverrides):
def drop_database(self): def drop_database(self):
""" """
Drop database Drop database
This is the same thing as dropping all the tables This functions the same as dropping all the tables
**Note: this API is not yet available on LanceDB Cloud**
""" """
raise NotImplementedError raise NotImplementedError

View File

@@ -54,16 +54,16 @@ class RemoteTable(Table):
def to_arrow(self) -> pa.Table: def to_arrow(self) -> pa.Table:
"""to_arrow() is not supported on the LanceDB cloud""" """to_arrow() is not supported on the LanceDB cloud"""
raise NotImplementedError("to_arrow() is not supported on the LanceDB cloud") raise NotImplementedError("to_arrow() is not yet supported on LanceDB Cloud")
def to_pandas(self): def to_pandas(self):
"""to_pandas() is not supported on the LanceDB cloud""" """to_pandas() is not supported on the LanceDB cloud"""
return NotImplementedError("to_pandas() is not supported on the LanceDB cloud") return NotImplementedError("to_pandas() is not yet supported on LanceDB Cloud")
def create_scalar_index(self, *args, **kwargs): def create_scalar_index(self, *args, **kwargs):
"""Creates a scalar index""" """Creates a scalar index"""
return NotImplementedError( return NotImplementedError(
"create_scalar_index() is not supported on the LanceDB cloud" "create_scalar_index() is not yet supported on LanceDB Cloud"
) )
def create_index( def create_index(

View File

@@ -178,6 +178,7 @@ class Table(ABC):
def to_pandas(self) -> "pd.DataFrame": def to_pandas(self) -> "pd.DataFrame":
"""Return the table as a pandas DataFrame. """Return the table as a pandas DataFrame.
**Note: this API is not yet available on LanceDB Cloud**
Returns Returns
------- -------
pd.DataFrame pd.DataFrame
@@ -188,6 +189,7 @@ class Table(ABC):
def to_arrow(self) -> pa.Table: def to_arrow(self) -> pa.Table:
"""Return the table as a pyarrow Table. """Return the table as a pyarrow Table.
**Note: this API is not yet available on LanceDB Cloud**
Returns Returns
------- -------
pa.Table pa.Table
@@ -215,18 +217,26 @@ class Table(ABC):
num_partitions: int, default 256 num_partitions: int, default 256
The number of IVF partitions to use when creating the index. The number of IVF partitions to use when creating the index.
Default is 256. Default is 256.
**Note: this parameter is not supported on LanceDB Cloud**
num_sub_vectors: int, default 96 num_sub_vectors: int, default 96
The number of PQ sub-vectors to use when creating the index. The number of PQ sub-vectors to use when creating the index.
Default is 96. Default is 96.
**Note: this parameter is not supported on LanceDB Cloud**
vector_column_name: str, default "vector" vector_column_name: str, default "vector"
The vector column name to create the index. The vector column name to create the index.
replace: bool, default True replace: bool, default True
- If True, replace the existing index if it exists. - If True, replace the existing index if it exists.
- If False, raise an error if duplicate index exists. - If False, raise an error if duplicate index exists.
**Note: this parameter is not yet supported on LanceDB Cloud**
accelerator: str, default None accelerator: str, default None
If set, use the given accelerator to create the index. If set, use the given accelerator to create the index.
Only support "cuda" for now. Only support "cuda" for now.
**Note: this parameter is not yet supported on LanceDB Cloud**
index_cache_size : int, optional index_cache_size : int, optional
The size of the index cache in number of entries. Default value is 256. The size of the index cache in number of entries. Default value is 256.
""" """
@@ -241,6 +251,8 @@ class Table(ABC):
): ):
"""Create a scalar index on a column. """Create a scalar index on a column.
**Note: this API is not yet available on LanceDB Cloud**
Scalar indices, like vector indices, can be used to speed up scans. A scalar 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. 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 For example, the following scan will be faster if the column ``my_col`` has
@@ -396,6 +408,8 @@ class Table(ABC):
- If `query` is a string, then the query type is "vector" if the - If `query` is a string, then the query type is "vector" if the
table has embedding functions else the query type is "fts" table has embedding functions else the query type is "fts"
**Note: this parameter is not yet supported on LanceDB Cloud**
Returns Returns
------- -------
LanceQueryBuilder LanceQueryBuilder

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "vectordb-node" name = "vectordb-node"
version = "0.4.6" version = "0.4.4"
description = "Serverless, low-latency vector database for AI applications" description = "Serverless, low-latency vector database for AI applications"
license = "Apache-2.0" license = "Apache-2.0"
edition = "2018" edition = "2018"

View File

@@ -1,4 +1,4 @@
// Copyright 2024 Lance Developers. // Copyright 2023 Lance Developers.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
@@ -19,8 +19,19 @@ use arrow_array::RecordBatch;
use arrow_ipc::reader::FileReader; use arrow_ipc::reader::FileReader;
use arrow_ipc::writer::FileWriter; use arrow_ipc::writer::FileWriter;
use arrow_schema::SchemaRef; use arrow_schema::SchemaRef;
use vectordb::table::VECTOR_COLUMN_NAME;
use crate::error::Result; use crate::error::{MissingColumnSnafu, Result};
use snafu::prelude::*;
fn validate_vector_column(record_batch: &RecordBatch) -> Result<()> {
record_batch
.column_by_name(VECTOR_COLUMN_NAME)
.map(|_| ())
.context(MissingColumnSnafu {
name: VECTOR_COLUMN_NAME,
})
}
pub(crate) fn arrow_buffer_to_record_batch(slice: &[u8]) -> Result<(Vec<RecordBatch>, SchemaRef)> { pub(crate) fn arrow_buffer_to_record_batch(slice: &[u8]) -> Result<(Vec<RecordBatch>, SchemaRef)> {
let mut batches: Vec<RecordBatch> = Vec::new(); let mut batches: Vec<RecordBatch> = Vec::new();
@@ -28,6 +39,7 @@ pub(crate) fn arrow_buffer_to_record_batch(slice: &[u8]) -> Result<(Vec<RecordBa
let schema = file_reader.schema(); let schema = file_reader.schema();
for b in file_reader { for b in file_reader {
let record_batch = b?; let record_batch = b?;
validate_vector_column(&record_batch)?;
batches.push(record_batch); batches.push(record_batch);
} }
Ok((batches, schema)) Ok((batches, schema))

View File

@@ -19,7 +19,6 @@ use neon::{
}; };
use crate::{error::ResultExt, runtime, table::JsTable}; use crate::{error::ResultExt, runtime, table::JsTable};
use vectordb::Table;
pub(crate) fn table_create_scalar_index(mut cx: FunctionContext) -> JsResult<JsPromise> { pub(crate) fn table_create_scalar_index(mut cx: FunctionContext) -> JsResult<JsPromise> {
let js_table = cx.this().downcast_or_throw::<JsBox<JsTable>, _>(&mut cx)?; let js_table = cx.this().downcast_or_throw::<JsBox<JsTable>, _>(&mut cx)?;
@@ -36,9 +35,7 @@ pub(crate) fn table_create_scalar_index(mut cx: FunctionContext) -> JsResult<JsP
let idx_result = table let idx_result = table
.as_native() .as_native()
.unwrap() .unwrap()
.create_index(&[&column]) .create_scalar_index(&column, replace)
.replace(replace)
.build()
.await; .await;
deferred.settle_with(&channel, move |mut cx| { deferred.settle_with(&channel, move |mut cx| {

View File

@@ -16,7 +16,6 @@ use arrow_array::{RecordBatch, RecordBatchIterator};
use lance::dataset::optimize::CompactionOptions; use lance::dataset::optimize::CompactionOptions;
use lance::dataset::{WriteMode, WriteParams}; use lance::dataset::{WriteMode, WriteParams};
use lance::io::ObjectStoreParams; use lance::io::ObjectStoreParams;
use vectordb::table::OptimizeAction;
use crate::arrow::{arrow_buffer_to_record_batch, record_batch_to_buffer}; use crate::arrow::{arrow_buffer_to_record_batch, record_batch_to_buffer};
use neon::prelude::*; use neon::prelude::*;
@@ -246,30 +245,27 @@ impl JsTable {
.map(|val| val.value(&mut cx) as i64) .map(|val| val.value(&mut cx) as i64)
.unwrap_or_else(|| 2 * 7 * 24 * 60); // 2 weeks .unwrap_or_else(|| 2 * 7 * 24 * 60); // 2 weeks
let older_than = chrono::Duration::minutes(older_than); let older_than = chrono::Duration::minutes(older_than);
let delete_unverified: Option<bool> = Some( let delete_unverified: bool = cx
cx.argument_opt(1) .argument_opt(1)
.and_then(|val| val.downcast::<JsBoolean, _>(&mut cx).ok()) .and_then(|val| val.downcast::<JsBoolean, _>(&mut cx).ok())
.map(|val| val.value(&mut cx)) .map(|val| val.value(&mut cx))
.unwrap_or_default(), .unwrap_or_default();
);
rt.spawn(async move { rt.spawn(async move {
let stats = table let stats = table
.optimize(OptimizeAction::Prune { .as_native()
older_than, .unwrap()
delete_unverified, .cleanup_old_versions(older_than, Some(delete_unverified))
})
.await; .await;
deferred.settle_with(&channel, move |mut cx| { deferred.settle_with(&channel, move |mut cx| {
let stats = stats.or_throw(&mut cx)?; let stats = stats.or_throw(&mut cx)?;
let prune_stats = stats.prune.as_ref().expect("Prune stats missing");
let output_metrics = JsObject::new(&mut cx); let output_metrics = JsObject::new(&mut cx);
let bytes_removed = cx.number(prune_stats.bytes_removed as f64); let bytes_removed = cx.number(stats.bytes_removed as f64);
output_metrics.set(&mut cx, "bytesRemoved", bytes_removed)?; output_metrics.set(&mut cx, "bytesRemoved", bytes_removed)?;
let old_versions = cx.number(prune_stats.old_versions as f64); let old_versions = cx.number(stats.old_versions as f64);
output_metrics.set(&mut cx, "oldVersions", old_versions)?; output_metrics.set(&mut cx, "oldVersions", old_versions)?;
let output_table = cx.boxed(JsTable::from(table)); let output_table = cx.boxed(JsTable::from(table));
@@ -321,15 +317,13 @@ impl JsTable {
rt.spawn(async move { rt.spawn(async move {
let stats = table let stats = table
.optimize(OptimizeAction::Compact { .as_native()
options, .unwrap()
remap_options: None, .compact_files(options, None)
})
.await; .await;
deferred.settle_with(&channel, move |mut cx| { deferred.settle_with(&channel, move |mut cx| {
let stats = stats.or_throw(&mut cx)?; let stats = stats.or_throw(&mut cx)?;
let stats = stats.compaction.as_ref().expect("Compact stats missing");
let output_metrics = JsObject::new(&mut cx); let output_metrics = JsObject::new(&mut cx);
let fragments_removed = cx.number(stats.fragments_removed as f64); let fragments_removed = cx.number(stats.fragments_removed as f64);

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "vectordb" name = "vectordb"
version = "0.4.6" version = "0.4.4"
edition = "2021" edition = "2021"
description = "LanceDB: A serverless, low-latency vector database for AI applications" description = "LanceDB: A serverless, low-latency vector database for AI applications"
license = "Apache-2.0" license = "Apache-2.0"

View File

@@ -68,87 +68,6 @@ pub trait Connection: Send + Sync {
async fn drop_table(&self, name: &str) -> Result<()>; async fn drop_table(&self, name: &str) -> Result<()>;
} }
#[derive(Debug)]
pub struct ConnectOptions {
/// Database URI
///
/// # Accpeted URI formats
///
/// - `/path/to/database` - local database on file system.
/// - `s3://bucket/path/to/database` or `gs://bucket/path/to/database` - database on cloud object store
/// - `db://dbname` - Lance Cloud
pub uri: String,
/// Lance Cloud API key
pub api_key: Option<String>,
/// Lance Cloud region
pub region: Option<String>,
/// Lance Cloud host override
pub host_override: Option<String>,
/// The maximum number of indices to cache in memory. Defaults to 256.
pub index_cache_size: u32,
}
impl ConnectOptions {
/// Create a new [`ConnectOptions`] with the given database URI.
pub fn new(uri: &str) -> Self {
Self {
uri: uri.to_string(),
api_key: None,
region: None,
host_override: None,
index_cache_size: 256,
}
}
pub fn api_key(mut self, api_key: &str) -> Self {
self.api_key = Some(api_key.to_string());
self
}
pub fn region(mut self, region: &str) -> Self {
self.region = Some(region.to_string());
self
}
pub fn host_override(mut self, host_override: &str) -> Self {
self.host_override = Some(host_override.to_string());
self
}
pub fn index_cache_size(mut self, index_cache_size: u32) -> Self {
self.index_cache_size = index_cache_size;
self
}
}
/// Connect to a LanceDB database.
///
/// # Arguments
///
/// - `uri` - URI where the database is located, can be a local file or a supported remote cloud storage
///
/// ## Accepted URI formats
///
/// - `/path/to/database` - local database on file system.
/// - `s3://bucket/path/to/database` or `gs://bucket/path/to/database` - database on cloud object store
/// - `db://dbname` - Lance Cloud
///
pub async fn connect(uri: &str) -> Result<Arc<dyn Connection>> {
let options = ConnectOptions::new(uri);
connect_with_options(&options).await
}
/// Connect with [`ConnectOptions`].
///
/// # Arguments
/// - `options` - [`ConnectOptions`] to connect to the database.
pub async fn connect_with_options(options: &ConnectOptions) -> Result<Arc<dyn Connection>> {
let db = Database::connect(&options.uri).await?;
Ok(Arc::new(db))
}
pub struct Database { pub struct Database {
object_store: ObjectStore, object_store: ObjectStore,
query_string: Option<String>, query_string: Option<String>,

View File

@@ -14,7 +14,6 @@
use std::{cmp::max, sync::Arc}; use std::{cmp::max, sync::Arc};
use lance::index::scalar::ScalarIndexParams;
use lance_index::{DatasetIndexExt, IndexType}; use lance_index::{DatasetIndexExt, IndexType};
pub use lance_linalg::distance::MetricType; pub use lance_linalg::distance::MetricType;
@@ -233,14 +232,10 @@ impl IndexBuilder {
let mut dataset = tbl.clone_inner_dataset(); let mut dataset = tbl.clone_inner_dataset();
match params { match params {
IndexParams::Scalar { replace } => { IndexParams::Scalar { replace } => {
dataset self.table
.create_index( .as_native()
&[&column], .unwrap()
IndexType::Scalar, .create_scalar_index(column, replace)
None,
&ScalarIndexParams::default(),
replace,
)
.await? .await?
} }
IndexParams::IvfPq { IndexParams::IvfPq {

View File

@@ -16,10 +16,10 @@
use std::io::Cursor; use std::io::Cursor;
use arrow_array::{RecordBatch, RecordBatchReader}; use arrow_array::RecordBatchReader;
use arrow_ipc::{reader::StreamReader, writer::FileWriter}; use arrow_ipc::reader::StreamReader;
use crate::{Error, Result}; use crate::Result;
/// Convert a Arrow IPC file to a batch reader /// Convert a Arrow IPC file to a batch reader
pub fn ipc_file_to_batches(buf: Vec<u8>) -> Result<impl RecordBatchReader> { pub fn ipc_file_to_batches(buf: Vec<u8>) -> Result<impl RecordBatchReader> {
@@ -28,22 +28,6 @@ pub fn ipc_file_to_batches(buf: Vec<u8>) -> Result<impl RecordBatchReader> {
Ok(reader) Ok(reader)
} }
/// Convert record batches to Arrow IPC file
pub fn batches_to_ipc_file(batches: &[RecordBatch]) -> Result<Vec<u8>> {
if batches.is_empty() {
return Err(Error::Store {
message: "No batches to write".to_string(),
});
}
let schema = batches[0].schema();
let mut writer = FileWriter::try_new(vec![], &schema)?;
for batch in batches {
writer.write(batch)?;
}
writer.finish()?;
Ok(writer.into_inner()?)
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {

View File

@@ -41,32 +41,15 @@
//! //!
//! ### Quick Start //! ### Quick Start
//! //!
//! <div class="warning">Rust API is not stable yet, please expect breaking changes.</div> //! <div class="warning">Rust API is not stable yet.</div>
//! //!
//! #### Connect to a database. //! #### Connect to a database.
//! //!
//! ```rust //! ```rust
//! use vectordb::connect; //! use vectordb::connection::Database;
//! # use arrow_schema::{Field, Schema}; //! # use arrow_schema::{Field, Schema};
//! # tokio::runtime::Runtime::new().unwrap().block_on(async { //! # tokio::runtime::Runtime::new().unwrap().block_on(async {
//! let db = connect("data/sample-lancedb").await.unwrap(); //! let db = Database::connect("data/sample-lancedb").await.unwrap();
//! # });
//! ```
//!
//! LanceDB accepts the different form of database path:
//!
//! - `/path/to/database` - local database on file system.
//! - `s3://bucket/path/to/database` or `gs://bucket/path/to/database` - database on cloud object store
//! - `db://dbname` - Lance Cloud
//!
//! You can also use [`ConnectOptions`] to configure the connectoin to the database.
//!
//! ```rust
//! use vectordb::{connect_with_options, ConnectOptions};
//! # tokio::runtime::Runtime::new().unwrap().block_on(async {
//! let options = ConnectOptions::new("data/sample-lancedb")
//! .index_cache_size(1024);
//! let db = connect_with_options(&options).await.unwrap();
//! # }); //! # });
//! ``` //! ```
//! //!
@@ -74,8 +57,6 @@
//! It treats [`FixedSizeList<Float16/Float32>`](https://docs.rs/arrow/latest/arrow/array/struct.FixedSizeListArray.html) //! It treats [`FixedSizeList<Float16/Float32>`](https://docs.rs/arrow/latest/arrow/array/struct.FixedSizeListArray.html)
//! columns as vector columns. //! columns as vector columns.
//! //!
//! For more details, please refer to [LanceDB documentation](https://lancedb.github.io/lancedb/).
//!
//! #### Create a table //! #### Create a table
//! //!
//! To create a Table, you need to provide a [`arrow_schema::Schema`] and a [`arrow_array::RecordBatch`] stream. //! To create a Table, you need to provide a [`arrow_schema::Schema`] and a [`arrow_array::RecordBatch`] stream.
@@ -86,11 +67,10 @@
//! use arrow_array::{RecordBatch, RecordBatchIterator}; //! use arrow_array::{RecordBatch, RecordBatchIterator};
//! # use arrow_array::{FixedSizeListArray, Float32Array, Int32Array, types::Float32Type}; //! # use arrow_array::{FixedSizeListArray, Float32Array, Int32Array, types::Float32Type};
//! # use vectordb::connection::{Database, Connection}; //! # use vectordb::connection::{Database, Connection};
//! # use vectordb::connect;
//! //!
//! # tokio::runtime::Runtime::new().unwrap().block_on(async { //! # tokio::runtime::Runtime::new().unwrap().block_on(async {
//! # let tmpdir = tempfile::tempdir().unwrap(); //! # let tmpdir = tempfile::tempdir().unwrap();
//! # let db = connect(tmpdir.path().to_str().unwrap()).await.unwrap(); //! # let db = Database::connect(tmpdir.path().to_str().unwrap()).await.unwrap();
//! let schema = Arc::new(Schema::new(vec![ //! let schema = Arc::new(Schema::new(vec![
//! Field::new("id", DataType::Int32, false), //! Field::new("id", DataType::Int32, false),
//! Field::new("vector", DataType::FixedSizeList( //! Field::new("vector", DataType::FixedSizeList(
@@ -114,13 +94,13 @@
//! //!
//! ```no_run //! ```no_run
//! # use std::sync::Arc; //! # use std::sync::Arc;
//! # use vectordb::connect; //! # use vectordb::connection::{Database, Connection};
//! # use arrow_array::{FixedSizeListArray, types::Float32Type, RecordBatch, //! # use arrow_array::{FixedSizeListArray, types::Float32Type, RecordBatch,
//! # RecordBatchIterator, Int32Array}; //! # RecordBatchIterator, Int32Array};
//! # use arrow_schema::{Schema, Field, DataType}; //! # use arrow_schema::{Schema, Field, DataType};
//! # tokio::runtime::Runtime::new().unwrap().block_on(async { //! # tokio::runtime::Runtime::new().unwrap().block_on(async {
//! # let tmpdir = tempfile::tempdir().unwrap(); //! # let tmpdir = tempfile::tempdir().unwrap();
//! # let db = connect(tmpdir.path().to_str().unwrap()).await.unwrap(); //! # let db = Database::connect(tmpdir.path().to_str().unwrap()).await.unwrap();
//! # let tbl = db.open_table("idx_test").await.unwrap(); //! # let tbl = db.open_table("idx_test").await.unwrap();
//! tbl.create_index(&["vector"]) //! tbl.create_index(&["vector"])
//! .ivf_pq() //! .ivf_pq()
@@ -186,6 +166,4 @@ pub use connection::{Connection, Database};
pub use error::{Error, Result}; pub use error::{Error, Result};
pub use table::{Table, TableRef}; pub use table::{Table, TableRef};
/// Connect to a database
pub use connection::{connect, connect_with_options, ConnectOptions};
pub use lance::dataset::WriteMode; pub use lance::dataset::WriteMode;

View File

@@ -22,7 +22,6 @@ use lance_linalg::distance::MetricType;
use crate::error::Result; use crate::error::Result;
use crate::utils::default_vector_column; use crate::utils::default_vector_column;
use crate::Error;
const DEFAULT_TOP_K: usize = 10; const DEFAULT_TOP_K: usize = 10;
@@ -94,19 +93,6 @@ impl Query {
let arrow_schema = Schema::from(self.dataset.schema()); let arrow_schema = Schema::from(self.dataset.schema());
default_vector_column(&arrow_schema, Some(query.len() as i32))? default_vector_column(&arrow_schema, Some(query.len() as i32))?
}; };
let field = self.dataset.schema().field(&column).ok_or(Error::Store {
message: format!("Column {} not found in dataset schema", column),
})?;
if !matches!(field.data_type(), arrow_schema::DataType::FixedSizeList(f, dim) if f.data_type().is_floating() && dim == query.len() as i32)
{
return Err(Error::Store {
message: format!(
"Vector column '{}' does not match the dimension of the query vector: dim={}",
column,
query.len(),
),
});
}
scanner.nearest(&column, query, self.limit.unwrap_or(DEFAULT_TOP_K))?; scanner.nearest(&column, query, self.limit.unwrap_or(DEFAULT_TOP_K))?;
} else { } else {
// If there is no vector query, it's ok to not have a limit // If there is no vector query, it's ok to not have a limit

View File

@@ -27,9 +27,9 @@ use lance::dataset::optimize::{
}; };
pub use lance::dataset::ReadParams; pub use lance::dataset::ReadParams;
use lance::dataset::{Dataset, UpdateBuilder, WriteParams}; use lance::dataset::{Dataset, UpdateBuilder, WriteParams};
use lance::index::scalar::ScalarIndexParams;
use lance::io::WrappingObjectStore; use lance::io::WrappingObjectStore;
use lance_index::{optimize::OptimizeOptions, DatasetIndexExt}; use lance_index::{optimize::OptimizeOptions, DatasetIndexExt, IndexType};
use log::info;
use crate::error::{Error, Result}; use crate::error::{Error, Result};
use crate::index::vector::{VectorIndex, VectorIndexStatistics}; use crate::index::vector::{VectorIndex, VectorIndexStatistics};
@@ -38,46 +38,7 @@ use crate::query::Query;
use crate::utils::{PatchReadParam, PatchWriteParam}; use crate::utils::{PatchReadParam, PatchWriteParam};
use crate::WriteMode; use crate::WriteMode;
/// Optimize the dataset. pub const VECTOR_COLUMN_NAME: &str = "vector";
///
/// Similar to `VACUUM` in PostgreSQL, it offers different options to
/// optimize different parts of the table on disk.
///
/// By default, it optimizes everything, as [`OptimizeAction::All`].
pub enum OptimizeAction {
/// Run optimization on every, with default options.
All,
/// Compact files in the dataset
Compact {
options: CompactionOptions,
remap_options: Option<Arc<dyn IndexRemapperOptions>>,
},
/// Prune old version of datasets.
Prune {
/// The duration of time to keep versions of the dataset.
older_than: Duration,
/// Because they may be part of an in-progress transaction, files newer than 7 days old are not deleted by default.
/// If you are sure that there are no in-progress transactions, then you can set this to True to delete all files older than `older_than`.
delete_unverified: Option<bool>,
},
/// Optimize index.
Index(OptimizeOptions),
}
impl Default for OptimizeAction {
fn default() -> Self {
Self::All
}
}
/// Statistics about the optimization.
pub struct OptimizeStats {
/// Stats of the file compaction.
pub compaction: Option<CompactionMetrics>,
/// Stats of the version pruning
pub prune: Option<RemovalStats>,
}
/// A Table is a collection of strong typed Rows. /// A Table is a collection of strong typed Rows.
/// ///
@@ -233,14 +194,6 @@ pub trait Table: std::fmt::Display + Send + Sync {
/// # }); /// # });
/// ``` /// ```
fn query(&self) -> Query; fn query(&self) -> Query;
/// Optimize the on-disk data and indices for better performance.
///
/// <section class="warning">Experimental API</section>
///
/// Modeled after ``VACCUM`` in PostgreSQL.
/// Not all implementations support explicit optimization.
async fn optimize(&self, action: OptimizeAction) -> Result<OptimizeStats>;
} }
/// Reference to a Table pointer. /// Reference to a Table pointer.
@@ -443,8 +396,17 @@ impl NativeTable {
self.dataset.lock().expect("lock poison").version().version self.dataset.lock().expect("lock poison").version().version
} }
async fn optimize_indices(&self, options: &OptimizeOptions) -> Result<()> { /// Create a scalar index on the table
info!("LanceDB: optimizing indices: {:?}", options); pub async fn create_scalar_index(&self, column: &str, replace: bool) -> Result<()> {
let mut dataset = self.clone_inner_dataset();
let params = ScalarIndexParams::default();
dataset
.create_index(&[column], IndexType::Scalar, None, &params, replace)
.await?;
Ok(())
}
pub async fn optimize_indices(&mut self, options: &OptimizeOptions) -> Result<()> {
let mut dataset = self.clone_inner_dataset(); let mut dataset = self.clone_inner_dataset();
dataset.optimize_indices(options).await?; dataset.optimize_indices(options).await?;
@@ -501,7 +463,7 @@ impl NativeTable {
/// ///
/// This calls into [lance::dataset::Dataset::cleanup_old_versions] and /// This calls into [lance::dataset::Dataset::cleanup_old_versions] and
/// returns the result. /// returns the result.
async fn cleanup_old_versions( pub async fn cleanup_old_versions(
&self, &self,
older_than: Duration, older_than: Duration,
delete_unverified: Option<bool>, delete_unverified: Option<bool>,
@@ -518,7 +480,7 @@ impl NativeTable {
/// for faster reads. /// for faster reads.
/// ///
/// This calls into [lance::dataset::optimize::compact_files]. /// This calls into [lance::dataset::optimize::compact_files].
async fn compact_files( pub async fn compact_files(
&self, &self,
options: CompactionOptions, options: CompactionOptions,
remap_options: Option<Arc<dyn IndexRemapperOptions>>, remap_options: Option<Arc<dyn IndexRemapperOptions>>,
@@ -652,52 +614,6 @@ impl Table for NativeTable {
self.reset_dataset(dataset); self.reset_dataset(dataset);
Ok(()) Ok(())
} }
async fn optimize(&self, action: OptimizeAction) -> Result<OptimizeStats> {
let mut stats = OptimizeStats {
compaction: None,
prune: None,
};
match action {
OptimizeAction::All => {
stats.compaction = self
.optimize(OptimizeAction::Compact {
options: CompactionOptions::default(),
remap_options: None,
})
.await?
.compaction;
stats.prune = self
.optimize(OptimizeAction::Prune {
older_than: Duration::days(7),
delete_unverified: None,
})
.await?
.prune;
self.optimize(OptimizeAction::Index(OptimizeOptions::default()))
.await?;
}
OptimizeAction::Compact {
options,
remap_options,
} => {
stats.compaction = Some(self.compact_files(options, remap_options).await?);
}
OptimizeAction::Prune {
older_than,
delete_unverified,
} => {
stats.prune = Some(
self.cleanup_old_versions(older_than, delete_unverified)
.await?,
);
}
OptimizeAction::Index(options) => {
self.optimize_indices(&options).await?;
}
}
Ok(stats)
}
} }
#[cfg(test)] #[cfg(test)]