syntax = "proto3";
package milvus.proto.internal;
option go_package = "github.com/milvus-io/milvus/internal/proto/internalpb";

import "common.proto";
import "schema.proto";

enum StateCode {
  Initializing = 0;
  Healthy = 1;
  Abnormal = 2;
}

message ComponentInfo {
  int64 nodeID = 1;
  string role = 2;
  StateCode state_code = 3;
  repeated common.KeyValuePair extra_info = 4;
}

message ComponentStates {
  ComponentInfo state = 1;
  repeated ComponentInfo subcomponent_states = 2;
  common.Status status = 3;
}

message GetComponentStatesRequest {
}

message GetTimeTickChannelRequest {
}

message GetStatisticsChannelRequest {
}

message GetDdChannelRequest {
}

message NodeInfo {
  common.Address address = 1;
  string role = 2;
}

message InitParams {
  int64 nodeID = 1;
  repeated common.KeyValuePair start_params = 2;
}

message StringList {
  repeated string values = 1;
  common.Status status = 2;
}

message TimeTickMsg {
  common.MsgBase base = 1;
}

message CreateCollectionRequest {
  common.MsgBase base = 1;
  string db_name = 2;
  string collectionName = 3;
  string partitionName = 4;
  // `schema` is the serialized `schema.CollectionSchema`
  int64 dbID = 5;
  int64 collectionID = 6;
  int64 partitionID = 7;
  bytes schema = 8;
  repeated string virtualChannelNames = 9;
  repeated string physicalChannelNames = 10;
}

message DropCollectionRequest {
  common.MsgBase base = 1;
  string db_name = 2;
  string collectionName = 3;
  int64 dbID = 4;
  int64 collectionID = 5;
}

message CreatePartitionRequest {
  common.MsgBase base = 1;
  string db_name = 2;
  string collection_name = 3;
  string partition_name = 4;
  int64 dbID = 5;
  int64 collectionID = 6;
  int64 partitionID = 7;
}

message DropPartitionRequest {
  common.MsgBase base = 1;
  string db_name = 2;
  string collection_name = 3;
  string partition_name = 4;
  int64 dbID = 5;
  int64 collectionID = 6;
  int64 partitionID = 7;
}

message CreateAliasRequest {
  common.MsgBase base = 1;
  string db_name = 2;
  string collection_name = 3;
  string alias = 4;
}

message DropAliasRequest {
  common.MsgBase base = 1;
  string db_name = 2;
  string alias = 3;
}

message AlterAliasRequest{
  common.MsgBase base = 1;
  string db_name = 2;
  string collection_name = 3;
  string alias = 4;
}

message CreateIndexRequest {
  common.MsgBase base = 1;
  string db_name = 2;
  string collection_name = 3;
  string field_name = 4;
  int64 dbID = 5;
  int64 collectionID = 6;
  int64 fieldID = 7;
  repeated common.KeyValuePair extra_params = 8;
}

message InsertRequest {
  common.MsgBase base = 1;
  string shardName = 2;
  string db_name = 3;
  string collection_name = 4;
  string partition_name = 5;
  int64 dbID = 6;
  int64 collectionID = 7;
  int64 partitionID = 8;
  int64 segmentID = 9;
  repeated uint64 timestamps = 10;
  repeated int64 rowIDs = 11;
  repeated common.Blob row_data = 12;
}

message SearchRequest {
  common.MsgBase base = 1;
  string result_channelID = 2;
  int64 dbID = 3;
  int64 collectionID = 4;
  repeated int64 partitionIDs = 5;
  string dsl = 6;
  // serialized `PlaceholderGroup`
  bytes placeholder_group = 7;
  common.DslType dsl_type = 8;
  bytes serialized_expr_plan = 9;
  repeated int64 output_fields_id = 10;
  uint64 travel_timestamp = 11;
  uint64 guarantee_timestamp = 12;
}

message SearchResults {
  common.MsgBase base = 1;
  common.Status status = 2;
  string result_channelID = 3;
  string metric_type = 4;
  int64 num_queries = 5;
  int64 top_k = 6;
  repeated int64 sealed_segmentIDs_searched = 7;
  repeated string channelIDs_searched = 8;
  repeated int64 global_sealed_segmentIDs = 9;
  // schema.SearchResultsData inside
  bytes sliced_blob = 10;
  int64 sliced_num_count = 11;
  int64 sliced_offset = 12;
}

message RetrieveRequest {
  common.MsgBase base = 1;
  string result_channelID = 2;
  int64 dbID = 3;
  int64 collectionID = 4;
  repeated int64 partitionIDs = 5;
  bytes serialized_expr_plan = 6;
  repeated int64 output_fields_id = 7;
  uint64 travel_timestamp = 8;
  uint64 guarantee_timestamp = 9;
}

message RetrieveResults {
  common.MsgBase base = 1;
  common.Status status = 2;
  string result_channelID = 3;
  schema.IDs ids = 4;
  repeated schema.FieldData fields_data = 5;
  repeated int64 sealed_segmentIDs_retrieved = 6;
  repeated string channelIDs_retrieved = 7;
  repeated int64 global_sealed_segmentIDs = 8;
}

message DeleteRequest {
  common.MsgBase base = 1;
  string shardName = 2;
  string db_name = 3;
  string collection_name = 4;
  string partition_name = 5;
  int64 dbID = 6;
  int64 collectionID = 7;
  int64 partitionID = 8;
  repeated int64 primary_keys = 9;
  repeated uint64 timestamps = 10;
}

message LoadBalanceSegmentsRequest {
  common.MsgBase base = 1;
  repeated int64 segmentIDs = 2;
}

message LoadIndex {
  common.MsgBase base = 1;
  int64 segmentID = 2;
  string fieldName = 3;
  int64 fieldID = 4;
  repeated string index_paths = 5;
  repeated common.KeyValuePair index_params = 6;
}

message SegmentStatisticsUpdates {
  int64 SegmentID = 1;
  int64 MemorySize = 2;
  int64 NumRows = 3;
  uint64 create_time = 4;
  uint64 end_time = 5;
  internal.MsgPosition start_position = 6;
  internal.MsgPosition end_position = 7;
}

message SegmentStatistics {
  common.MsgBase base = 1;
  repeated SegmentStatisticsUpdates SegStats = 2;
}

message IndexStats {
  repeated common.KeyValuePair index_params = 1;
  int64 num_related_segments = 2;
}

message FieldStats {
  int64 collectionID = 1;
  int64 fieldID = 2;
  repeated IndexStats index_stats = 3;
}

message SegmentStats {
  int64 segmentID = 1;
  int64 memory_size = 2;
  int64 num_rows = 3;
  bool recently_modified = 4;
}

message QueryNodeStats {
  common.MsgBase base = 1;
  repeated SegmentStats seg_stats = 2;
  repeated FieldStats field_stats = 3;
}

message MsgPosition {
  string channel_name = 1;
  bytes msgID = 2;
  string msgGroup = 3;
  uint64 timestamp = 4;
}

message ChannelTimeTickMsg {
  common.MsgBase base = 1;
  repeated string channelNames = 2;
  repeated uint64 timestamps = 3;
  uint64 default_timestamp = 4;
}
