替换数据集节点
概述
Replace Dataset节点用于在图形执行期间替换数据集中的所有数据为新数据,或清除数据集中的数据。
节点在运行图时需要上下文中有一个可用的数据集提供者。数据集提供者负责管理数据集的存储和检索。在Rivet应用程序中,数据集提供者会自动为您处理。
有关数据集的更多信息,请参阅用户指南中的Data Studio部分。
- 输入
- 输出
- 编辑器设置
输入项
标题 | 数据类型 | 描述 | 默认值 | 备注 |
---|---|---|---|---|
Data | object[] | The new data of the dataset. If empty, the dataset will be cleared. May be an array of array of strings, or an array of DatasetRow objects with { id, data } properties. If a string[][], IDs will be generated. | (empty) | The input will be coerced into an object array if it is not an object array. |
Dataset ID | string | The ID of the dataset to replace. This input is only available if Use Dataset ID Input is enabled. | (required if 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 new data of the dataset. An array of DatasetRow objects with { id, data } properties. | The output will be an object containing the ID, data, and embedding of the new row. |
编辑器设置
设置 | 描述 | 默认值 | 使用输入切换 | 输入数据类型 |
---|---|---|---|---|
Dataset | The ID of the dataset to replace. | (required) | Yes | string |
示例1:替换数据集中的数据
- 在Data Studio中,创建一个ID为
employees
的新数据集,并向其中添加一些数据。 - 为第一行创建一个Array Node,并将值设置为
["John Doe", "30", "Engineer"]
。 - 创建另一个Array Node,禁用其Flattening功能,并将第一个Array Node连接到它。
- 创建一个替换数据集节点并将数据集设置为
Employees
。 - 将Array节点连接到Replace Dataset节点的
Data
输入端口。 - 运行图表。Replace Dataset节点的
Dataset
输出应包含替换employees
数据集中现有数据的新数据。
错误处理
如果在运行图表时上下文中的数据集提供程序不可用,Replace Dataset Node 将会报错。
常见问题
问:什么是数据集提供者?
A: 数据集提供者是一个负责管理数据集存储和检索的对象。当图表运行时,它会被传递给上下文。数据集提供者必须实现DatasetProvider
接口,该接口包含获取、存放和删除数据集的方法。更多信息请参阅API参考文档。
问:如果数据集不存在会发生什么?
A: 如果数据集不存在,Replace Dataset Node 将会报错。