github.com/matrixorigin/matrixone@v1.2.0/proto/api.proto (about) 1 /* 2 * Copyright 2021 Matrix Origin 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 syntax = "proto3"; 18 package api; 19 20 import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 21 import "timestamp.proto"; 22 import "plan.proto"; 23 24 option go_package = "github.com/matrixorigin/matrixone/pkg/pb/api"; 25 option (gogoproto.sizer_all) = false; 26 option (gogoproto.protosizer_all) = true; 27 28 enum OpCode { 29 Nop = 0; 30 OpGetLogTail = 1000; 31 OpPreCommit = 1001; 32 33 OpPing = 2000; 34 OpFlush = 2001; 35 OpCheckpoint = 2003; 36 OpInspect = 2004; 37 OpAddFaultPoint = 2005; 38 OpBackup = 2006; 39 OpTraceSpan = 2007; 40 OpStorageUsage = 2008; 41 OpGlobalCheckpoint = 2009; 42 OpInterceptCommit = 2010; 43 OpCommitMerge = 2011; 44 } 45 46 // TNPingRequest ping request 47 message TNPingRequest { 48 option (gogoproto.sizer) = true; 49 option (gogoproto.protosizer) = false; 50 string parameter = 1; 51 } 52 53 // TNPingResponse ping response 54 message TNPingResponse { 55 option (gogoproto.sizer) = true; 56 option (gogoproto.protosizer) = false; 57 string storeID = 1; 58 string serviceAddress = 2; 59 uint64 shardID = 3; 60 uint64 replicaID = 4; 61 uint64 logShardID = 5; 62 } 63 64 // TNStringResponse string type response 65 message TNStringResponse { 66 option (gogoproto.sizer) = true; 67 option (gogoproto.protosizer) = false; 68 string returnStr = 1; 69 } 70 71 message Vector { 72 bytes data = 1; 73 plan.Type type = 2; 74 bool nullable = 3; 75 bytes nsp = 4; 76 bool is_const = 5; 77 uint32 len = 6; 78 bytes area = 7; 79 }; 80 81 message Batch { 82 repeated string attrs = 1 [(gogoproto.nullable) = false]; 83 repeated Vector vecs = 2 [(gogoproto.nullable) = false]; 84 }; 85 86 message TableID { 87 uint64 db_id = 1; 88 uint64 tb_id = 2; 89 uint64 partition_id = 3; 90 } 91 92 // CN pull the log tail of table from TN. 93 message SyncLogTailReq { 94 timestamp.Timestamp cn_have = 1; 95 timestamp.Timestamp cn_want = 2; 96 TableID table = 3; 97 }; 98 99 message SyncLogTailResp { 100 // ckp_location is a checkpoint location list. 101 // How to get checkpoint data on S3 by the ckp_location , 102 // pls ref to disttae/logtail.go/consumeLogTail function. 103 string ckp_location = 1; 104 // commands is log tail for a system or user table, 105 // pls ref to tae/logtail/handle.go/HandleSyncLogTailReq function. 106 repeated Entry commands = 2; 107 }; 108 109 // How to parse and handle PrecommiWriteCmd , pls ref to 110 // tae/rpc/handle.go/HandlePreCommit function 111 message PrecommitWriteCmd { 112 repeated Entry entry_list = 1; 113 }; 114 115 // CN--->TN, DDL 116 // create database test: 117 // Entry { 118 // entry_type = Insert 119 // table_id = 0 120 // database_id = 0 121 // table_name = mo_database 122 // database_name = mo_catalog 123 // file_name = "" 124 // bat = "test, 0, ..." 125 // } 126 // drop database test: 127 // Entry { 128 // entry_type = Delete 129 // table_id = 0 130 // database_id = 0 131 // table_name = mo_database 132 // database_name = mo_catalog 133 // file_name = "" 134 // bat= "test, 0, ..." 135 // } 136 137 // create a user table: 138 // insert entry into mo_tables and ...; 139 // Entry { 140 // entry_type = Insert 141 // table_id = 1 142 // database_id = 0 143 // table_name = mo_tables 144 // database_name = mo_catalog 145 // file_name = "" 146 // bat.attrs = {"relid", "relname", "reldatabase", ...} 147 // } 148 149 // drop table: 150 // delete entry from mo_tables and ...; 151 // Entry { 152 // entry_type = delete 153 // table_id = 1 154 // database_id = 0 155 // table_name = mo_tables 156 // database_name = mo_catalog 157 // file_name = "" 158 // bat.attrs = {"relid", "relname",...} 159 // } 160 161 // bulk load: 162 // bulk loads a block into S3. 163 // Entry { 164 // entry_type = Insert 165 // table_id = tid 166 // database_id = dbId 167 // table_name = xxx 168 // database_name = xxx 169 // // one S3 object file can hold many blocks. 170 // file_name = "s3 file name" 171 // 172 // // bat holds meta locations for many blocks. 173 // // "meta_loc" : the location of block data which contains BF and ZM 174 // index and be sorted by primary key. bat.attrs = {"meta_loc"} 175 // } 176 177 // deletes/updates involves many rows need to write S3. 178 // Entry { 179 // entry_type = Delete 180 // table_id = tid 181 // database_id = dbId 182 // table_name = xxx 183 // database_name = xxx 184 // 185 // // one S3 object file can contains many blocks 186 // file_name = "s3 file name" 187 188 // // "delta_loc" : the location of deleted row-ids for a block 189 // bat.attrs = {"delta_loc"} 190 // } 191 192 // DML: 193 // append a batch of data into table; 194 // Entry { 195 // entry_type = Insert 196 // table_id = tid 197 // database_id = dbId 198 // table_name = xxx 199 // database_name = xxx 200 // file_name = "" 201 // bat.attrs = {"primary column value", "column1 value", ...} 202 // } 203 204 // delete batch of data from table; 205 // Entry { 206 // entry_type = Delete 207 // table_id = tid 208 // database_id = dbId 209 // table_name = xxx 210 // database_name = xxx 211 // file_name = "" 212 // bat.attrs = {"rowid"} 213 // } 214 215 message Entry { 216 enum EntryType { 217 Insert = 0; 218 Delete = 1; 219 Update = 2; 220 Alter = 3; 221 SpecialDelete = 4; 222 } 223 EntryType entry_type = 1; 224 uint64 table_id = 2; 225 uint64 database_id = 3; 226 string table_name = 4; 227 string database_name = 5; 228 string file_name = 6; 229 Batch bat = 7; 230 // whether TN do the PK uniqueness check against txn's workspace or not. 231 int32 pk_check_by_tn = 8; 232 }; 233 234 // There are two kinds of checkpoint: delta checkpoint and base checkpoint, 235 // base checkpoint is a snapshot at a timestamp for catalog and block meta. 236 // delta checkpoint is a mini checkpoint represents changes during a period. 237 238 // CatalogCkp contains information about database and tables in the system,and 239 // MetadataCkp contains information about blocks. 240 message Checkpoint { 241 // min_ts TN is the lower bounds of the checkpoint 242 // CN maybe don't care about it. 243 timestamp.Timestamp min_ts = 1; 244 // max_ts is the upper bounds of the checkpoint. 245 // CN maybe don't care about it. 246 timestamp.Timestamp max_ts = 2; 247 Batch bat = 3; 248 }; 249 // catalog checkpoint: 250 // one Batch represents a table, such as : mo_databases, mo_tables, 251 // mo_columns,... etc. knowing more about system tables, pls ref to 252 // pkg/vm/engine/tae/catalog/model.go 253 message CatalogCkp { 254 timestamp.Timestamp min_ts = 1; 255 timestamp.Timestamp max_ts = 2; 256 Batch bat = 3; 257 }; 258 259 // metadata checkpoint: 260 // Batch is a batch of block metadata for a table, 261 // one row of Batch represents a block meta data. 262 // TODO:: 263 // knowing more about block meta data , pls ref to ... 264 message MetadataCkp { 265 timestamp.Timestamp min_ts = 1; 266 timestamp.Timestamp max_ts = 2; 267 // block meta data for a table; 268 Batch bat = 3; 269 }; 270 271 // For AlterTable 272 273 enum AlterKind { 274 Invalid = 0; 275 AddColumn = 1; 276 DropColumn = 2; 277 RenameTable = 3; 278 UpdateComment = 4; 279 UpdateConstraint = 5; 280 UpdatePolicy = 6; 281 AddPartition = 7; 282 RenameColumn = 8; 283 } 284 285 message AlterTablePolicy { 286 uint32 min_osize_quailifed = 1; 287 uint32 max_obj_onerun = 2; 288 uint32 max_osize_merged_obj = 3; 289 repeated MergeHint hints = 4; 290 uint64 min_cn_merge_size = 5; 291 } 292 293 message AlterTableConstraint { 294 bytes constraints = 1; 295 } 296 297 message AlterTableComment { 298 string comment = 1; 299 } 300 301 message AlterTableRenameTable { 302 string old_name = 1; 303 string new_name = 2; 304 } 305 306 message AlterTableRenameCol { 307 string old_name = 1; 308 string new_name = 2; 309 uint32 sequence_num = 3; // used to double check 310 } 311 312 message AlterTableAddColumn { 313 plan.ColDef column = 1; 314 int32 insert_position = 2; // if the position can be found in the schema, 315 // the column will be added to the last 316 } 317 318 message AlterTableAddPartition { 319 plan.PartitionByDef partition_def = 1; 320 } 321 322 message AlterTableDropColumn { 323 uint32 logical_idx = 1; 324 uint32 sequence_num = 2; // used to double check 325 } 326 327 message AlterTableReq { 328 uint64 table_id = 1; 329 uint64 db_id = 2; 330 AlterKind kind = 3; 331 332 oneof operation { 333 AlterTableAddColumn add_column = 4; 334 AlterTableDropColumn drop_column = 5; 335 AlterTableRenameTable rename_table = 6; 336 AlterTableComment update_comment = 7; 337 AlterTableConstraint update_cstr = 8; 338 AlterTablePolicy update_policy = 9; 339 AlterTableAddPartition add_partition = 10; 340 AlterTableRenameCol rename_col = 11; 341 } 342 } 343 344 345 enum MergeHint { 346 Auto = 0; 347 NoDeletes = 1; 348 BigTable = 2; 349 ContinuousWrite = 3; 350 } 351 352 message SchemaExtra { 353 uint32 next_col_seqnum = 1; 354 // sending mo_columns deletes according to this. 355 repeated string dropped_attrs = 2; 356 bool column_changed = 3; 357 // sending mo_tables deletes by this. 358 string old_name = 4; 359 360 uint32 min_osize_quailifed = 5; 361 uint32 max_obj_onerun = 6; 362 uint32 max_osize_merged_obj = 7; 363 repeated MergeHint hints = 8; 364 uint64 min_cn_merge_size = 9; 365 } 366 367 // Int64Map mainly used in unit test 368 message Int64Map { 369 map<int64, int64> m = 1; 370 } 371 372 message TransDestPos { 373 int32 objIdx = 1; 374 int32 blkIdx = 2; 375 int32 rowIdx = 3; 376 } 377 378 message BlkTransMap { 379 map<int32, TransDestPos> m = 1[(gogoproto.nullable) = false]; 380 } 381 382 message BlkTransferBooking { 383 repeated BlkTransMap mappings = 1[(gogoproto.nullable) = false]; 384 } 385 386 387 message MergeCommitEntry { 388 uint64 db_id = 1; 389 uint64 tbl_id = 2; 390 string table_name = 3; 391 timestamp.Timestamp start_ts = 4[(gogoproto.nullable) = false]; 392 repeated bytes merged_objs = 5; 393 repeated bytes created_objs = 6; 394 BlkTransferBooking booking = 7; 395 bytes booking_loc = 8; 396 string err = 9; 397 } 398 399 message MergeTaskEntry { 400 uint64 db_id = 1; 401 uint64 tbl_id = 2; 402 string table_name = 3; 403 string db_name = 4; 404 // ObjectStats 405 repeated bytes to_merge_objs = 5; 406 uint64 estimated_mem_usage = 6; 407 uint32 account_id = 7; 408 uint32 user_id = 8; 409 uint32 role_id = 9; 410 }