加载数据集节点
概述
加载数据集节点用于将数据集的全部内容载入图中。这些数据随后可以在图中的其他节点中使用。
Load Dataset节点输出一个数据集行的数组。每行具有以下结构:
{
"id": "1", // The ID of the row
"embedding": [], // The vector embedding of the row, if it has been saved with an embedding
"data": [] // The data of the row, each element in the array corresponds to a column in the dataset
}
要访问行的数据,您可以使用Extract Object Path Node从每行中提取data
属性。如果在Extract Object Path Node中使用jsonpath $[*].data
,您将获得一个数组的数组,其中每个内部数组代表数据集中的一行。
您可以通过在Extract Object Path节点中使用$[0].data
来从数据集中提取单行数据。这将返回一个值数组,其中每个值对应数据集中的一列。
您可以通过在Extract Object Path节点中使用$[*].data[0]
来从数据集中提取单个列。这将返回一个值数组,其中每个值对应数据集中的一行。
节点在运行图时需要上下文中有一个可用的数据集提供者。数据集提供者负责管理数据集的存储和检索。在Rivet应用程序中,数据集提供者会自动为您处理。
有关数据集的更多信息,请参阅用户指南中的Data Studio部分。
- 输入
- 输出
- 编辑器设置
输入项
标题 | 数据类型 | 描述 | 默认值 | 备注 |
---|---|---|---|---|
Dataset ID | string | The ID of the dataset to load. This input is only available if Use Dataset ID Input is enabled in the editor settings. | (required if the input toggle for Dataset ID is enabled) | The input will be coerced into a string if it is not a string. |
输出
标题 | 数据类型 | 描述 | 备注 |
---|---|---|---|
Dataset | object[] | The dataset that was loaded. Each object in the array represents a row in the dataset. | If the dataset does not exist, the node will error. |
Dataset ID | string | The ID of the dataset that was loaded. This output will be the same as the Dataset ID input or the Dataset ID specified in the settings. |
编辑器设置
设置 | 描述 | 默认值 | 使用输入切换 | 输入数据类型 |
---|---|---|---|---|
Dataset | The ID of the dataset to load. | (required) | Yes | string |
示例1:加载数据集
- 在Data Studio中,创建一个ID为
employees
的新数据集。 - 创建一个加载数据集节点并将数据集ID设置为
employees
。 - 运行图表。Load Dataset节点的
Dataset
输出应包含完整的employees
数据集。
错误处理
如果在运行图表时上下文环境中数据集提供程序不可用,Load Dataset Node 将会报错。如果没有提供 Dataset ID 输入或数据集不存在,它也会报错。
常见问题
问:什么是数据集提供者?
A: 数据集提供者是一个负责管理数据集存储和检索的对象。当图表运行时,它会被传递给上下文。数据集提供者必须实现DatasetProvider
接口,该接口包含获取、存放和删除数据集的方法。更多信息请参阅API参考文档。
问:我可以一次性加载多个数据集吗?
A: 不,Load Dataset Node 一次只能加载一个数据集。如果您想加载多个数据集,可以使用多个 Load Dataset Node。
问:如果数据集不存在会发生什么?
A: 如果数据集不存在,Load Dataset Node 将会报错。