All Products
Search
Document Center

Tablestore:Tablestore ProtocolBuffer message definitions

Last Updated:Aug 28, 2024

This topic describes the definitions of ots_internal_api.proto, ots_filter.proto, search.proto, tunnel_service.proto, and timeseries.proto.

ots_internal_api.proto

syntax = "proto2";

package com.alicloud.openservices.tablestore.core.protocol;

message Error {
    required string code = 1;
    optional string message = 2;
}

enum PrimaryKeyType {
    INTEGER = 1;
    STRING = 2;
    BINARY = 3;
}

enum DefinedColumnType {
    DCT_INTEGER = 1;
    DCT_DOUBLE = 2;
    DCT_BOOLEAN = 3;
    DCT_STRING = 4;
    DCT_BLOB = 7;
}

enum PrimaryKeyOption {
    AUTO_INCREMENT = 1;
}

message PrimaryKeySchema {
    required string name = 1;
    required PrimaryKeyType type = 2;
    optional PrimaryKeyOption option = 3;
}

message PartitionRange {
    required bytes begin = 1; // encoded as SQLVariant
    required bytes end = 2; // encoded as SQLVariant
}

message DefinedColumnSchema {
    required string name = 1;
    required DefinedColumnType type = 2;
}

message TableOptions {
    optional int32 time_to_live = 1;
    optional int32 max_versions = 2;
    optional int64 deviation_cell_version_in_sec = 5;
    optional bool allow_update = 6;
}

enum IndexUpdateMode {
    IUM_ASYNC_INDEX = 0;
    IUM_SYNC_INDEX = 1;
}

enum IndexType {
    IT_GLOBAL_INDEX = 0;
    IT_LOCAL_INDEX = 1;
}

enum IndexSyncPhase {
    ISP_INVALID = 0;
    ISP_FULL = 1;
    ISP_INCR = 2;
}

message IndexMeta {
    required string name = 1;
    repeated string primary_key = 2;
    repeated string defined_column = 3;
    required IndexUpdateMode index_update_mode = 4;
    required IndexType index_type = 5;
    optional IndexSyncPhase index_sync_phase = 6;
}

message TableMeta {
    required string table_name = 1;
    repeated PrimaryKeySchema primary_key = 2;
    repeated DefinedColumnSchema defined_column = 3;
}

enum RowExistenceExpectation {
    IGNORE = 0;
    EXPECT_EXIST = 1;
    EXPECT_NOT_EXIST = 2;
}

message Condition {
    required RowExistenceExpectation row_existence = 1;
    optional bytes column_condition      = 2;
}

message CapacityUnit {
    optional int32 read = 1;
    optional int32 write = 2;
}

message CapacityDataSize {
    optional int64 read_size = 1;
    optional int64 write_size = 2;
}

message ReservedThroughputDetails {
    required CapacityUnit capacity_unit = 1;
    required int64 last_increase_time = 2;
    optional int64 last_decrease_time = 3;
}

message ReservedThroughput {
    required CapacityUnit capacity_unit = 1;
}

message ConsumedCapacity {
    required CapacityUnit capacity_unit = 1;
    optional CapacityDataSize capacity_data_size = 2;
}

message StreamSpecification {
    required bool enable_stream = 1;
    optional int32 expiration_time = 2;
    repeated string columns_to_get = 3;
}

message StreamDetails {
    required bool enable_stream = 1;
    optional string stream_id = 2;
    optional int32 expiration_time = 3;
    optional int64 last_enable_time = 4;
    repeated string column_to_get = 5;
}

enum SSEKeyType {
    SSE_KMS_SERVICE = 1;
    SSE_BYOK = 2;
}

message SSESpecification {
    required bool enable = 1;
    optional SSEKeyType key_type = 2;
    optional bytes key_id = 3; // only useful when key_type is SSE_BYOK
    optional bytes role_arn = 4; // only useful when key_type is SSE_BYOK
}

message SSEDetails {
    required bool enable = 1;
    optional SSEKeyType key_type = 2;
    optional bytes key_id = 3;
    optional bytes role_arn = 4; // only useful when key_type is SSE_BYOK
}

message CreateTableRequest {
    required TableMeta table_meta = 1;
    required ReservedThroughput reserved_throughput = 2;
    optional TableOptions table_options = 3;
    repeated PartitionRange partitions = 4;
    optional StreamSpecification stream_spec = 5;
    optional SSESpecification sse_spec = 6;
    repeated IndexMeta index_metas = 7;
    optional bool enable_local_txn = 8;
}

message CreateTableResponse {
}

message CreateIndexRequest {
    required string main_table_name = 1;
    required IndexMeta index_meta = 2;
    optional bool include_base_data = 3;
}

message CreateIndexResponse {
}

message DropIndexRequest {
    required string main_table_name = 1;
    required string index_name = 2;
}

message DropIndexResponse {
}

message AddDefinedColumnRequest {
    required string table_name = 1;
    repeated DefinedColumnSchema columns = 2;
}

message AddDefinedColumnResponse {
}

message DeleteDefinedColumnRequest {
    required string table_name = 1;
    repeated string columns = 2;
}

message DeleteDefinedColumnResponse {
}

message UpdateTableRequest {
    required string table_name = 1;
    optional ReservedThroughput reserved_throughput = 2;
    optional TableOptions table_options = 3;
    optional StreamSpecification stream_spec = 4;
}

message UpdateTableResponse {
    required ReservedThroughputDetails reserved_throughput_details = 1;
    required TableOptions table_options = 2;
    optional StreamDetails stream_details = 3;
}
message DescribeTableRequest {
    required string table_name = 1;
}

message DescribeTableResponse {
    required TableMeta table_meta = 1;
    required ReservedThroughputDetails reserved_throughput_details = 2;
    required TableOptions table_options = 3;
    optional StreamDetails stream_details = 5;
    repeated bytes shard_splits = 6;
    optional SSEDetails sse_details = 7;
    repeated IndexMeta index_metas = 8;
    optional int64 creation_time = 9;
}
message ListTableRequest {
}

message ListTableResponse {
    repeated string table_names = 1;
}
message DeleteTableRequest {
    required string table_name = 1;
}

message DeleteTableResponse {
}
message LoadTableRequest {
    required string table_name = 1;
}

message LoadTableResponse {
}
message UnloadTableRequest {
    required string table_name = 1;
}

message UnloadTableResponse {

}
message TimeRange {
    optional int64 start_time = 1;
    optional int64 end_time = 2;
    optional int64 specific_time = 3;
}

enum ReturnType {
    RT_NONE = 0;
    RT_PK = 1;
    RT_AFTER_MODIFY = 2;
}

message ReturnContent {
    optional ReturnType return_type = 1;
    repeated string return_column_names = 2;
}

message GetRowRequest {
    required string table_name = 1;
    required bytes primary_key = 2;
    repeated string columns_to_get = 3;
    optional TimeRange time_range = 4;
    optional int32 max_versions = 5;
    optional bytes filter = 7;
    optional string start_column = 8;
    optional string end_column = 9;
    optional bytes token = 10;
    optional string transaction_id = 11;
}

message GetRowResponse {
    required ConsumedCapacity consumed = 1;
    required bytes row = 2;
    optional bytes next_token = 3;
}
message UpdateRowRequest {
    required string table_name = 1;
    required bytes row_change = 2;
    required Condition condition = 3;
    optional ReturnContent return_content = 4;
    optional string transaction_id = 5;
}

message UpdateRowResponse {
    required ConsumedCapacity consumed = 1;
    optional bytes row = 2;
}
message PutRowRequest {
    required string table_name = 1;
    required bytes row = 2;
    required Condition condition = 3;
    optional ReturnContent return_content = 4;
    optional string transaction_id = 5;
}

message PutRowResponse {
    required ConsumedCapacity consumed = 1;
    optional bytes row = 2;
}
message DeleteRowRequest {
    required string table_name = 1;
    required bytes primary_key = 2;
    required Condition condition = 3;
    optional ReturnContent return_content = 4;
    optional string transaction_id = 5;
}

message DeleteRowResponse {
    required ConsumedCapacity consumed = 1;
    optional bytes row = 2;
}
message TableInBatchGetRowRequest {
    required string table_name = 1;
    repeated bytes primary_key = 2;
    repeated bytes token = 3;
    repeated string columns_to_get = 4;
    optional TimeRange time_range = 5;
    optional int32 max_versions = 6;
    optional bytes filter = 8;
    optional string start_column = 9;
    optional string end_column = 10;
}

message BatchGetRowRequest {
    repeated TableInBatchGetRowRequest tables = 1;
}

message RowInBatchGetRowResponse {
    required bool is_ok = 1;
    optional Error error = 2;
    optional ConsumedCapacity consumed = 3;
    optional bytes row = 4;
    optional bytes next_token = 5;
}

message TableInBatchGetRowResponse {
    required string table_name = 1;
    repeated RowInBatchGetRowResponse rows = 2;
}

message BatchGetRowResponse {
    repeated TableInBatchGetRowResponse tables = 1;
}

enum OperationType {
    PUT = 1;
    UPDATE = 2;
    DELETE = 3;
}

message RowInBatchWriteRowRequest {
    required OperationType type = 1;
    required bytes row_change = 2;
    required Condition condition = 3;
    optional ReturnContent return_content = 4;
}

message TableInBatchWriteRowRequest {
    required string table_name = 1;
    repeated RowInBatchWriteRowRequest rows = 2;
}

message BatchWriteRowRequest {
    repeated TableInBatchWriteRowRequest tables = 1;
    optional string transaction_id = 2;
    optional bool is_atomic = 3;
}

message RowInBatchWriteRowResponse {
    required bool is_ok = 1;
    optional Error error = 2;
    optional ConsumedCapacity consumed = 3;
    optional bytes row = 4;
}

message TableInBatchWriteRowResponse {
    required string table_name = 1;
    repeated RowInBatchWriteRowResponse rows = 2;
}

message BatchWriteRowResponse {
    repeated TableInBatchWriteRowResponse tables = 1;
}
enum Direction {
    FORWARD = 0;
    BACKWARD = 1;
}

message GetRangeRequest {
    required string table_name = 1;
    required Direction direction = 2;
    repeated string columns_to_get = 3;
    optional TimeRange time_range = 4;
    optional int32 max_versions = 5;
    optional int32 limit = 6;
    required bytes inclusive_start_primary_key = 7;
    required bytes exclusive_end_primary_key = 8;
    optional bytes filter = 10;
    optional string start_column = 11;
    optional string end_column = 12;
    optional bytes token = 13;
    optional string transaction_id = 14;
}

message GetRangeResponse {
    required ConsumedCapacity consumed = 1;
    required bytes rows = 2;
    optional bytes next_start_primary_key = 3;
    optional bytes next_token = 4;
}

message StartLocalTransactionRequest {
    required string table_name = 1;
    required bytes key = 2;
}

message StartLocalTransactionResponse {
    required string transaction_id = 1;
};

message CommitTransactionRequest {
    required string transaction_id = 1;
}

message CommitTransactionResponse {
};

message AbortTransactionRequest {
    required string transaction_id = 1;
}

message AbortTransactionResponse {
};


message ListStreamRequest {
    optional string table_name = 1;
}

message Stream {
    required string stream_id = 1;
    required string table_name = 2;
    required int64 creation_time = 3;
}

message ListStreamResponse {
    repeated Stream streams = 1;
}

message StreamShard {
    required string shard_id = 1;
    optional string parent_id = 2;
    optional string parent_sibling_id = 3;
}

enum StreamStatus {
    STREAM_ENABLING = 1;
    STREAM_ACTIVE = 2;
}

message DescribeStreamRequest {
    required string stream_id = 1;
    optional string inclusive_start_shard_id = 2;
    optional int32 shard_limit = 3;
    optional bool support_timeseries_data_table = 4;
}

message DescribeStreamResponse {
    required string stream_id = 1;
    required int32 expiration_time = 2;
    required string table_name = 3;
    required int64 creation_time = 4;
    required StreamStatus stream_status = 5;
    repeated StreamShard shards = 6;
    optional string next_shard_id = 7;
    optional bool is_timeseries_data_table = 8;
}

message GetShardIteratorRequest {
    required string stream_id = 1;
    required string shard_id = 2;
    optional int64 timestamp = 3;
    optional string token = 4;
}

message GetShardIteratorResponse {
    required string shard_iterator = 1;
    optional string next_token = 2;
}

message GetStreamRecordRequest {
    required string shard_iterator = 1;
    optional int32 limit = 2;
    optional string table_name = 3;
}

enum ActionType {
    PUT_ROW = 1;
    UPDATE_ROW = 2;
    DELETE_ROW = 3;
}

message GetStreamRecordResponse {
    message StreamRecord {
        required ActionType action_type = 1;
        required bytes record = 2;
        optional bytes origin_record = 3;
    }
    repeated StreamRecord stream_records = 1;
    optional string next_shard_iterator = 2;
    optional ConsumedCapacity consumed = 3;
    optional bool may_more_record = 4;
}

message ComputeSplitPointsBySizeRequest {
    required string table_name = 1;
    required int64 split_size = 2; // in 100MB
    optional int64 split_size_unit_in_byte = 3;
    optional int32 split_point_limit = 4;
}

message ComputeSplitPointsBySizeResponse {
    required ConsumedCapacity consumed = 1;
    repeated PrimaryKeySchema schema = 2;

    /**
     * Split points between splits, in the increasing order
     *
     * A split is a consecutive range of primary keys,
     * whose data size is about split_size specified in the request.
     * The size could be hard to be precise.
     *
     * A split point is an array of primary-key column w.r.t. table schema,
     * which is never longer than that of table schema.
     * Tailing -inf will be omitted to reduce transmission payloads.
     */
    repeated bytes split_points = 3;

    /**
     * Locations where splits lies in.
     *
     * By the managed nature of TableStore, these locations are no more than hints.
     * If a location is not suitable to be seen, an empty string will be placed.
     */
     message SplitLocation {
         required string location = 1;
         required sint64 repeat = 2;
     }
     repeated SplitLocation locations = 4;
}

enum DataBlockType {
    DBT_PLAIN_BUFFER = 0;
    DBT_SIMPLE_ROW_MATRIX = 1;
}

message BulkExportRequest {
    required string table_name = 1;
    repeated string columns_to_get = 2;
    required bytes inclusive_start_primary_key = 3;
    required bytes exclusive_end_primary_key = 4;
    optional bytes filter = 5;
    optional DataBlockType data_block_type_hint = 6 [default = DBT_SIMPLE_ROW_MATRIX];
}

message BulkExportResponse {
     required ConsumedCapacity consumed = 1;
     required bytes rows = 2;
     optional bytes next_start_primary_key = 3;
     optional DataBlockType data_block_type = 4;
}

message BulkImportRequest {
    required string table_name = 1;
    repeated RowInBulkImportRequest rows = 2;
}

message RowInBulkImportRequest {
    required OperationType type = 1;
    required bytes row_change = 2;
}

message BulkImportResponse {
    required string table_name = 1;
    repeated RowInBulkImportResponse rows = 2;
}

message RowInBulkImportResponse {
    required bool is_ok = 1;
    optional Error error = 2;
    optional ConsumedCapacity consumed = 3;
}

/* computeSplits */
message ComputeSplitsRequest {
    optional string table_name = 1;
    optional SearchIndexSplitsOptions search_index_splits_options = 2;
}

message SearchIndexSplitsOptions{
    optional string index_name = 1;
}

message ComputeSplitsResponse {
    optional bytes session_id = 1;
    optional int32 splits_size = 2;
}

/* SQLQuery */
enum SQLPayloadVersion {
    SQL_PLAIN_BUFFER = 1;
    SQL_FLAT_BUFFERS = 2;
}

enum SQLStatementType {
    SQL_SELECT = 1;
    SQL_CREATE_TABLE = 2;
    SQL_SHOW_TABLE = 3;
    SQL_DESCRIBE_TABLE = 4;
    SQL_DROP_TABLE = 5;
    SQL_ALTER_TABLE = 6;
}

message SQLQueryRequest {
    required string query = 1;
    optional SQLPayloadVersion version = 2;
    optional int64 sql_version = 3;
    optional string search_token = 5;
}

message TableConsumedCapacity {
    optional string table_name = 1;
    optional ConsumedCapacity consumed = 2;
    optional ReservedThroughput reserved_throughput = 3;
}

message SQLQueryResponse {
    repeated TableConsumedCapacity consumes = 1;
    optional bytes rows = 2;
    optional SQLPayloadVersion version = 3;
    optional SQLStatementType type = 4;
    optional string next_search_token = 8;
}

ots_filter.proto

syntax = "proto2";

package com.alicloud.openservices.tablestore.core.protocol;

enum VariantType {
    VT_INTEGER = 0;
    VT_DOUBLE = 1;
    //VT_BOOLEAN = 2;
    VT_STRING = 3;
    VT_NULL = 6;
    VT_BLOB = 7;
}

message ValueTransferRule {
    required string regex = 1;
    optional VariantType cast_type = 2;
}

enum FilterType {
    FT_SINGLE_COLUMN_VALUE = 1;
    FT_COMPOSITE_COLUMN_VALUE = 2;
    FT_COLUMN_PAGINATION = 3;
}

enum ComparatorType {
    CT_EQUAL = 1;
    CT_NOT_EQUAL = 2;
    CT_GREATER_THAN = 3;
    CT_GREATER_EQUAL = 4;
    CT_LESS_THAN = 5;
    CT_LESS_EQUAL = 6;
    CT_EXIST = 7;
    CT_NOT_EXIST = 8;
}

message SingleColumnValueFilter {
    required ComparatorType comparator = 1;
    required string column_name = 2;
    required bytes column_value = 3;
    required bool filter_if_missing = 4;
    required bool latest_version_only = 5; 
    optional ValueTransferRule value_trans_rule = 6;
}

enum LogicalOperator {
    LO_NOT = 1;
    LO_AND = 2;
    LO_OR = 3;
}

message CompositeColumnValueFilter {
    required LogicalOperator combinator = 1;
    repeated Filter sub_filters = 2;
}

message ColumnPaginationFilter {
    required int32 offset = 1;
    required int32 limit = 2;
}

message Filter {
    required FilterType type = 1;
    required bytes filter = 2;  // Serialized string of filter of the type
}

search.proto

syntax = "proto2";

package com.alicloud.openservices.tablestore.core.protocol;

import "ots_internal_api.proto";

enum AggregationType {
    AGG_AVG = 1;
    AGG_DISTINCT_COUNT = 6;
    AGG_MAX = 2;
    AGG_MIN = 3;
    AGG_SUM = 4;
    AGG_COUNT = 5;
    AGG_TOP_ROWS = 7;
    AGG_PERCENTILES = 8;
}

enum GroupByType {
    GROUP_BY_FIELD = 1;
    GROUP_BY_RANGE = 2;
    GROUP_BY_FILTER = 3;
    GROUP_BY_GEO_DISTANCE = 4;
    GROUP_BY_HISTOGRAM = 5;
    GROUP_BY_DATE_HISTOGRAM = 6;
    GROUP_BY_GEO_GRID = 7;
    GROUP_BY_COMPOSITE = 8;
}

// agg & group by
message Aggregation {
    optional string name = 1;
    optional AggregationType type = 2;
    optional bytes body = 3;
}
message Aggregations {
    repeated Aggregation aggs = 1;
}

message GroupBy {
    optional string name = 1;
    optional GroupByType type = 2;
    optional bytes body = 3;
}
message GroupBys {
    repeated GroupBy group_bys = 1;
}

// single agg
message AvgAggregation {
    optional string field_name = 1;
    optional bytes missing = 2; //encoded as SQLVariant, check in SearchProxy
}

message MaxAggregation {
    optional string field_name = 1;
    optional bytes missing = 2;
}

message MinAggregation {
    optional string field_name = 1;
    optional bytes missing = 2;
}

message SumAggregation {
    optional string field_name = 1;
    optional bytes missing = 2;
}

message CountAggregation {
    optional string field_name = 1;
}

message DistinctCountAggregation {
    optional string field_name = 1;
    optional bytes missing = 2;
}

message TopRowsAggregation {
    optional int32 limit = 1;
    optional Sort sort = 2;
}

message PercentilesAggregation {
    optional string field_name = 1;
    repeated double percentiles = 2;
    optional bytes missing = 3;
}

// group agg
message FieldRange {
    optional bytes min = 1;
    optional bytes max = 2;
}

message GroupByDateHistogram {
    optional string field_name = 1;
    optional DateTimeValue interval = 2;
    optional FieldRange field_range = 3;
    optional bytes missing = 4;
    optional int64  min_doc_count = 5;
    optional string time_zone = 6;
    optional GroupBySort sort = 7;
    optional Aggregations sub_aggs = 8;
    optional GroupBys sub_group_bys = 9;
    optional DateTimeValue offset = 10;
}

message GroupByHistogram {
    optional string field_name = 1;
    optional bytes interval = 2;
    optional bytes missing = 3;
    optional int64  min_doc_count = 4;
    optional GroupBySort sort = 5;
    optional FieldRange field_range = 6;
    optional Aggregations sub_aggs = 7;
    optional GroupBys sub_group_bys = 8;
    optional bytes offset = 9;
}

message GroupKeySort {
    optional SortOrder order = 1;
}

message RowCountSort {
    optional SortOrder order = 1;
}

message SubAggSort {
    optional string sub_agg_name = 1;
    optional SortOrder order = 2;
}

message GroupBySorter {
    optional GroupKeySort group_key_sort = 1;
    optional RowCountSort row_count_sort = 2;
    optional SubAggSort sub_agg_sort = 3;
}

message GroupBySort {
    repeated GroupBySorter sorters = 1;
}

message GroupByComposite {
    optional GroupBys sources = 1;
    optional int32 size = 2;
    optional Aggregations sub_aggs = 4;
    optional GroupBys sub_group_bys = 5;
    optional string next_token = 6;
    optional int32 suggested_size = 7;
}

message GroupByCompositeResultItem {
    repeated string keys = 1;
    repeated bool is_null_keys = 5;
    optional int64 row_count = 2;
    optional AggregationsResult sub_aggs_result = 3;
    optional GroupBysResult sub_group_bys_result = 4;
}

message GroupByCompositeResult {
    repeated GroupByCompositeResultItem group_by_composite_result_items = 1;
    repeated string source_group_by_names = 2;
    optional string next_token = 3;
}

message GroupByField {
    optional string field_name = 1;
    optional int32 size = 2;
    optional GroupBySort sort = 3;
    optional Aggregations sub_aggs = 4;
    optional GroupBys sub_group_bys = 5;
    optional int64  min_doc_count = 6;
}

message Range {
    optional double from = 1;
    optional double to = 2;
}

message GroupByRange {
    optional string field_name = 1;
    repeated Range ranges = 2;
    optional Aggregations sub_aggs = 3;
    optional GroupBys sub_group_bys = 4;
}

message GroupByFilter {
    repeated Query filters = 1;
    optional Aggregations sub_aggs = 2;
    optional GroupBys sub_group_bys = 3;
}

message GroupByGeoDistance {
    optional string field_name = 1;
    optional GeoPoint origin = 2;
    repeated Range ranges = 3;
    optional Aggregations sub_aggs = 4;
    optional GroupBys sub_group_bys = 5;
}

message GroupByGeoGrid {
    optional string field_name = 1;
    optional GeoHashPrecision precision = 2;//meter
    optional int32 size = 3;
    optional Aggregations sub_aggs = 4;
    optional GroupBys sub_group_bys = 5;
}

enum GeoHashPrecision {
    GHP_5009KM_4992KM_1 = 1;
    GHP_1252KM_624KM_2 = 2;
    GHP_156KM_156KM_3 = 3;
    GHP_39KM_19KM_4 = 4;
    GHP_4900M_4900M_5 = 5;
    GHP_1200M_609M_6 = 6;
    GHP_152M_152M_7 = 7;
    GHP_38M_19M_8 = 8;
    GHP_480CM_480CM_9 = 9;
    GHP_120CM_595MM_10 = 10;
    GHP_149MM_149MM_11 = 11;
    GHP_37MM_19MM_12 = 12;
}

message GeoGrid {
    optional GeoPoint top_left = 1;
    optional GeoPoint bottom_right = 2;
}
//single agg result
message AvgAggregationResult {
    optional double value = 1;
}

message TopRowsAggregationResult {
    repeated bytes rows = 1;
}

message PercentilesAggregationItem {
    optional double key = 1;
    optional bytes value = 2;
}

message PercentilesAggregationResult {
    repeated PercentilesAggregationItem percentiles_aggregation_items = 1;
}

message DistinctCountAggregationResult {
    optional int64 value = 1;
}

message MaxAggregationResult {
    optional double value = 1;
}

message MinAggregationResult {
    optional double value = 1;
}

message SumAggregationResult {
    optional double value = 1;
}

message CountAggregationResult {
    optional int64 value = 1;
}

message AggregationResult {
    optional string name = 1;
    optional AggregationType type = 2;
    optional bytes agg_result = 3; // encoded by XxxAggregationResult
}

message AggregationsResult {
    repeated AggregationResult agg_results = 1;
}

//group by result
message GroupByFieldResultItem {
    optional string key = 1;
    optional int64 row_count = 2;
    optional AggregationsResult sub_aggs_result = 3;
    optional GroupBysResult sub_group_bys_result = 4;
}
message GroupByFieldResult {
    repeated GroupByFieldResultItem group_by_field_result_items = 1;
}

message GroupByRangeResultItem {
    optional double from = 1;
    optional double to = 2;
    optional int64 row_count = 3;
    optional AggregationsResult sub_aggs_result = 4;
    optional GroupBysResult sub_group_bys_result = 5;
}
message GroupByRangeResult {
    repeated GroupByRangeResultItem group_by_range_result_items = 1;
}

message GroupByGeoDistanceResultItem {
    optional double from = 1;
    optional double to = 2;
    optional int64 row_count = 3;
    optional AggregationsResult sub_aggs_result = 4;
    optional GroupBysResult sub_group_bys_result = 5;
}
message GroupByGeoDistanceResult {
    repeated GroupByGeoDistanceResultItem group_by_geo_distance_result_items = 1;
}

message GroupByFilterResultItem {
    optional int64 row_count = 1;
    optional AggregationsResult sub_aggs_result = 2;
    optional GroupBysResult sub_group_bys_result = 3;
}
message GroupByFilterResult {
    repeated GroupByFilterResultItem group_by_filter_result_items = 1;
}

message GroupByResult {
    optional string name = 1;
    optional GroupByType type = 2;
    optional bytes group_by_result = 3; //encoded by XxxGroupByResult
}

message GroupBysResult {
    repeated GroupByResult group_by_results = 1; //sibling pipeline / parallel group bys
}

message GroupByHistogramItem {
    optional bytes key = 1;
    optional int64 value = 2;
    optional AggregationsResult sub_aggs_result = 3;
    optional GroupBysResult sub_group_bys_result = 4;
}

message GroupByHistogramResult {
    repeated GroupByHistogramItem group_by_histogra_items = 1;
}

message GroupByDateHistogramItem {
    optional int64 timestamp = 1;
    optional int64 row_count = 2;
    optional AggregationsResult sub_aggs_result = 3;
    optional GroupBysResult sub_group_bys_result = 4;
}

message GroupByDateHistogramResult {
    repeated GroupByDateHistogramItem group_by_date_histogram_items = 1;
}

message GroupByGeoGridResultItem {
    optional string key = 1;
    optional GeoGrid geo_grid = 2;
    optional int64 row_count = 3;
    optional AggregationsResult sub_aggs_result = 4;
    optional GroupBysResult sub_group_bys_result = 5;
}

message GroupByGeoGridResult {
    repeated GroupByGeoGridResultItem group_by_geo_grid_result_items = 1;
}
///////////////////////////////////////////////////////////////////////////////////// end off new agg


enum QueryType {
    MATCH_QUERY = 1;
    MATCH_PHRASE_QUERY = 2;
    TERM_QUERY = 3;
    RANGE_QUERY = 4;
    PREFIX_QUERY = 5;
    BOOL_QUERY = 6;
    CONST_SCORE_QUERY = 7;
    FUNCTION_SCORE_QUERY = 8;
    NESTED_QUERY = 9;
    WILDCARD_QUERY = 10;
    MATCH_ALL_QUERY = 11;
    GEO_BOUNDING_BOX_QUERY = 12;
    GEO_DISTANCE_QUERY = 13;
    GEO_POLYGON_QUERY = 14;
    TERMS_QUERY = 15;
    EXISTS_QUERY = 16;
    KNN_VECTOR_QUERY = 17;
    FUNCTIONS_SCORE_QUERY = 18;
    SUFFIX_QUERY = 19;
}

enum QueryOperator {
    OR = 1;
    AND = 2;
}

message MatchQuery {
    optional string field_name = 1;
    optional string text = 2;
    optional int32 minimum_should_match = 3;
    optional QueryOperator operator = 4;
    optional float weight = 5;
}

message MatchPhraseQuery {
    optional string field_name = 1;
    optional string text = 2;
    optional float weight = 3;
}

message MatchAllQuery {
}

message TermQuery {
    optional string field_name = 1;
    optional bytes term = 2;
    optional float weight = 3;
}

message TermsQuery {
    optional string field_name = 1;
    repeated bytes terms = 2;
    optional float weight = 3;
}

message RangeQuery {
    optional string field_name = 1;
    optional bytes range_from = 2; // variant value
    optional bytes range_to = 3; // variant value
    optional bool include_lower = 4;
    optional bool include_upper = 5;
}

message PrefixQuery {
    optional string field_name = 1;
    optional string prefix = 2;
    optional float weight = 3;
}

message WildcardQuery {
    optional string field_name = 1;
    optional string value = 2;
    optional float weight = 3;
}

message BoolQuery {
    repeated Query must_queries = 1;
    repeated Query must_not_queries = 2;
    repeated Query filter_queries = 3;
    repeated Query should_queries = 4;
    optional int32 minimum_should_match = 5;
}

message ConstScoreQuery {
    optional Query filter = 1;
}

message FieldValueFactor {
    optional string field_name = 1;
}

message FunctionScoreQuery {
    optional Query query = 1;
    optional FieldValueFactor field_value_factor = 2;
}

message FunctionsScoreQuery {
    optional Query query = 1;
    repeated Function functions = 2;
    optional FunctionScoreMode score_mode = 3;
    optional FunctionCombineMode combine_mode = 4;
    optional float min_score = 5;
    optional float max_score = 6;
}

message SuffixQuery {
    optional string field_name = 1;
    optional string suffix = 2;
    optional float weight = 3;
}

message Function {
    optional FieldValueFactorFunction field_value_factor = 1;
    optional RandomScoreFunction random = 2;
    optional DecayFunction decay = 3;
    optional float weight = 4;
    optional Query filter = 5;
}

message FieldValueFactorFunction {
    optional string field_name = 1;
    optional float factor = 2;
    optional FunctionModifier modifier = 3;
    optional double missing = 4;
}

enum FunctionModifier {
    FM_NONE = 1;
    FM_LOG = 2;
    FM_LOG1P = 3;
    FM_LOG2P = 4;
    FM_LN = 5;
    FM_LN1P = 6;
    FM_LN2P = 7;
    FM_SQUARE = 8;
    FM_SQRT = 9;
    FM_RECIPROCAL = 10;
}

message DecayFunction {
    optional string field_name = 1;
    optional DecayMathFunction math_function = 2;
    optional DecayFuncParamType param_type = 3;
    optional bytes param = 4;
    optional double decay = 5;
    optional MultiValueMode multi_value_mode = 6;
}

enum DecayFuncParamType {
    DF_DATE_PARAM = 1;
    DF_NUMERIC_PARAM = 2;
    DF_GEO_PARAM = 3;
}

message DecayFuncDateParam{
    optional int64 origin_long = 1;
    optional string origin_string = 2;
    optional DateTimeValue scale = 3;
    optional DateTimeValue offset = 4;
}

message  DecayFuncNumericParam{
    optional double origin = 1;
    optional double scale = 2;
    optional double offset = 3;
}

message DecayFuncGeoParam{
    optional string origin = 1;
    optional double scale = 2;
    optional double offset = 3;
}

enum DecayMathFunction {
    GAUSS = 1;
    EXP = 2;
    LINEAR = 3;
}

enum MultiValueMode {
    MVM_MAX = 1;
    MVM_MIN = 2;
    MVM_SUM = 3;
    MVM_AVG = 4;
}

message RandomScoreFunction {
}

enum FunctionScoreMode {
    FSM_AVG = 1;
    FSM_MAX = 2;
    FSM_SUM = 3;
    FSM_MIN = 4;
    FSM_MULTIPLY = 5;
    FSM_FIRST = 6;
}

enum FunctionCombineMode {
    FCM_MULTIPLY = 1;
    FCM_AVG = 2;
    FCM_MAX = 3;
    FCM_SUM = 4;
    FCM_MIN = 5;
    FCM_REPLACE = 6;
}

enum ScoreMode {
    SCORE_MODE_NONE = 1;
    SCORE_MODE_AVG = 2;
    SCORE_MODE_MAX = 3;
    SCORE_MODE_TOTAL = 4;
    SCORE_MODE_MIN = 5;
}

message NestedQuery {
    optional string path = 1;
    optional Query query = 2;
    optional ScoreMode score_mode = 3;
    optional float weight = 4;
    optional InnerHits inner_hits = 5;
}

message InnerHits {
    optional Sort sort = 1;
    optional int32 offset = 2;
    optional int32 limit = 3;
    optional Highlight highlight = 4;
}

message GeoBoundingBoxQuery {
    optional string field_name = 1;
    optional string top_left = 2;
    optional string bottom_right = 3;
}

message GeoDistanceQuery {
    optional string field_name = 1;
    optional string center_point = 2;
    optional double distance = 3;
}

message GeoPolygonQuery {
    optional string field_name = 1;
    repeated string points = 2;
}

message ExistsQuery {
    optional string field_name = 1;
}

message KnnVectorQuery {
    optional string field_name = 1;
    optional int32 top_k = 2;
    repeated float float32_query_vector = 4;
    optional Query filter = 5;
    optional float weight = 6;
}

message Query {
    optional QueryType type = 1;
    optional bytes query = 2;
}

message Collapse {
    optional string field_name = 1;
}

message NestedFilter {
    optional string path = 1;
    optional Query filter = 2;
}

enum SortOrder {
    SORT_ORDER_ASC = 0;
    SORT_ORDER_DESC = 1;
}

enum SortMode {
    SORT_MODE_MIN = 0;
    SORT_MODE_MAX = 1;
    SORT_MODE_AVG = 2;
}

message ScoreSort {
    optional SortOrder order = 1;
}

message PrimaryKeySort {
    optional SortOrder order = 1;
}

message FieldSort {
    optional string field_name = 1;
    optional SortOrder order = 2;
    optional SortMode mode = 3;
    optional NestedFilter nested_filter = 4;
    optional bytes missing_value = 5; //encoded as SQLVariant
    optional string missing_field = 6;
}

message DocSort {
    optional SortOrder order = 1;
}

enum GeoDistanceType {
    GEO_DISTANCE_ARC = 0;
    GEO_DISTANCE_PLANE = 1;
}

message GeoDistanceSort {
    optional string field_name = 1;
    repeated string points = 2;
    optional SortOrder order = 3;
    optional SortMode mode = 4;
    optional GeoDistanceType distance_type = 5;
    optional NestedFilter nested_filter = 6;
}

message Sorter {
    optional FieldSort field_sort = 1;
    optional GeoDistanceSort geo_distance_sort = 2;
    optional ScoreSort score_sort = 3;
    optional PrimaryKeySort pk_sort = 4;
    optional DocSort doc_sort = 5;
}

message Sort {
    repeated Sorter sorter = 1;
    optional bool disable_default_pk_sorter = 2;
}

message SearchQuery {
    optional int32 offset = 1;
    optional int32 limit = 2;
    optional Query query = 4;
    optional Collapse collapse = 5;
    optional Sort sort = 6;
    optional bool getTotalCount = 8;
    optional bytes token = 9;
    optional Aggregations aggs = 10;
    optional GroupBys group_bys = 11;
    optional Highlight highlight = 12;
}

message Highlight {
    repeated HighlightParameter highlight_parameters = 1;
    optional HighlightEncoder highlight_encoder = 2 [default=PLAIN_MODE];
}

message HighlightParameter {
    optional string  field_name = 1;
    optional int32   number_of_fragments = 2;
    optional int32   fragment_size = 3;
    optional string  pre_tag = 4;
    optional string  post_tag = 5;
    optional HighlightFragmentOrder fragments_order = 6 [default=TEXT_SEQUENCE];
}

enum HighlightFragmentOrder {
    TEXT_SEQUENCE = 1;
    SCORE = 2;
}

enum HighlightEncoder {
    PLAIN_MODE = 1;
    HTML_MODE = 2;
}

enum ColumnReturnType {
    RETURN_ALL = 1;
    RETURN_SPECIFIED = 2;
    RETURN_NONE = 3;
    RETURN_ALL_FROM_INDEX = 4;
}

message ColumnsToGet {
    optional ColumnReturnType return_type = 1;
    repeated string column_names = 2;
}

message SearchRequest {
    optional string table_name = 1;
    optional string index_name = 2;
    optional ColumnsToGet columns_to_get = 3;
    optional bytes search_query = 4;
    repeated bytes routing_values = 5;
    optional int32 timeout_ms = 6;
}

message SearchResponse {
    optional int64 total_hits = 1;
    repeated bytes rows = 2;
    optional bool is_all_succeeded = 3;
    repeated SearchHit search_hits = 5;
    optional bytes next_token = 6;
    optional bytes aggs = 7;
    optional bytes group_bys = 8;
    optional ConsumedCapacity consumed = 9;
    optional ConsumedCapacity reserved_consumed = 10;
}

message SearchHit {
    optional double score = 3;
    optional HighlightResult highlight_result = 4;
    repeated SearchInnerHit search_inner_hits = 5;
    optional int32 nested_doc_offset = 6;
}

message SearchInnerHit {
    optional string path = 1;
    repeated SearchHit search_hits = 2;
}

message HighlightResult {
    repeated HighlightField highlight_fields = 1;
}

message HighlightField {
    optional string field_name = 1;
    repeated string field_fragments = 2;
}

/* Create Search Index */

enum IndexOptions {
    DOCS = 1;
    FREQS = 2;
    POSITIONS = 3;
    OFFSETS = 4;
}

enum FieldType {
    LONG = 1;
    DOUBLE = 2;
    BOOLEAN = 3;
    KEYWORD = 4;
    TEXT = 5;
    NESTED = 6;
    GEO_POINT = 7;
    DATE = 8;
    VECTOR = 9;
    FUZZY_KEYWORD = 10;
}

enum DateTimeUnit {
    YEAR = 1;
    QUARTER_YEAR = 2; // One quarter.
    MONTH = 3;
    WEEK = 4;
    DAY = 5;
    HOUR = 6;
    MINUTE = 7;
    SECOND = 8;
    MILLISECOND = 9;
}

message DateTimeValue {
    optional int32 value = 1;
    optional DateTimeUnit unit = 2;
}

message SingleWordAnalyzerParameter {
    optional bool case_sensitive = 1;
    optional bool delimit_word = 2;
}

message SplitAnalyzerParameter {
    optional string delimiter = 1;
    optional bool case_sensitive = 2;
}

message FuzzyAnalyzerParameter {
    optional int32 min_chars = 1;
    optional int32 max_chars = 2;
    optional bool case_sensitive = 3;
}

message FieldSchema {
    optional string field_name = 1;
    optional FieldType field_type = 2;
    optional IndexOptions index_options = 3;
    optional string analyzer = 4;
    optional bool index = 5;
    optional bool sort_and_agg = 6;
    optional bool store = 7;
    repeated FieldSchema field_schemas = 8; // only for nested type
    optional bool is_array = 9;
    optional bytes analyzer_parameter = 10;
    optional bool is_virtual_field = 11;
    repeated string source_field_names = 12;
    repeated string date_formats = 13;
    optional bool enable_highlighting = 14;
    optional VectorOptions vector_options = 15;
}

enum VectorDataType {
    VD_FLOAT_32 = 2;
}

message VectorOptions {
    optional VectorDataType data_type = 1;
    optional int32 dimension = 2;
    optional VectorMetricType metric_type = 3;
}

enum VectorMetricType {
    VM_EUCLIDEAN = 0;
    VM_COSINE = 1;
    VM_DOT_PRODUCT = 2;
}

message IndexSchema {
    repeated FieldSchema field_schemas = 1;
    optional IndexSetting index_setting = 2;
    optional Sort index_sort = 3;
}

message IndexSetting {
    optional int32 number_of_shards = 1;
    repeated string routing_fields = 2;
    optional int32 routing_partition_size = 3;
}

message CreateSearchIndexRequest {
    required string table_name = 1;
    required string index_name = 2;
    optional IndexSchema schema = 3;
    optional string source_index_name = 4;
    optional int32 time_to_live = 5; // unit is seconds
}

message CreateSearchIndexResponse {
}

/* Update Search Index */
message QueryFlowWeight {
    optional string index_name = 1;
    optional int32 weight = 2;
}

message UpdateSearchIndexRequest {
    optional string table_name = 1;
    optional string index_name = 2;
    optional string switch_index_name = 3;
    repeated QueryFlowWeight query_flow_weight = 4;
    optional int32 time_to_live = 5;  // unit is seconds
}

message UpdateSearchIndexResponse {
}

/* List Search Index */

message IndexInfo {
    optional string table_name = 1;
    optional string index_name = 2;
}

message ListSearchIndexRequest {
    optional string table_name = 1;
}

message ListSearchIndexResponse {
    repeated IndexInfo indices = 1;
}

/* Delete Search Index */

message DeleteSearchIndexRequest {
    optional string table_name = 1;
    optional string index_name = 2;
}

message DeleteSearchIndexResponse {
}

/* Describe Search Index */

enum SyncPhase {
    FULL = 1;
    INCR = 2;
}

message SyncStat {
    optional SyncPhase sync_phase = 1;
    optional int64 current_sync_timestamp = 2;
}

message MeteringInfo {
    optional int64 storage_size = 1;
    optional int64 row_count = 2;
    optional int64 reserved_read_cu = 3;
    optional int64 timestamp = 4;
}

message DescribeSearchIndexRequest {
    optional string table_name = 1;
    optional string index_name = 2;
}

message DescribeSearchIndexResponse {
    optional IndexSchema schema = 1;
    optional SyncStat sync_stat = 2;
    optional MeteringInfo metering_info = 3;

    optional string brother_index_name = 4;
    repeated QueryFlowWeight query_flow_weight = 5;
    optional int64 create_time = 6;
    optional int32 time_to_live = 7;  // unit is seconds
    optional IndexStatus index_status = 8;
}

message IndexStatus {
    optional IndexStatusEnum status = 1;
    optional string status_description = 2;
}

enum IndexStatusEnum {
    PENDING = 1;
    FAILED = 2;
    RUNNING = 3;
}

/* ParallelScan API, same to Search API */
message ScanQuery {
    optional Query query = 1;
    optional int32 limit = 2;
    optional int32 alive_time = 3;  //unit is second
    optional bytes token = 4;
    optional int32 current_parallel_id = 5;
    optional int32 max_parallel = 6;
}

message ParallelScanRequest {
    optional string table_name = 1;
    optional string index_name = 2;
    optional ColumnsToGet columns_to_get = 3;
    optional bytes session_id = 4;
    optional ScanQuery scan_query = 5;
    optional int32 timeout_ms = 6;
}

message ParallelScanResponse {
    repeated bytes rows = 1;
    optional bytes next_token = 2;
}

tunnel_service.proto

syntax = "proto2";

package com.alicloud.openservices.tablestore.core.protocol;

enum TunnelType {
    BaseData = 1;
    Stream = 2;
    BaseAndStream = 3;
}

message Error {
    required string code = 1;
    optional string message = 2;
    optional string tunnel_id = 3;
}

message Tunnel {
    required string table_name = 1;
    required string tunnel_name = 3;
    required TunnelType tunnel_type = 4;
    optional StreamTunnelConfig StreamTunnelConfig = 5;
}

message CreateTunnelRequest {
    required Tunnel tunnel = 1;
}

message CreateTunnelResponse {
    required string tunnel_id = 1;
}

message DeleteTunnelRequest {
    required string table_name = 1;
    required string tunnel_name = 2;
    optional string tunnel_id = 3;
}

message DeleteTunnelResponse {
}

message ListTunnelRequest {
    optional string table_name = 1;
}

message TunnelInfo {
    required string tunnel_id = 1;
    required string tunnel_type = 2;
    required string table_name = 3;
    required string instance_name = 4;
    required string stream_id = 5;
    required string stage = 6;
    optional bool expired = 7;
    optional string tunnel_name = 8;
    optional bool   public = 9;
    optional StreamTunnelConfig stream_tunnel_config = 10;
    optional int64  create_time = 11;
}

message ListTunnelResponse {
    repeated TunnelInfo tunnels = 1;
}

message DescribeTunnelRequest {
    required string table_name = 1;
    required string tunnel_name = 2;
    optional string tunnel_id = 3;
}

message ChannelInfo {
    required string channel_id = 1;
    optional string channel_type = 2;
    optional string channel_status = 3;
    optional string client_id = 4;
    optional int64 channel_rpo = 5;
    optional int64 channel_count = 6;
}

message DescribeTunnelResponse {
    required TunnelInfo tunnel = 1;
    repeated ChannelInfo channels = 2;
    optional int64 tunnel_rpo = 3;
}

message GetRpoRequest {
    optional string tunnel_id = 1;
}

message GetRpoResponse {
    optional bytes rpo_infos = 1;
    optional bytes tunnel_rpo_infos = 2;
}

message ClientConfig {
    optional int64 timeout = 1; // seconds
    optional string client_tag = 2;
}

message ConnectRequest {
    required string tunnel_id = 1;
    optional ClientConfig client_config = 2;
}

message ConnectResponse {
    required string client_id = 1;
}

enum ChannelStatus {
    OPEN = 1;
    CLOSING = 2;
    CLOSE = 3;
    TERMINATED = 4;
}

message Channel {
    required string channel_id = 1;
    required int64 version = 2;
    required ChannelStatus status = 3;
    optional bytes detail = 4; // The range information or information reported by the client to the master, such as the processing speed. 
}

message HeartbeatRequest {
    required string tunnel_id = 1;
    required string client_id = 2;
    repeated Channel channels = 3;
}

message HeartbeatResponse {
    repeated Channel channels = 1;
}

message ShutdownRequest {
    required string tunnel_id = 1;
    required string client_id = 2;
}

message ShutdownResponse {
}

message GetCheckpointRequest {
    required string tunnel_id = 1;
    required string client_id = 2;
    required string channel_id = 3;
}

message GetCheckpointResponse {
    required string checkpoint = 1;
    required int64 sequence_number = 2;
}

message CheckpointRequest {
    required string tunnel_id = 1;
    required string client_id = 2;
    required string channel_id = 3;
    required string checkpoint = 4;
    required int64 sequence_number = 5;
}

message CheckpointResponse {
}

message ReadRecordsRequest {
    required string tunnel_id = 1;
    required string client_id = 2;
    required string channel_id = 3;
    required string token = 4;
}

enum ActionType {
    PUT_ROW = 1;
    UPDATE_ROW = 2;
    DELETE_ROW = 3;
}

message Record {
    required ActionType action_type = 1;
    required bytes record = 2;
    optional bytes origin_record = 3;
}

message ReadRecordsResponse {
    repeated Record records = 1;
    required string next_token = 2;
    optional bool may_more_record = 3;
}

message Token {
    required int64 version = 1;
    required bytes content = 2;
}

message TokenContent {
    optional bytes primary_key = 1;
    optional string iterator = 2;
    optional int64 timestamp = 3;
}

message TokenContentV2 {
    optional bytes primary_key = 1;
    optional string iterator = 2;
    optional int64 timestamp = 3;
    optional int64 total_count = 4;
}

enum StartOffsetFlag {
    LATEST = 0;
    EARLIEST = 1;
}

message StreamTunnelConfig {
    optional StartOffsetFlag flag = 1;
    optional uint64 startOffset = 2;
    optional uint64 endOffset = 3;
}

timeseries.proto

syntax = "proto2";

package com.alicloud.openservices.tablestore.core.protocol.timeseries;

import "ots_internal_api.proto";

message TimeseriesTableOptions {
  optional int32 time_to_live = 1;
}

message TimeseriesMetaOptions {
  optional bool allow_update_attributes = 1;
  optional int32 meta_time_to_live = 2;
}

message TimeseriesTableMeta {
  required string table_name = 1;
  optional TimeseriesTableOptions table_options = 2;
  optional string status = 3;
  optional TimeseriesMetaOptions meta_options = 4;
  repeated string timeseries_key_schema = 5;
  repeated PrimaryKeySchema field_primary_key_schema = 6;
  optional bool disable_hash_partition_key = 7;
  optional bool disable_timeseries_meta_index = 8;
}

message LastpointIndexMetaForCreate {
  required string index_table_name = 1;
}

message CreateTimeseriesTableRequest {
  required TimeseriesTableMeta table_meta = 1;
  repeated TimeseriesAnalyticalStore analytical_stores = 3;
  optional bool enable_analytical_store = 4;
  repeated LastpointIndexMetaForCreate lastpoint_index_metas = 5;
}

message CreateTimeseriesTableResponse {
}

message ListTimeseriesTableRequest {
}

message ListTimeseriesTableResponse {
  repeated TimeseriesTableMeta table_metas = 1;
}

message DeleteTimeseriesTableRequest {
  required string table_name = 1;
}

message DeleteTimeseriesTableResponse {
}

message UpdateTimeseriesTableRequest {
  required string table_name = 1;
  optional TimeseriesTableOptions table_options = 2;
  optional TimeseriesMetaOptions meta_options = 3;
}

message UpdateTimeseriesTableResponse {
}

message DescribeTimeseriesTableRequest {
  required string table_name = 1;
}

message DescribeTimeseriesTableResponse {
  required TimeseriesTableMeta table_meta = 1;
  repeated TimeseriesAnalyticalStore analytical_stores = 2;
  repeated TimeseriesLastpointIndex lastpoint_indexes = 3;
}

enum MetaQueryConditionType {
  COMPOSITE_CONDITION = 1;
  MEASUREMENT_CONDITION = 2;
  SOURCE_CONDITION = 3;
  TAG_CONDITION = 4;
  UPDATE_TIME_CONDITION = 5;
  ATTRIBUTE_CONDITION = 6;
}

message MetaQueryCondition {
  required MetaQueryConditionType type = 1;
  required bytes proto_data = 2;
}

enum MetaQueryCompositeOperator {
  OP_AND = 1;
  OP_OR = 2;
  OP_NOT = 3;
}

message MetaQueryCompositeCondition {
  required MetaQueryCompositeOperator op = 1;
  repeated MetaQueryCondition sub_conditions = 2;
}

enum MetaQuerySingleOperator {
  OP_EQUAL = 1;
  OP_GREATER_THAN = 2;
  OP_GREATER_EQUAL = 3;
  OP_LESS_THAN = 4;
  OP_LESS_EQUAL = 5;
  OP_PREFIX = 6;
}

message MetaQueryMeasurementCondition {
  required MetaQuerySingleOperator op = 1;
  required string value = 2;
}

message MetaQuerySourceCondition {
  required MetaQuerySingleOperator op = 1;
  required string value = 2;
}

message MetaQueryTagCondition {
  required MetaQuerySingleOperator op = 1;
  required string tag_name = 2;
  required string value = 3;
}

message MetaQueryAttributeCondition {
  required MetaQuerySingleOperator op = 1;
  required string attr_name = 2;
  required string value = 3;
}

message MetaQueryUpdateTimeCondition {
  required MetaQuerySingleOperator op = 1;
  required int64 value = 2;
}

message TimeseriesTag {
  required string name = 1;
  required string value = 2;
}

message TimeseriesKey {
  optional string measurement = 1;
  optional string source = 2;
  optional string tags = 3;
  repeated TimeseriesTag tag_list = 4;
}

message TimeseriesMeta {
  required TimeseriesKey time_series_key = 1;
  optional string attributes = 2;
  optional int64 update_time = 3;
}

message QueryTimeseriesMetaRequest {
  required string table_name = 1;
  optional MetaQueryCondition condition = 2;
  optional bool get_total_hit = 3;
  optional bytes token = 4;
  optional int32 limit = 5;
  optional int64 supported_table_version = 6;
}

message QueryTimeseriesMetaResponse {
  repeated TimeseriesMeta timeseries_metas = 1;
  optional int64 total_hit = 2;
  optional bytes next_token = 3;
}

enum RowsSerializeType {
  RST_FLAT_BUFFER = 0;
  RST_PLAIN_BUFFER = 1;
}

message TimeseriesRows {
  required RowsSerializeType type = 1;
  required bytes rows_data = 2;
  optional int32 flatbuffer_crc32c = 3;
}

enum MetaUpdateMode {
  MUM_NORMAL = 0;
  MUM_IGNORE = 1;
}

message PutTimeseriesDataRequest {
  required string table_name = 1;
  required TimeseriesRows rows_data = 2;
  optional MetaUpdateMode meta_update_mode = 3;
  optional int64 supported_table_version = 4;
}

message FailedRowInfo {
  required int32 row_index = 1;
  optional string error_code = 2;
  optional string error_message = 3;
}

message MetaUpdateStatus {
  repeated uint32 row_ids = 1;
  repeated uint32 meta_update_times = 2;
}

message PutTimeseriesDataResponse {
  repeated FailedRowInfo failed_rows = 1;
  optional MetaUpdateStatus meta_update_status = 2;
}

message TimeseriesFieldsToGet {
  optional string name = 1;
  optional int32 type = 2;
}

message GetTimeseriesDataRequest {
  required string table_name = 1;
  required TimeseriesKey time_series_key = 2;
  optional int64 begin_time = 3;
  optional int64 end_time = 4;
  optional int64 specific_time = 5;
  optional bytes token = 6;
  optional int32 limit = 7;
  optional bool backward = 8;
  repeated TimeseriesFieldsToGet fields_to_get = 9;
  optional int64 supported_table_version = 10;
}

message GetTimeseriesDataResponse {
  required bytes rows_data = 1;
  optional bytes next_token = 2;
}

message UpdateTimeseriesMetaRequest {
  required string table_name = 1;
  repeated TimeseriesMeta timeseries_meta = 2;
  optional int64 supported_table_version = 3;
}

message UpdateTimeseriesMetaResponse {
  repeated FailedRowInfo failed_rows = 1;
}

message DeleteTimeseriesMetaRequest {
  required string table_name = 1;
  repeated TimeseriesKey timeseries_key = 2;
  optional int64 supported_table_version = 3;
}

message DeleteTimeseriesMetaResponse {
  repeated FailedRowInfo failed_rows = 1;
}

message SplitTimeseriesScanTaskRequest {
  required string table_name = 1;
  optional string measurement_name = 2;
  required int32 split_count_hint = 3;
}

message SplitTimeseriesScanTaskResponse {
  repeated bytes split_infos = 1;
}

message ScanTimeseriesDataRequest {
  required string table_name = 1;
  optional bytes split_info = 2;
  optional int64 start_time_us = 3;
  optional int64 end_time_us = 4;
  repeated TimeseriesFieldsToGet fields_to_get = 5;
  optional int32 limit = 6;
  optional RowsSerializeType data_serialize_type = 7;
  optional bytes token = 8;
  optional int64 supported_table_version = 9;
}

message ScanTimeseriesDataResponse {
  optional RowsSerializeType data_serialize_type = 1;
  required bytes data = 2;
  optional bytes next_token = 3;
}

message TimeseriesAnalyticalStore {
  optional string store_name = 1;	      // The store name.
  optional int32 time_to_live = 2;    // The TTL of data.
  optional AnalyticalStoreSyncType sync_option = 3;	// Create an analytical store for full or incremental data.
}

enum AnalyticalStoreSyncType {
  SYNC_TYPE_FULL = 1;	// Create an analytical store for full data.
  SYNC_TYPE_INCR = 2;	// Create an analytical store for incremental data.
}

message AnalyticalStoreSyncStat {
  optional AnalyticalStoreSyncType sync_phase = 1;				// The status of analytical store creation.
  optional int64 current_sync_timestamp = 2;// The latest synchronization time.
}

message AnalyticalStoreStorageSize {
  optional int64 size = 1;			// The storage space occupied by the analytical store.
  optional int64 timestamp = 2;	// The statistical timestamp.
}

message CreateTimeseriesAnalyticalStoreRequest {
  required string table_name = 1;
  optional TimeseriesAnalyticalStore analytical_store = 2;	// The analytical store that you want to create for time series data.
}

message CreateTimeseriesAnalyticalStoreResponse {}

message DeleteTimeseriesAnalyticalStoreRequest {
  required string table_name = 1;
  required string store_name = 2;
  optional bool drop_mapping_table = 3;
}

message DeleteTimeseriesAnalyticalStoreResponse {}

message DescribeTimeseriesAnalyticalStoreRequest {
  required string table_name = 1;
  required string store_name = 2;
}

message DescribeTimeseriesAnalyticalStoreResponse {
  optional TimeseriesAnalyticalStore analytical_store = 1;
  optional AnalyticalStoreSyncStat sync_stat = 2;
  optional AnalyticalStoreStorageSize storage_size = 3;
}

message UpdateTimeseriesAnalyticalStoreRequest {
  required string table_name = 1;
  required TimeseriesAnalyticalStore analytical_store = 2;
}

message UpdateTimeseriesAnalyticalStoreResponse {}

message TimeseriesLastpointIndex {
  optional string index_table_name = 1;
}

message CreateTimeseriesLastpointIndexRequest {
  required string main_table_name = 1;
  required string index_table_name = 2;
  optional bool include_base_data = 3;
  optional bool create_on_wide_column_table = 4;
  repeated string index_primary_key_names = 5;
}

message CreateTimeseriesLastpointIndexResponse {
}

message DeleteTimeseriesLastpointIndexRequest {
  required string main_table_name = 1;
  required string index_table_name = 2;
}

message DeleteTimeseriesLastpointIndexResponse {
}