Elffuss BraidHub

kikocis/lancedb public

main · 7.2 KiBRenderedRawPermalink
1[vectordb](README.md) / Exports
2
3# vectordb
4
5## Table of contents
6
7### Enumerations
8
9- [IndexStatus](enums/IndexStatus.md)
10- [MetricType](enums/MetricType.md)
11- [WriteMode](enums/WriteMode.md)
12
13### Classes
14
15- [DefaultWriteOptions](classes/DefaultWriteOptions.md)
16- [LocalConnection](classes/LocalConnection.md)
17- [LocalTable](classes/LocalTable.md)
18- [MakeArrowTableOptions](classes/MakeArrowTableOptions.md)
19- [OpenAIEmbeddingFunction](classes/OpenAIEmbeddingFunction.md)
20- [Query](classes/Query.md)
21
22### Interfaces
23
24- [AwsCredentials](interfaces/AwsCredentials.md)
25- [CleanupStats](interfaces/CleanupStats.md)
26- [ColumnAlteration](interfaces/ColumnAlteration.md)
27- [CompactionMetrics](interfaces/CompactionMetrics.md)
28- [CompactionOptions](interfaces/CompactionOptions.md)
29- [Connection](interfaces/Connection.md)
30- [ConnectionOptions](interfaces/ConnectionOptions.md)
31- [CreateTableOptions](interfaces/CreateTableOptions.md)
32- [EmbeddingFunction](interfaces/EmbeddingFunction.md)
33- [IndexStats](interfaces/IndexStats.md)
34- [IvfPQIndexConfig](interfaces/IvfPQIndexConfig.md)
35- [MergeInsertArgs](interfaces/MergeInsertArgs.md)
36- [Table](interfaces/Table.md)
37- [UpdateArgs](interfaces/UpdateArgs.md)
38- [UpdateSqlArgs](interfaces/UpdateSqlArgs.md)
39- [VectorIndex](interfaces/VectorIndex.md)
40- [WriteOptions](interfaces/WriteOptions.md)
41
42### Type Aliases
43
44- [VectorIndexParams](modules.md#vectorindexparams)
45
46### Functions
47
48- [connect](modules.md#connect)
49- [convertToTable](modules.md#converttotable)
50- [isWriteOptions](modules.md#iswriteoptions)
51- [makeArrowTable](modules.md#makearrowtable)
52
53## Type Aliases
54
55### VectorIndexParams
56
57Ƭ **VectorIndexParams**: [`IvfPQIndexConfig`](interfaces/IvfPQIndexConfig.md)
58
59#### Defined in
60
61[index.ts:1336](https://github.com/lancedb/lancedb/blob/92179835/node/src/index.ts#L1336)
62
63## Functions
64
65### connect
66
67▸ **connect**(`uri`): `Promise`\<[`Connection`](interfaces/Connection.md)\>
68
69Connect to a LanceDB instance at the given URI.
70
71Accepted formats:
72
73- `/path/to/database` - local database
74- `s3://bucket/path/to/database` or `gs://bucket/path/to/database` - database on cloud storage
75- `db://host:port` - remote database (LanceDB cloud)
76
77#### Parameters
78
79| Name | Type | Description |
80| :------ | :------ | :------ |
81| `uri` | `string` | The uri of the database. If the database uri starts with `db://` then it connects to a remote database. |
82
83#### Returns
84
85`Promise`\<[`Connection`](interfaces/Connection.md)\>
86
87**`See`**
88
89[ConnectionOptions](interfaces/ConnectionOptions.md) for more details on the URI format.
90
91#### Defined in
92
93[index.ts:188](https://github.com/lancedb/lancedb/blob/92179835/node/src/index.ts#L188)
94
95▸ **connect**(`opts`): `Promise`\<[`Connection`](interfaces/Connection.md)\>
96
97Connect to a LanceDB instance with connection options.
98
99#### Parameters
100
101| Name | Type | Description |
102| :------ | :------ | :------ |
103| `opts` | `Partial`\<[`ConnectionOptions`](interfaces/ConnectionOptions.md)\> | The [ConnectionOptions](interfaces/ConnectionOptions.md) to use when connecting to the database. |
104
105#### Returns
106
107`Promise`\<[`Connection`](interfaces/Connection.md)\>
108
109#### Defined in
110
111[index.ts:194](https://github.com/lancedb/lancedb/blob/92179835/node/src/index.ts#L194)
112
113___
114
115### convertToTable
116
117▸ **convertToTable**\<`T`\>(`data`, `embeddings?`, `makeTableOptions?`): `Promise`\<`ArrowTable`\>
118
119#### Type parameters
120
121| Name |
122| :------ |
123| `T` |
124
125#### Parameters
126
127| Name | Type |
128| :------ | :------ |
129| `data` | `Record`\<`string`, `unknown`\>[] |
130| `embeddings?` | [`EmbeddingFunction`](interfaces/EmbeddingFunction.md)\<`T`\> |
131| `makeTableOptions?` | `Partial`\<[`MakeArrowTableOptions`](classes/MakeArrowTableOptions.md)\> |
132
133#### Returns
134
135`Promise`\<`ArrowTable`\>
136
137#### Defined in
138
139[arrow.ts:465](https://github.com/lancedb/lancedb/blob/92179835/node/src/arrow.ts#L465)
140
141___
142
143### isWriteOptions
144
145▸ **isWriteOptions**(`value`): value is WriteOptions
146
147#### Parameters
148
149| Name | Type |
150| :------ | :------ |
151| `value` | `any` |
152
153#### Returns
154
155value is WriteOptions
156
157#### Defined in
158
159[index.ts:1362](https://github.com/lancedb/lancedb/blob/92179835/node/src/index.ts#L1362)
160
161___
162
163### makeArrowTable
164
165▸ **makeArrowTable**(`data`, `options?`): `ArrowTable`
166
167An enhanced version of the makeTable function from Apache Arrow
168that supports nested fields and embeddings columns.
169
170This function converts an array of Record<String, any> (row-major JS objects)
171to an Arrow Table (a columnar structure)
172
173Note that it currently does not support nulls.
174
175If a schema is provided then it will be used to determine the resulting array
176types. Fields will also be reordered to fit the order defined by the schema.
177
178If a schema is not provided then the types will be inferred and the field order
179will be controlled by the order of properties in the first record.
180
181If the input is empty then a schema must be provided to create an empty table.
182
183When a schema is not specified then data types will be inferred. The inference
184rules are as follows:
185
186 - boolean => Bool
187 - number => Float64
188 - String => Utf8
189 - Buffer => Binary
190 - Record<String, any> => Struct
191 - Array<any> => List
192
193#### Parameters
194
195| Name | Type | Description |
196| :------ | :------ | :------ |
197| `data` | `Record`\<`string`, `any`\>[] | input data |
198| `options?` | `Partial`\<[`MakeArrowTableOptions`](classes/MakeArrowTableOptions.md)\> | options to control the makeArrowTable call. |
199
200#### Returns
201
202`ArrowTable`
203
204**`Example`**
205
206```ts
207
208import { fromTableToBuffer, makeArrowTable } from "../arrow";
209import { Field, FixedSizeList, Float16, Float32, Int32, Schema } from "apache-arrow";
210
211const schema = new Schema([
212 new Field("a", new Int32()),
213 new Field("b", new Float32()),
214 new Field("c", new FixedSizeList(3, new Field("item", new Float16()))),
215 ]);
216 const table = makeArrowTable([
217 { a: 1, b: 2, c: [1, 2, 3] },
218 { a: 4, b: 5, c: [4, 5, 6] },
219 { a: 7, b: 8, c: [7, 8, 9] },
220 ], { schema });
221```
222
223By default it assumes that the column named `vector` is a vector column
224and it will be converted into a fixed size list array of type float32.
225The `vectorColumns` option can be used to support other vector column
226names and data types.
227
228```ts
229
230const schema = new Schema([
231 new Field("a", new Float64()),
232 new Field("b", new Float64()),
233 new Field(
234 "vector",
235 new FixedSizeList(3, new Field("item", new Float32()))
236 ),
237 ]);
238 const table = makeArrowTable([
239 { a: 1, b: 2, vector: [1, 2, 3] },
240 { a: 4, b: 5, vector: [4, 5, 6] },
241 { a: 7, b: 8, vector: [7, 8, 9] },
242 ]);
243 assert.deepEqual(table.schema, schema);
244```
245
246You can specify the vector column types and names using the options as well
247
248```typescript
249
250const schema = new Schema([
251 new Field('a', new Float64()),
252 new Field('b', new Float64()),
253 new Field('vec1', new FixedSizeList(3, new Field('item', new Float16()))),
254 new Field('vec2', new FixedSizeList(3, new Field('item', new Float16())))
255 ]);
256const table = makeArrowTable([
257 { a: 1, b: 2, vec1: [1, 2, 3], vec2: [2, 4, 6] },
258 { a: 4, b: 5, vec1: [4, 5, 6], vec2: [8, 10, 12] },
259 { a: 7, b: 8, vec1: [7, 8, 9], vec2: [14, 16, 18] }
260 ], {
261 vectorColumns: {
262 vec1: { type: new Float16() },
263 vec2: { type: new Float16() }
264 }
265 }
266assert.deepEqual(table.schema, schema)
267```
268
269#### Defined in
270
271[arrow.ts:198](https://github.com/lancedb/lancedb/blob/92179835/node/src/arrow.ts#L198)