// Copyright 2023 Greptime Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package greptime.v1;

option go_package = "github.com/GreptimeTeam/greptime-proto/go/greptime/v1";

import "greptime/v1/row.proto";

// Type of operation to rows.
enum OpType {
  // Delete rows.
  DELETE = 0;
  // Put rows.
  PUT = 1;
}

// Encoding of primary key.
enum PrimaryKeyEncoding {
  DENSE = 0;
  SPARSE = 1;
}

// Write hint of the mutation.
message WriteHint {
  PrimaryKeyEncoding primary_key_encoding = 1;
}

// Mutation contains updates to a set of rows.
message Mutation {
  // Type of this mutation.
  OpType op_type = 1;
  // Start WAL sequence of this mutation.
  uint64 sequence = 2;
  // Row updates to write to the WAL.
  Rows rows = 3;
  // Write hint of the mutation.
  WriteHint write_hint = 4;
}

// A WAL entry contains a list of mutations for a region to write.
message WalEntry {
  // List of mutations for a region.
  repeated Mutation mutations = 1;
}
