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

import "common.proto";
import "service_msg.proto";


enum MsgType {
    kNone = 0;
    /* Definition Requests: collection */
    kCreateCollection = 100;
    kDropCollection = 101;
    kHasCollection = 102;
    kDescribeCollection = 103;
    kShowCollections = 104;

    /* Definition Requests: partition */
    kCreatePartition = 200;
    kDropPartition = 201;
    kHasPartition = 202;
    kDescribePartition = 203;
    kShowPartitions = 204;

    /* Manipulation Requests */
    kInsert = 400;
    kDelete = 401;

    /* Query */
    kSearch = 500;
    kSearchResult = 501;

    /* System Control */
    kTimeTick = 1200;
    kQueryNodeSegStats = 1201;
}

enum PeerRole {

    Master = 0;

    Reader = 1;

    Writer = 2;

    Proxy = 3;

}

message IDRequest {
    int64 peerID = 1;
    PeerRole role = 2;
    uint32 count = 3;
}

message IDResponse {
    common.Status status = 1;
    int64 ID = 2;
    uint32 count = 3;
}

message TsoRequest {
    int64 peerID = 1;
    PeerRole role = 2;
    uint32 count = 3;
}

message TsoResponse {
    common.Status status = 1;
    uint64 timestamp = 2;
    uint32 count = 3;
}


message CreateCollectionRequest {
    MsgType msg_type = 1;
    int64 reqID = 2;
    uint64 timestamp = 3;
    int64 proxyID = 4;
    common.Blob schema = 5;
}


message DropCollectionRequest {
    MsgType msg_type = 1;
    int64 reqID = 2;
    uint64 timestamp = 3;
    int64 proxyID = 4;
    service.CollectionName collection_name = 5;
}


message HasCollectionRequest {
    MsgType msg_type = 1;
    int64 reqID = 2;
    uint64 timestamp = 3;
    int64 proxyID = 4;
    service.CollectionName collection_name = 5;
}


message DescribeCollectionRequest {
    MsgType msg_type = 1;
    int64 reqID = 2;
    uint64 timestamp = 3;
    int64 proxyID = 4;
    service.CollectionName collection_name = 5;
}


message ShowCollectionRequest {
    MsgType msg_type = 1;
    int64 reqID = 2;
    uint64 timestamp = 3;
    int64 proxyID = 4;
}


message CreatePartitionRequest {
    MsgType msg_type = 1;
    int64 reqID = 2;
    uint64 timestamp = 3;
    int64 proxyID = 4;
    service.PartitionName partition_name = 5;
}


message DropPartitionRequest {
    MsgType msg_type = 1;
    int64 reqID = 2;
    uint64 timestamp = 3;
    int64 proxyID = 4;
    service.PartitionName partition_name = 5;
}


message HasPartitionRequest {
    MsgType msg_type = 1;
    int64 reqID = 2;
    uint64 timestamp = 3;
    int64 proxyID = 4;
    service.PartitionName partition_name = 5;
}


message DescribePartitionRequest {
    MsgType msg_type = 1;
    int64 reqID = 2;
    uint64 timestamp = 3;
    int64 proxyID = 4;
    service.PartitionName partition_name = 5;
}


message ShowPartitionRequest {
    MsgType msg_type = 1;
    int64 reqID = 2;
    uint64 timestamp = 3;
    int64 proxyID = 4;
    service.CollectionName collection_name = 5;
}


message InsertRequest {
    MsgType msg_type = 1;
    int64 reqID = 2;
    string collection_name = 3;
    string partition_tag = 4;
    int64 segmentID = 5;
    int64 channelID = 6;
    int64 proxyID = 7;
    repeated uint64 timestamps = 8;
    repeated int64 rowIDs = 9;
    repeated common.Blob row_data = 10;
}


message DeleteRequest {
    MsgType msg_type = 1;
    int64 reqID = 2;
    string collection_name = 3;
    int64 channelID = 4;
    int64 proxyID = 5;
    repeated uint64 timestamps = 6;
    repeated int64 primary_keys = 7;
}


message SearchRequest {
    MsgType msg_type = 1;
    int64 reqID = 2;
    int64 proxyID = 3;
    uint64 timestamp = 4;
    int64 result_channelID = 5;
    common.Blob query = 6;

}

message SearchResult {
    MsgType msg_type = 1;
    common.Status status = 2;
    int64 reqID = 3;
    int64 proxyID = 4;
    int64 query_nodeID = 5;
    uint64 timestamp = 6;
    int64 result_channelID = 7;
    repeated service.Hits hits = 8;
}

message TimeTickMsg {
    MsgType msg_type = 1;
    int64 peerID = 2;
    uint64 timestamp = 3;
}


message Key2Seg {
    int64 rowID = 1;
    int64 primary_key = 2;
    uint64 timestamp = 3;
    bool is_valid = 4;
    repeated int64 segmentIDs = 5;
}


message Key2SegMsg {
    int64 reqID = 1;
    repeated Key2Seg key2seg = 2;
}

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

message QueryNodeSegStats {
    MsgType msg_type = 1;
    int64 peerID = 2;
    repeated SegmentStats seg_stats = 3;
}