vectordb / 导出
向量数据库
目录
枚举类型
类
接口
- AwsCredentials
- CleanupStats
- ColumnAlteration
- CompactionMetrics
- CompactionOptions
- 连接
- ConnectionOptions
- CreateTableOptions
- EmbeddingFunction
- IndexStats
- IvfPQIndexConfig
- MergeInsertArgs
- Table
- UpdateArgs
- UpdateSqlArgs
- VectorIndex
- WriteOptions
类型别名
功能
类型别名
VectorIndexParams
Ƭ VectorIndexParams: IvfPQIndexConfig
定义于
功能
连接
▸ 连接(uri): Promise\<Connection>
连接到给定URI的LanceDB实例。
接受的格式:
/path/to/database- 本地数据库s3://bucket/path/to/database或gs://bucket/path/to/database- 云存储上的数据库db://host:port- 远程数据库(LanceDB云服务)
参数
| 名称 | 类型 | 描述 |
|---|---|---|
uri |
string |
The uri of the database. If the database uri starts with db:// then it connects to a remote database. |
返回值
Promise\<Connection>
查看
ConnectionOptions 有关URI格式的更多详情。
定义于
▸ connect(opts): Promise\<Connection>
使用连接选项连接到LanceDB实例。
参数
| 名称 | 类型 | 描述 |
|---|---|---|
opts |
Partial\<ConnectionOptions> |
The ConnectionOptions to use when connecting to the database. |
返回值
Promise\<Connection>
定义于
convertToTable
▸ convertToTable\<T>(data, embeddings?, makeTableOptions?): Promise\<ArrowTable>
类型参数
| 名称 |
|---|
T |
参数
| 名称 | 类型 |
|---|---|
data |
Record\<string, unknown>[] |
embeddings? |
EmbeddingFunction\<T> |
makeTableOptions? |
Partial\<MakeArrowTableOptions> |
返回值
Promise\<ArrowTable>
定义于
isWriteOptions
▸ isWriteOptions(value): value 是 WriteOptions 类型
参数
| 名称 | 类型 |
|---|---|
value |
any |
返回值
value 是 WriteOptions
定义于
makeArrowTable
▸ makeArrowTable(data, options?): ArrowTable
Apache Arrow中makeTable函数的增强版本,支持嵌套字段和嵌入列。
该函数将Record
请注意,目前不支持空值。
如果提供了模式(schema),则将使用它来确定结果数组的类型。字段也将重新排序以符合模式定义的结构顺序。
如果未提供模式(schema),则将推断类型,字段顺序将由第一条记录中的属性顺序决定。
如果输入为空,则必须提供一个模式(schema)来创建空表。
当未指定模式时,数据类型将被推断。推断规则如下:
- boolean => Bool
- number => Float64
- 字符串 => Utf8
- 缓冲区 => 二进制
- Record
=> 结构体 - Array
=> 列表
参数
| 名称 | 类型 | 描述 |
|---|---|---|
data |
Record\<string, any>[] |
input data |
options? |
Partial\<MakeArrowTableOptions> |
options to control the makeArrowTable call. |
返回值
ArrowTable
示例
import { fromTableToBuffer, makeArrowTable } from "../arrow";
import { Field, FixedSizeList, Float16, Float32, Int32, Schema } from "apache-arrow";
const schema = new Schema([
new Field("a", new Int32()),
new Field("b", new Float32()),
new Field("c", new FixedSizeList(3, new Field("item", new Float16()))),
]);
const table = makeArrowTable([
{ a: 1, b: 2, c: [1, 2, 3] },
{ a: 4, b: 5, c: [4, 5, 6] },
{ a: 7, b: 8, c: [7, 8, 9] },
], { schema });
默认情况下,它假设名为vector的列是向量列,并将被转换为float32类型的固定大小列表数组。可以使用vectorColumns选项来支持其他向量列名称和数据类型。
const schema = new Schema([
new Field("a", new Float64()),
new Field("b", new Float64()),
new Field(
"vector",
new FixedSizeList(3, new Field("item", new Float32()))
),
]);
const table = makeArrowTable([
{ a: 1, b: 2, vector: [1, 2, 3] },
{ a: 4, b: 5, vector: [4, 5, 6] },
{ a: 7, b: 8, vector: [7, 8, 9] },
]);
assert.deepEqual(table.schema, schema);
你也可以通过选项指定向量列的类型和名称
const schema = new Schema([
new Field('a', new Float64()),
new Field('b', new Float64()),
new Field('vec1', new FixedSizeList(3, new Field('item', new Float16()))),
new Field('vec2', new FixedSizeList(3, new Field('item', new Float16())))
]);
const table = makeArrowTable([
{ a: 1, b: 2, vec1: [1, 2, 3], vec2: [2, 4, 6] },
{ a: 4, b: 5, vec1: [4, 5, 6], vec2: [8, 10, 12] },
{ a: 7, b: 8, vec1: [7, 8, 9], vec2: [14, 16, 18] }
], {
vectorColumns: {
vec1: { type: new Float16() },
vec2: { type: new Float16() }
}
}
assert.deepEqual(table.schema, schema)