package exec.bit.data;

option java_package = "org.apache.drill.exec.proto";
option java_outer_classname = "BitData";
option optimize_for = SPEED;

import "ExecutionProtos.proto";
import "Coordination.proto";
import "UserBitShared.proto";

enum RpcType {
  HANDSHAKE = 0;
  ACK = 1;
  GOODBYE = 2;
  REQ_RECORD_BATCH = 3; // send record batch, returns Ack

  // both bit request and response
  SASL_MESSAGE = 4;

  REQ_RUNTIME_FILTER = 5; // send runtime filter data from HashJoin to Foreman, from Foreman to Scan nodes.
}

message BitClientHandshake{
  optional int32 rpc_version = 1;
  optional exec.shared.RpcChannel channel = 2 [default = BIT_DATA];
}

message BitServerHandshake{
  optional int32 rpc_version = 1;
  repeated string authenticationMechanisms = 2;
}

message FragmentRecordBatch{
  optional exec.shared.QueryId query_id = 1;
  optional int32 receiving_major_fragment_id = 2;
  repeated int32 receiving_minor_fragment_id = 3; 
  optional int32 sending_major_fragment_id = 4;
  optional int32 sending_minor_fragment_id = 5;
  optional exec.shared.RecordBatchDef def = 6;
  optional bool isLastBatch = 7;
}

message RuntimeFilterBDef{
  optional exec.shared.QueryId query_id = 1;
  optional int32 major_fragment_id = 2;
  optional int32 minor_fragment_id = 3;
  optional bool to_foreman = 4; // true means sending to foreman,false means sending to scan nodes
  repeated int32 bloom_filter_size_in_bytes = 5;
  repeated string probe_fields = 6; // probe fields with corresponding BloomFilters
  optional int32 hj_op_id = 7; // the operator id of the HashJoin which generates this RuntimeFilter
  optional int64 rf_identifier = 8; // the runtime filter identifier
}
