github.com/matrixorigin/matrixone@v0.7.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  
    25  option go_package = "github.com/matrixorigin/matrixone/pkg/pb/api";
    26  option (gogoproto.sizer_all) = false;
    27  option (gogoproto.protosizer_all) = true;
    28  
    29  enum OpCode {
    30      Nop = 0;
    31      OpGetLogTail = 1000;
    32      OpWrite = 1001;
    33      OpPreCommit = 1002;
    34  }
    35  
    36  message Vector {
    37      bytes data = 1;
    38      plan.Type  type = 2;
    39      bool  nullable = 3;
    40      bytes nsp = 4;
    41      bool is_const = 5;
    42      uint32 len = 6;
    43      bytes area = 7;
    44  };
    45  
    46  message Batch {
    47      repeated string attrs = 1;
    48      repeated Vector vecs = 2;
    49  };
    50  
    51  message TableID {
    52      uint64 db_id  = 1; 
    53      uint64 tb_id  = 2;
    54      uint64 partition_id = 3;
    55  }
    56  
    57  // CN pull the log tail of table from DN.
    58  message SyncLogTailReq {
    59      timestamp.Timestamp cn_have = 1;
    60      timestamp.Timestamp cn_want = 2;
    61      TableID   table = 3;
    62  };
    63  
    64  message SyncLogTailResp {
    65    // ckp_location is a checkpoint location list.
    66    // How to get checkpoint data on S3 by the ckp_location ,
    67    // pls ref to disttae/logtail.go/consumeLogTail function.
    68    string     ckp_location = 1;
    69    // commands is log tail for a system or user table,
    70    // pls ref to tae/logtail/handle.go/HandleSyncLogTailReq function.
    71    repeated Entry commands = 2;
    72  };
    73  
    74  //How to parse and handle PrecommiWriteCmd , pls ref to tae/rpc/handle.go/HandlePreCommit function
    75  message PrecommitWriteCmd {
    76      uint32 user_id = 1;
    77      uint32 role_id = 2;
    78      uint32 account_id = 3;
    79      repeated Entry entry_list = 4;
    80  };
    81  
    82  // CN--->DN, DDL
    83  // create database test: 
    84  //      Entry {
    85  //          entry_type = Insert
    86  //          table_id = 0
    87  //          database_id = 0
    88  //          table_name = mo_database
    89  //          database_name = mo_catalog
    90  //          file_name = "" 
    91  //          bat = "test, 0, ..."
    92  //      }
    93  // drop database test:
    94  //      Entry {
    95  //          entry_type = Delete
    96  //          table_id = 0
    97  //          database_id = 0
    98  //          table_name = mo_database
    99  //          database_name = mo_catalog
   100  //          file_name = "" 
   101  //          bat= "test, 0, ..."
   102  //      }
   103  
   104  // create a user table: 
   105  //  insert entry into mo_tables and ...;
   106  //      Entry {
   107  //          entry_type = Insert
   108  //          table_id = 1
   109  //          database_id =  0
   110  //          table_name =  mo_tables
   111  //          database_name = mo_catalog
   112  //          file_name = "" 
   113  //          bat.attrs = {"relid", "relname", "reldatabase", ...}
   114  //      }
   115  
   116  // drop table: 
   117  //  delete entry from mo_tables and ...;
   118  //      Entry {
   119  //          entry_type = delete
   120  //          table_id = 1
   121  //          database_id = 0
   122  //          table_name =  mo_tables
   123  //          database_name = mo_catalog
   124  //          file_name = "" 
   125  //          bat.attrs = {"relid", "relname",...}
   126  //      }
   127  
   128  //  bulk load:
   129  // bulk loads a block into S3.
   130  //      Entry {
   131  //          entry_type = Insert
   132  //          table_id = tid
   133  //          database_id = dbId
   134  //          table_name =  xxx
   135  //          database_name = xxx
   136  //          // one S3 object file can hold many blocks.
   137  //          file_name = "s3 file name"
   138  //
   139  //          //  bat holds meta locations for many blocks.
   140  //          //  "meta_loc" : the location of block data which contains BF and ZM index and be sorted by primary key.
   141  //          bat.attrs = {"meta_loc"}
   142  //      }
   143  
   144  // deletes/updates involves many rows need to write S3.
   145  //      Entry {
   146  //          entry_type = Delete
   147  //          table_id = tid
   148  //          database_id = dbId
   149  //          table_name =  xxx
   150  //          database_name = xxx
   151  //
   152  //          // one S3 object file can contains many blocks
   153  //          file_name = "s3 file name"
   154  
   155  //          // "delta_loc" : the location of deleted row-ids for a block
   156  //          bat.attrs = {"delta_loc"}
   157  //      }
   158  
   159  
   160  //  DML:
   161  // append a batch of data into table;
   162  //            Entry {
   163      //          entry_type = Insert
   164      //          table_id =  tid
   165      //          database_id = dbId
   166      //          table_name =  xxx
   167      //          database_name = xxx
   168      //          file_name = "" 
   169      //          bat.attrs = {"primary column value",  "column1 value", ...}
   170      //      }
   171  
   172  
   173  //  delete batch of data from table;
   174  //            Entry {
   175      //          entry_type = Delete
   176      //          table_id =  tid
   177      //          database_id = dbId
   178      //          table_name =  xxx
   179      //          database_name = xxx
   180      //          file_name = ""
   181      //          bat.attrs = {"rowid"}
   182      //      }
   183  
   184  
   185  message Entry {
   186      enum EntryType {
   187          Insert = 0;
   188          Delete = 1;
   189          Update = 2;
   190      }
   191      EntryType entry_type = 1;
   192      uint64    table_id = 2;
   193      uint64    database_id = 3;
   194      string    table_name = 4;
   195      string    database_name = 5;
   196      string    file_name = 6;
   197      Batch     bat = 8;
   198  };
   199  
   200  // There are two kinds of checkpoint: delta checkpoint and base checkpoint,
   201  // base checkpoint is a snapshot at a timestamp for catalog and block meta.
   202  // delta checkpoint is a mini checkpoint represents changes during a period.
   203  
   204  // CatalogCkp contains information about database and tables in the system,and
   205  // MetadataCkp contains information about blocks.
   206  message Checkpoint {
   207      //min_ts DN is the lower bounds of the checkpoint
   208      // CN maybe don't care about it.
   209      timestamp.Timestamp min_ts = 1;
   210      //max_ts is the upper bounds of the checkpoint.
   211      // CN maybe don't care about it.
   212      timestamp.Timestamp max_ts = 2;
   213      Batch      bat   = 3;
   214  
   215  };
   216  // catalog checkpoint:
   217  // one Batch represents a table, such as : mo_databases, mo_tables, mo_columns,... etc.
   218  // knowing more about system tables, pls ref to pkg/vm/engine/tae/catalog/model.go
   219  message CatalogCkp {
   220     timestamp.Timestamp min_ts = 1;
   221     timestamp.Timestamp max_ts = 2;
   222     Batch      bat   = 3;
   223  };
   224  
   225  //metadata checkpoint:
   226  // Batch is a batch of block metadata for a table,  
   227  // one row of Batch represents a block meta data.
   228  // TODO::
   229  // knowing more about block meta data , pls ref to ...
   230  message MetadataCkp {
   231      timestamp.Timestamp min_ts = 1;
   232      timestamp.Timestamp max_ts = 2;
   233      //block meta data for a table;
   234      Batch      bat = 3;
   235  };
   236