ClientProxy.h 3.2 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
#pragma once

#include "GrpcClient.h"
S
starlord 已提交
21
#include "MilvusApi.h"
K
kun yu 已提交
22

S
starlord 已提交
23
#include <memory>
S
starlord 已提交
24 25
#include <string>
#include <vector>
S
starlord 已提交
26

K
kun yu 已提交
27 28 29
namespace milvus {

class ClientProxy : public Connection {
S
starlord 已提交
30
 public:
K
kun yu 已提交
31
    // Implementations of the Connection interface
S
starlord 已提交
32
    Status
S
starlord 已提交
33
    Connect(const ConnectParam& param) override;
K
kun yu 已提交
34

S
starlord 已提交
35
    Status
S
starlord 已提交
36
    Connect(const std::string& uri) override;
K
kun yu 已提交
37

S
starlord 已提交
38
    Status
K
kun yu 已提交
39 40
    Connected() const override;

S
starlord 已提交
41
    Status
K
kun yu 已提交
42 43
    Disconnect() override;

S
starlord 已提交
44
    Status
S
starlord 已提交
45
    CreateTable(const TableSchema& param) override;
K
kun yu 已提交
46

S
starlord 已提交
47
    bool
S
starlord 已提交
48
    HasTable(const std::string& table_name) override;
K
kun yu 已提交
49

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

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

S
starlord 已提交
56
    Status
G
groot 已提交
57
    Insert(const std::string& table_name, const std::string& partition_tag, const std::vector<RowRecord>& record_array,
S
starlord 已提交
58
           std::vector<int64_t>& id_array) override;
K
kun yu 已提交
59

S
starlord 已提交
60
    Status
G
groot 已提交
61 62 63
    Search(const std::string& table_name, const std::vector<std::string>& partiton_tags,
           const std::vector<RowRecord>& query_record_array, const std::vector<Range>& query_range_array, int64_t topk,
           int64_t nprobe, std::vector<TopKQueryResult>& topk_query_result_array) override;
K
kun yu 已提交
64

S
starlord 已提交
65
    Status
S
starlord 已提交
66
    DescribeTable(const std::string& table_name, TableSchema& table_schema) override;
K
kun yu 已提交
67

S
starlord 已提交
68
    Status
S
starlord 已提交
69
    CountTable(const std::string& table_name, int64_t& row_count) override;
K
kun yu 已提交
70

S
starlord 已提交
71
    Status
S
starlord 已提交
72
    ShowTables(std::vector<std::string>& table_array) override;
K
kun yu 已提交
73

S
starlord 已提交
74
    std::string
K
kun yu 已提交
75 76
    ClientVersion() const override;

S
starlord 已提交
77
    std::string
K
kun yu 已提交
78 79
    ServerVersion() const override;

S
starlord 已提交
80
    std::string
K
kun yu 已提交
81 82
    ServerStatus() const override;

S
starlord 已提交
83
    std::string
Y
Yu Kun 已提交
84 85
    DumpTaskTables() const override;

S
starlord 已提交
86
    Status
G
groot 已提交
87
    DeleteByDate(const std::string& table_name, const Range& range) override;
Y
Yu Kun 已提交
88

S
starlord 已提交
89
    Status
S
starlord 已提交
90
    PreloadTable(const std::string& table_name) const override;
Y
Yu Kun 已提交
91

S
starlord 已提交
92
    Status
S
starlord 已提交
93
    DescribeIndex(const std::string& table_name, IndexParam& index_param) const override;
Y
Yu Kun 已提交
94

S
starlord 已提交
95
    Status
S
starlord 已提交
96
    DropIndex(const std::string& table_name) const override;
Y
Yu Kun 已提交
97

G
groot 已提交
98 99 100 101 102 103 104 105 106
    Status
    CreatePartition(const PartitionParam& partition_param) override;

    Status
    ShowPartitions(const std::string& table_name, PartitionList& partition_array) const override;

    Status
    DropPartition(const PartitionParam& partition_param) override;

S
starlord 已提交
107
 private:
K
kun yu 已提交
108 109
    std::shared_ptr<::grpc::Channel> channel_;

S
starlord 已提交
110
 private:
K
kun yu 已提交
111
    std::shared_ptr<GrpcClient> client_ptr_;
K
kun yu 已提交
112 113 114
    bool connected_ = false;
};

S
starlord 已提交
115
}  // namespace milvus