CreateTableRequest

Struct CreateTableRequest 

Source
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

Source

pub fn new(table_name: &str) -> Self

Source

pub fn primary_key(self, pk: PrimaryKeySchema) -> Self

添加一个主键列

Source

pub fn primary_keys( self, pks: impl IntoIterator<Item = PrimaryKeySchema>, ) -> Self

设置主键列

Source

pub fn primary_key_string(self, name: &str) -> Self

添加字符串类型的主键列

Source

pub fn primary_key_integer(self, name: &str, auto_inc: bool) -> Self

添加整数类型的主键列。只有非分区键支持自增设置(主键集合中的第 1 个元素是分区键)

Source

pub fn primary_key_binary(self, name: &str) -> Self

添加二进制类型的主键列

Source

pub fn primary_key_auto_increment(self, name: &str) -> Self

添加自增主键列

Source

pub fn column(self, def_col: DefinedColumnSchema) -> Self

添加一个预定义列

Source

pub fn columns( self, def_cols: impl IntoIterator<Item = DefinedColumnSchema>, ) -> Self

设置预定义列

Source

pub fn column_integer(self, name: &str) -> Self

添加整数类型预定以列

Source

pub fn column_string(self, name: &str) -> Self

添加字符串类型预定义列

Source

pub fn column_double(self, name: &str) -> Self

添加双精度类型预定义列

Source

pub fn column_bool(self, name: &str) -> Self

添加布尔值类型预定义列

Source

pub fn column_blob(self, name: &str) -> Self

添加二进制类型预定义列

Source

pub fn reserved_throughput_read(self, read_cu: i32) -> Self

预设读取吞吐量。最大 100000 CU

Source

pub fn reserved_throughput_write(self, write_cu: i32) -> Self

预设写入吞吐量。最大 100000 CU

Source

pub fn ttl_seconds(self, ttl_seconds: i32) -> Self

数据生命周期,即数据的过期时间。当数据的保存时间超过设置的数据生命周期时,系统会自动清理超过数据生命周期的数据。 数据生命周期至少为 86400 秒(一天)或 -1(数据永不过期)。

Source

pub fn max_versions(self, max_versions: i32) -> Self

最大版本数,即属性列能够保留数据的最大版本个数。当属性列数据的版本个数超过设置的最大版本数时,系统会自动删除较早版本的数据。

Source

pub fn deviation_cell_version_seconds(self, dev: i64) -> Self

有效版本偏差,即写入数据的时间戳与系统当前时间的偏差允许最大值。只有当写入数据所有列的版本号与写入时时间的差值在数据有效版本偏差范围内,数据才能成功写入。

属性列的有效版本范围为 [max{数据写入时间-有效版本偏差,数据写入时间-数据生命周期},数据写入时间+有效版本偏差)

Source

pub fn allow_update(self, allow_update: bool) -> Self

是否允许通过 UpdateRow 更新写入数据。默认值为 true,表示允许通过 UpdateRow 更新写入数据。

当要使用多元索引生命周期功能时,您必须设置此参数为 false,即不允许通过 UpdateRow 更新写入数据。

Source

pub fn stream(self, enabled: bool) -> Self

设置是否启用 stream

Source

pub fn stream_expiration(self, exp: i32) -> Self

设置 stream 过期时间

Source

pub fn stream_column(self, col_name: impl Into<String>) -> Self

添加一个 stream 列

Source

pub fn stream_columns( self, col_names: impl IntoIterator<Item = impl Into<String>>, ) -> Self

设置 stream 列

Source

pub fn sse(self, enabled: bool) -> Self

设置是否启用加密

Source

pub fn sse_key_type(self, key_type: SseKeyType) -> Self

设置加密类型

Source

pub fn sse_key_id(self, key_id: impl Into<String>) -> Self

设置加密密钥 ID

Source

pub fn sse_arn(self, arn: impl Into<String>) -> Self

设置加密 ARN

Source

pub fn local_txn(self, enabled: bool) -> Self

是否启用本地事务

Source

pub fn index(self, idx_meta: IndexMeta) -> Self

添加一个索引。可以使用 IndexMetaBuilder 建立索引信息

Source

pub fn indexes(self, indexes: impl IntoIterator<Item = IndexMeta>) -> Self

设置多个索引

Trait Implementations§

Source§

impl Clone for CreateTableRequest

Source§

fn clone(&self) -> CreateTableRequest

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CreateTableRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CreateTableRequest

Source§

fn default() -> CreateTableRequest

Returns the “default value” for a type. Read more
Source§

impl From<CreateTableRequest> for CreateTableRequest

Source§

fn from(value: CreateTableRequest) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T