GrpcClient.h 2.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
#pragma once
S
starlord 已提交
19 20 21 22 23

#include "MilvusApi.h"
#include "grpc/gen-milvus/milvus.grpc.pb.h"
//#include "grpc/gen-status/status.grpc.pb.h"

K
kun yu 已提交
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
#include <chrono>
#include <iostream>
#include <memory>
#include <random>
#include <string>
#include <thread>

#include <grpc/grpc.h>
#include <grpcpp/channel.h>
#include <grpcpp/client_context.h>
#include <grpcpp/create_channel.h>
#include <grpcpp/security/credentials.h>

namespace milvus {
class GrpcClient {
S
starlord 已提交
39
 public:
S
starlord 已提交
40
    explicit GrpcClient(std::shared_ptr<::grpc::Channel>& channel);
K
kun yu 已提交
41

S
starlord 已提交
42
    virtual ~GrpcClient();
K
kun yu 已提交
43

K
kun yu 已提交
44
    Status
S
starlord 已提交
45
    CreateTable(const grpc::TableSchema& table_schema);
K
kun yu 已提交
46

K
kun yu 已提交
47
    bool
S
starlord 已提交
48
    HasTable(const grpc::TableName& table_name, Status& status);
K
kun yu 已提交
49

K
kun yu 已提交
50
    Status
S
starlord 已提交
51
    DropTable(const grpc::TableName& table_name);
K
kun yu 已提交
52

K
kun yu 已提交
53
    Status
S
starlord 已提交
54
    CreateIndex(const grpc::IndexParam& index_param);
K
kun yu 已提交
55

K
kun yu 已提交
56
    void
S
starlord 已提交
57
    Insert(grpc::VectorIds& vector_ids, const grpc::InsertParam& insert_param, Status& status);
K
kun yu 已提交
58

K
kun yu 已提交
59
    Status
60
    Search(::milvus::grpc::TopKQueryResult& topk_query_result, const grpc::SearchParam& search_param);
K
kun yu 已提交
61

K
kun yu 已提交
62
    Status
S
starlord 已提交
63
    DescribeTable(grpc::TableSchema& grpc_schema, const std::string& table_name);
K
kun yu 已提交
64

K
kun yu 已提交
65
    int64_t
S
starlord 已提交
66
    CountTable(const std::string& table_name, Status& status);
K
kun yu 已提交
67

K
kun yu 已提交
68
    Status
S
starlord 已提交
69
    ShowTables(milvus::grpc::TableNameList& table_name_list);
K
kun yu 已提交
70

K
kun yu 已提交
71
    Status
S
starlord 已提交
72
    Cmd(std::string& result, const std::string& cmd);
Y
Yu Kun 已提交
73 74

    Status
S
starlord 已提交
75
    DeleteByRange(grpc::DeleteByRangeParam& delete_by_range_param);
Y
Yu Kun 已提交
76 77

    Status
S
starlord 已提交
78
    PreloadTable(grpc::TableName& table_name);
Y
Yu Kun 已提交
79 80

    Status
S
starlord 已提交
81
    DescribeIndex(grpc::TableName& table_name, grpc::IndexParam& index_param);
Y
Yu Kun 已提交
82 83

    Status
S
starlord 已提交
84
    DropIndex(grpc::TableName& table_name);
K
kun yu 已提交
85

K
kun yu 已提交
86 87
    Status
    Disconnect();
K
kun yu 已提交
88

S
starlord 已提交
89
 private:
K
kun yu 已提交
90 91 92
    std::unique_ptr<grpc::MilvusService::Stub> stub_;
};

S
starlord 已提交
93
}  // namespace milvus