GrpcRequestHandler.h 9.5 KB
Newer Older
J
jinhai 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you 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.

K
kun yu 已提交
18 19 20 21 22
#pragma once

#include <cstdint>
#include <string>

G
groot 已提交
23 24
#include "grpc/gen-milvus/milvus.grpc.pb.h"
#include "grpc/gen-status/status.pb.h"
K
kun yu 已提交
25 26 27 28

namespace zilliz {
namespace milvus {
namespace server {
Y
Yu Kun 已提交
29
namespace grpc {
Y
Yu Kun 已提交
30
class GrpcRequestHandler final : public ::milvus::grpc::MilvusService::Service {
G
groot 已提交
31
 public:
K
kun yu 已提交
32 33 34 35 36
    /**
     * @brief Create table method
     *
     * This method is used to create table
     *
Y
Yu Kun 已提交
37
     * @param context, add context for every RPC
K
kun yu 已提交
38 39
     * @param request, used to provide table information to be created.
     * @param response, used to get the status
K
kun yu 已提交
40
     *
K
kun yu 已提交
41
     * @return status
K
kun yu 已提交
42
     *
K
kun yu 已提交
43 44
     * @param request
     * @param response
Y
Yu Kun 已提交
45
     * @param context
K
kun yu 已提交
46
     */
K
kun yu 已提交
47
    ::grpc::Status
G
groot 已提交
48 49
    CreateTable(::grpc::ServerContext* context, const ::milvus::grpc::TableSchema* request,
                ::milvus::grpc::Status* response) override;
K
kun yu 已提交
50 51 52 53 54 55

    /**
     * @brief Test table existence method
     *
     * This method is used to test table existence.
     *
Y
Yu Kun 已提交
56
     * @param context, add context for every RPC
K
kun yu 已提交
57 58
     * @param request, table name is going to be tested.
     * @param response, get the bool reply of hastable
K
kun yu 已提交
59
     *
K
kun yu 已提交
60
     * @return status
K
kun yu 已提交
61
     *
K
kun yu 已提交
62 63
     * @param request
     * @param response
Y
Yu Kun 已提交
64
     * @param context
K
kun yu 已提交
65
     */
K
kun yu 已提交
66
    ::grpc::Status
G
groot 已提交
67 68
    HasTable(::grpc::ServerContext* context, const ::milvus::grpc::TableName* request,
             ::milvus::grpc::BoolReply* response) override;
K
kun yu 已提交
69 70 71 72 73 74

    /**
     * @brief Drop table method
     *
     * This method is used to drop table.
     *
Y
Yu Kun 已提交
75
     * @param context, add context for every RPC
K
kun yu 已提交
76 77
     * @param request, table name is going to be deleted.
     * @param response, get the status of droptable
K
kun yu 已提交
78
     *
K
kun yu 已提交
79
     * @return status
K
kun yu 已提交
80
     *
K
kun yu 已提交
81 82
     * @param request
     * @param response
Y
Yu Kun 已提交
83
     * @param context
K
kun yu 已提交
84
     */
K
kun yu 已提交
85
    ::grpc::Status
G
groot 已提交
86 87
    DropTable(::grpc::ServerContext* context, const ::milvus::grpc::TableName* request,
              ::milvus::grpc::Status* response) override;
K
kun yu 已提交
88 89 90 91 92 93

    /**
     * @brief build index by table method
     *
     * This method is used to build index by table in sync.
     *
Y
Yu Kun 已提交
94
     * @param context, add context for every RPC
K
kun yu 已提交
95 96
     * @param request, table name is going to be built index.
     * @param response, get the status of buildindex
K
kun yu 已提交
97
     *
K
kun yu 已提交
98
     * @return status
K
kun yu 已提交
99
     *
K
kun yu 已提交
100 101
     * @param request
     * @param response
Y
Yu Kun 已提交
102
     * @param context
K
kun yu 已提交
103
     */
K
kun yu 已提交
104
    ::grpc::Status
G
groot 已提交
105 106
    CreateIndex(::grpc::ServerContext* context, const ::milvus::grpc::IndexParam* request,
                ::milvus::grpc::Status* response) override;
K
kun yu 已提交
107 108 109 110 111 112

    /**
     * @brief Insert vector array to table
     *
     * This method is used to insert vector array to table.
     *
Y
Yu Kun 已提交
113
     * @param context, add context for every RPC
K
kun yu 已提交
114 115
     * @param request, table_name is inserted.
     * @param response, vector array is inserted.
K
kun yu 已提交
116
     *
K
kun yu 已提交
117
     * @return status
K
kun yu 已提交
118
     *
Y
Yu Kun 已提交
119
     * @param context
K
kun yu 已提交
120 121
     * @param request
     * @param response
K
kun yu 已提交
122
     */
K
kun yu 已提交
123
    ::grpc::Status
G
groot 已提交
124 125
    Insert(::grpc::ServerContext* context, const ::milvus::grpc::InsertParam* request,
           ::milvus::grpc::VectorIds* response) override;
K
kun yu 已提交
126 127 128 129 130 131

    /**
     * @brief Query vector
     *
     * This method is used to query vector in table.
     *
Y
Yu Kun 已提交
132
     * @param context, add context for every RPC
K
kun yu 已提交
133 134 135 136 137
     * @param request:
     *               table_name, table_name is queried.
     *               query_record_array, all vector are going to be queried.
     *               query_range_array, optional ranges for conditional search. If not specified, search whole table
     *               topk, how many similarity vectors will be searched.
K
kun yu 已提交
138
     *
K
kun yu 已提交
139
     * @param writer, write query result array.
K
kun yu 已提交
140
     *
K
kun yu 已提交
141
     * @return status
Y
Yu Kun 已提交
142 143
     *
     * @param context
K
kun yu 已提交
144 145
     * @param request
     * @param writer
K
kun yu 已提交
146
     */
K
kun yu 已提交
147
    ::grpc::Status
G
groot 已提交
148 149
    Search(::grpc::ServerContext* context, const ::milvus::grpc::SearchParam* request,
           ::milvus::grpc::TopKQueryResultList* response) override;
K
kun yu 已提交
150 151 152 153 154 155

    /**
   * @brief Internal use query interface
   *
   * This method is used to query vector in specified files.
   *
Y
Yu Kun 已提交
156
   * @param context, add context for every RPC
K
kun yu 已提交
157 158 159 160 161 162 163
   * @param request:
   *                file_id_array, specified files id array, queried.
   *                query_record_array, all vector are going to be queried.
   *                query_range_array, optional ranges for conditional search. If not specified, search whole table
   *                topk, how many similarity vectors will be searched.
   *
   * @param writer, write query result array.
K
kun yu 已提交
164
   *
K
kun yu 已提交
165
   * @return status
K
kun yu 已提交
166
   *
Y
Yu Kun 已提交
167
   * @param context
K
kun yu 已提交
168 169
   * @param request
   * @param writer
K
kun yu 已提交
170
   */
K
kun yu 已提交
171
    ::grpc::Status
G
groot 已提交
172 173
    SearchInFiles(::grpc::ServerContext* context, const ::milvus::grpc::SearchInFilesParam* request,
                  ::milvus::grpc::TopKQueryResultList* response) override;
K
kun yu 已提交
174 175 176 177 178 179

    /**
     * @brief Get table schema
     *
     * This method is used to get table schema.
     *
Y
Yu Kun 已提交
180 181 182
     * @param context, add context for every RPC
     * @param request, target table name.
     * @param response, table schema
K
kun yu 已提交
183
     *
Y
Yu Kun 已提交
184
     * @return status
K
kun yu 已提交
185
     *
Y
Yu Kun 已提交
186 187 188
     * @param context
     * @param request
     * @param response
K
kun yu 已提交
189
     */
K
kun yu 已提交
190
    ::grpc::Status
G
groot 已提交
191 192
    DescribeTable(::grpc::ServerContext* context, const ::milvus::grpc::TableName* request,
                  ::milvus::grpc::TableSchema* response) override;
K
kun yu 已提交
193 194 195 196 197 198

    /**
     * @brief Get table row count
     *
     * This method is used to get table row count.
     *
Y
Yu Kun 已提交
199 200 201
     * @param context, add context for every RPC
     * @param request, target table name.
     * @param response, table row count
K
kun yu 已提交
202 203 204
     *
     * @return table row count
     *
Y
Yu Kun 已提交
205 206 207
     * @param request
     * @param response
     * @param context
K
kun yu 已提交
208
     */
K
kun yu 已提交
209
    ::grpc::Status
G
groot 已提交
210 211
    CountTable(::grpc::ServerContext* context, const ::milvus::grpc::TableName* request,
               ::milvus::grpc::TableRowCount* response) override;
K
kun yu 已提交
212 213 214 215 216 217

    /**
     * @brief List all tables in database
     *
     * This method is used to list all tables.
     *
Y
Yu Kun 已提交
218 219 220
     * @param context, add context for every RPC
     * @param request, show table command, usually not use
     * @param writer, write tables to client
K
kun yu 已提交
221
     *
K
kun yu 已提交
222
     * @return status
Y
Yu Kun 已提交
223 224 225 226
     *
     * @param context
     * @param request
     * @param writer
K
kun yu 已提交
227
     */
K
kun yu 已提交
228
    ::grpc::Status
G
groot 已提交
229
    ShowTables(::grpc::ServerContext* context, const ::milvus::grpc::Command* request,
G
groot 已提交
230
               ::milvus::grpc::TableNameList* response) override;
K
kun yu 已提交
231 232 233 234 235 236

    /**
     * @brief Give the server status
     *
     *
     * This method is used to give the server status.
Y
Yu Kun 已提交
237 238 239
     * @param context, add context for every RPC
     * @param request, give server command
     * @param response, server status
K
kun yu 已提交
240
     *
K
kun yu 已提交
241
     * @return status
K
kun yu 已提交
242
     *
Y
Yu Kun 已提交
243 244 245
     * @param context
     * @param request
     * @param response
K
kun yu 已提交
246
     */
K
kun yu 已提交
247
    ::grpc::Status
G
groot 已提交
248 249
    Cmd(::grpc::ServerContext* context, const ::milvus::grpc::Command* request,
        ::milvus::grpc::StringReply* response) override;
Y
Yu Kun 已提交
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265

    /**
     * @brief delete table by range
     *
     * This method is used to delete table by range.
     * @param context, add context for every RPC
     * @param request, table name and range
     * @param response, status
     *
     * @return status
     *
     * @param context
     * @param request
     * @param response
     */
    ::grpc::Status
G
groot 已提交
266 267
    DeleteByRange(::grpc::ServerContext* context, const ::milvus::grpc::DeleteByRangeParam* request,
                  ::milvus::grpc::Status* response) override;
Y
Yu Kun 已提交
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283

    /**
     * @brief preload table
     *
     * This method is used to preload table.
     * @param context, add context for every RPC
     * @param request, table name
     * @param response, status
     *
     * @return status
     *
     * @param context
     * @param request
     * @param response
     */
    ::grpc::Status
G
groot 已提交
284 285
    PreloadTable(::grpc::ServerContext* context, const ::milvus::grpc::TableName* request,
                 ::milvus::grpc::Status* response) override;
Y
Yu Kun 已提交
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301

    /**
     * @brief Describe index
     *
     * This method is used to describe index.
     * @param context, add context for every RPC
     * @param request, table name
     * @param response, index informations
     *
     * @return status
     *
     * @param context
     * @param request
     * @param response
     */
    ::grpc::Status
G
groot 已提交
302 303
    DescribeIndex(::grpc::ServerContext* context, const ::milvus::grpc::TableName* request,
                  ::milvus::grpc::IndexParam* response) override;
Y
Yu Kun 已提交
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319

    /**
     * @brief Drop index
     *
     * This method is used to drop index.
     * @param context, add context for every RPC
     * @param request, table name
     * @param response, status
     *
     * @return status
     *
     * @param context
     * @param request
     * @param response
     */
    ::grpc::Status
G
groot 已提交
320 321
    DropIndex(::grpc::ServerContext* context, const ::milvus::grpc::TableName* request,
              ::milvus::grpc::Status* response) override;
K
kun yu 已提交
322
};
G
groot 已提交
323

G
groot 已提交
324 325 326 327
}  // namespace grpc
}  // namespace server
}  // namespace milvus
}  // namespace zilliz