pub struct CreateTableRequest {Show 18 fields
pub table_name: String,
pub primary_keys: Vec<PrimaryKeySchema>,
pub defined_columns: Vec<DefinedColumnSchema>,
pub reserved_throughput_read: Option<i32>,
pub reserved_throughput_write: Option<i32>,
pub ttl_seconds: Option<i32>,
pub max_versions: Option<i32>,
pub deviation_cell_version_in_sec: Option<i64>,
pub allow_update: Option<bool>,
pub stream_enabled: bool,
pub stream_expiration_hour: Option<i32>,
pub stream_columns: HashSet<String>,
pub sse_enabled: bool,
pub sse_key_type: Option<SseKeyType>,
pub sse_key_id: Option<String>,
pub sse_arn: Option<String>,
pub enable_local_txn: Option<bool>,
pub indexes: Vec<IndexMeta>,
}
Expand description
根据给定的表结构信息创建相应的数据表的请求。
根据官方文档 https://help.aliyun.com/zh/tablestore/table-operations 2025-03-06 10:05:03 更新的内容,在创建表的时候,支持设置以下内容:
- 主键
- 数据版本和生命周期
- 预留读写吞吐量
- 二级索引
- 数据加密
- 本地事务
所以,虽然 table_store.proto
文件中的 CreateTableRequest
包含了分区相关的,但是这里没有放上来。对应的 Java SDK 5.17.5 版本中创建宽表的时候也是没有分区设定的。
Fields§
§table_name: String
表名
primary_keys: Vec<PrimaryKeySchema>
全部主键列
defined_columns: Vec<DefinedColumnSchema>
预定义列
reserved_throughput_read: Option<i32>
预留读取吞吐量
reserved_throughput_write: Option<i32>
预留写入吞吐量
ttl_seconds: Option<i32>
数据生命周期,即数据的过期时间。当数据的保存时间超过设置的数据生命周期时,系统会自动清理超过数据生命周期的数据。 数据生命周期至少为86400秒(一天)或-1(数据永不过期)。
max_versions: Option<i32>
最大版本数,即属性列能够保留数据的最大版本个数。当属性列数据的版本个数超过设置的最大版本数时,系统会自动删除较早版本的数据。
deviation_cell_version_in_sec: Option<i64>
有效版本偏差,即写入数据的时间戳与系统当前时间的偏差允许最大值。只有当写入数据所有列的版本号与写入时时间的差值在数据有效版本偏差范围内,数据才能成功写入。
allow_update: Option<bool>
是否允许通过 UpdateRow 更新写入数据。
stream_enabled: bool
该表是否打开stream。
stream_expiration_hour: Option<i32>
该表的stream过期时间。
stream_columns: HashSet<String>
§sse_enabled: bool
是否启用加密
sse_key_type: Option<SseKeyType>
加密密钥类型
sse_key_id: Option<String>
当密钥类型为 BYOK 时需要
sse_arn: Option<String>
当密钥类型为 BYOK 时需要
enable_local_txn: Option<bool>
是否启用本地事务
indexes: Vec<IndexMeta>
二级索引
Implementations§
Source§impl CreateTableRequest
impl CreateTableRequest
pub fn new(table_name: &str) -> Self
Sourcepub fn primary_key(self, pk: PrimaryKeySchema) -> Self
pub fn primary_key(self, pk: PrimaryKeySchema) -> Self
添加一个主键列
Sourcepub fn primary_keys(
self,
pks: impl IntoIterator<Item = PrimaryKeySchema>,
) -> Self
pub fn primary_keys( self, pks: impl IntoIterator<Item = PrimaryKeySchema>, ) -> Self
设置主键列
Sourcepub fn primary_key_string(self, name: &str) -> Self
pub fn primary_key_string(self, name: &str) -> Self
添加字符串类型的主键列
Sourcepub fn primary_key_integer(self, name: &str, auto_inc: bool) -> Self
pub fn primary_key_integer(self, name: &str, auto_inc: bool) -> Self
添加整数类型的主键列。只有非分区键支持自增设置(主键集合中的第 1 个元素是分区键)
Sourcepub fn primary_key_binary(self, name: &str) -> Self
pub fn primary_key_binary(self, name: &str) -> Self
添加二进制类型的主键列
Sourcepub fn primary_key_auto_increment(self, name: &str) -> Self
pub fn primary_key_auto_increment(self, name: &str) -> Self
添加自增主键列
Sourcepub fn column(self, def_col: DefinedColumnSchema) -> Self
pub fn column(self, def_col: DefinedColumnSchema) -> Self
添加一个预定义列
Sourcepub fn columns(
self,
def_cols: impl IntoIterator<Item = DefinedColumnSchema>,
) -> Self
pub fn columns( self, def_cols: impl IntoIterator<Item = DefinedColumnSchema>, ) -> Self
设置预定义列
Sourcepub fn column_integer(self, name: &str) -> Self
pub fn column_integer(self, name: &str) -> Self
添加整数类型预定以列
Sourcepub fn column_string(self, name: &str) -> Self
pub fn column_string(self, name: &str) -> Self
添加字符串类型预定义列
Sourcepub fn column_double(self, name: &str) -> Self
pub fn column_double(self, name: &str) -> Self
添加双精度类型预定义列
Sourcepub fn column_bool(self, name: &str) -> Self
pub fn column_bool(self, name: &str) -> Self
添加布尔值类型预定义列
Sourcepub fn column_blob(self, name: &str) -> Self
pub fn column_blob(self, name: &str) -> Self
添加二进制类型预定义列
Sourcepub fn reserved_throughput_read(self, read_cu: i32) -> Self
pub fn reserved_throughput_read(self, read_cu: i32) -> Self
预设读取吞吐量。最大 100000 CU
Sourcepub fn reserved_throughput_write(self, write_cu: i32) -> Self
pub fn reserved_throughput_write(self, write_cu: i32) -> Self
预设写入吞吐量。最大 100000 CU
Sourcepub fn ttl_seconds(self, ttl_seconds: i32) -> Self
pub fn ttl_seconds(self, ttl_seconds: i32) -> Self
数据生命周期,即数据的过期时间。当数据的保存时间超过设置的数据生命周期时,系统会自动清理超过数据生命周期的数据。
数据生命周期至少为 86400
秒(一天)或 -1
(数据永不过期)。
Sourcepub fn max_versions(self, max_versions: i32) -> Self
pub fn max_versions(self, max_versions: i32) -> Self
最大版本数,即属性列能够保留数据的最大版本个数。当属性列数据的版本个数超过设置的最大版本数时,系统会自动删除较早版本的数据。
Sourcepub fn deviation_cell_version_seconds(self, dev: i64) -> Self
pub fn deviation_cell_version_seconds(self, dev: i64) -> Self
有效版本偏差,即写入数据的时间戳与系统当前时间的偏差允许最大值。只有当写入数据所有列的版本号与写入时时间的差值在数据有效版本偏差范围内,数据才能成功写入。
属性列的有效版本范围为 [max{数据写入时间-有效版本偏差,数据写入时间-数据生命周期},数据写入时间+有效版本偏差)
。
Sourcepub fn allow_update(self, allow_update: bool) -> Self
pub fn allow_update(self, allow_update: bool) -> Self
是否允许通过 UpdateRow
更新写入数据。默认值为 true
,表示允许通过 UpdateRow
更新写入数据。
当要使用多元索引生命周期功能时,您必须设置此参数为 false
,即不允许通过 UpdateRow
更新写入数据。
Sourcepub fn stream_expiration(self, exp: i32) -> Self
pub fn stream_expiration(self, exp: i32) -> Self
设置 stream 过期时间
Sourcepub fn stream_column(self, col_name: impl Into<String>) -> Self
pub fn stream_column(self, col_name: impl Into<String>) -> Self
添加一个 stream 列
Sourcepub fn stream_columns(
self,
col_names: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn stream_columns( self, col_names: impl IntoIterator<Item = impl Into<String>>, ) -> Self
设置 stream 列
Sourcepub fn sse_key_type(self, key_type: SseKeyType) -> Self
pub fn sse_key_type(self, key_type: SseKeyType) -> Self
设置加密类型
Sourcepub fn sse_key_id(self, key_id: impl Into<String>) -> Self
pub fn sse_key_id(self, key_id: impl Into<String>) -> Self
设置加密密钥 ID
Sourcepub fn index(self, idx_meta: IndexMeta) -> Self
pub fn index(self, idx_meta: IndexMeta) -> Self
添加一个索引。可以使用 IndexMetaBuilder
建立索引信息
Sourcepub fn indexes(self, indexes: impl IntoIterator<Item = IndexMeta>) -> Self
pub fn indexes(self, indexes: impl IntoIterator<Item = IndexMeta>) -> Self
设置多个索引
Trait Implementations§
Source§impl Clone for CreateTableRequest
impl Clone for CreateTableRequest
Source§fn clone(&self) -> CreateTableRequest
fn clone(&self) -> CreateTableRequest
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more