Components
BaseComponent
BaseComponent()Source: hetu/data/component.py:115
所有组件的基类
Attributes
dtypes(np.dtype) — 组件的numpy格式的dtype信息
Methods
new_row
new_row(id_=None) -> numpy.recordSource: hetu/data/component.py:225
返回空数据行,id请设置为None,会自动生成规范雪花uuid,用于insert
new_rows
new_rows(size) -> numpy.rec.recarraySource: hetu/data/component.py:235
返回多行空数据行,用于批量insert
dict_to_struct
dict_to_struct(data: dict) -> numpy.recordSource: hetu/data/component.py:245
从dict转换为c-struct like的类型,成为可直接传给数据库的行数据
struct_to_dict
struct_to_dict(data: numpy.record) -> dict[str, typing.Any]Source: hetu/data/component.py:253
从c-struct like的行数据转换为typed dict
duplicate
duplicate(namespace: str, suffix: str) -> type[hetu.data.component.BaseComponent]Source: hetu/data/component.py:259
复制一个新的副本组件。拥有相同的定义,但使用suffix结尾的新的名字。
注意:只能在 define_system 时,传递成员变量时使用,如:
@hetu.define_system(namespace="Loot", components=(Order.duplicate("Loot", "Copy"),))get_duplicates
get_duplicates(namespace: str) -> dict[str, type[hetu.data.component.BaseComponent]]Source: hetu/data/component.py:281
获取此Component在指定namespace下的所有副本实例
is_rls
is_rls() -> boolSource: hetu/data/component.py:286
判断此Component是否是RLS权限
Permission
Permission(*values)Source: hetu/common/permission.py:11
Bases: IntEnum
客户端访问权限级别。
用于 define_endpoint
/ define_system
暴露给客户端的调用权限,也用于
define_component
声明Component数据的读取权限。服务端内部代码不受这些权限
限制;业务逻辑中的写入权限和更细粒度安全检查仍需要自行实现。
Attributes
EVERYBODY(Any) — 任何客户端连接都允许访问;适合公开状态、公告、配置等低敏感数据。USER(Any) — 仅已登录客户端允许访问;要求ctx.caller有有效用户id。OWNER(Any) — Component行级读取权限;等同于RLS且预设rls_compare=("eq", "owner", "caller")。RLS(Any) — Component自定义行级读取权限;具体比较逻辑由rls_compare参数定义。ADMIN(Any) — 仅管理员连接允许访问;要求ctx.is_admin()返回True。