ConnectionImpl.cpp 5.6 KB
Newer Older
1
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
J
jinhai 已提交
2
//
3 4
// Licensed 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
J
jinhai 已提交
5
//
6 7 8 9 10
// 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.
J
jinhai 已提交
11

Y
yukun 已提交
12
#include "interface/ConnectionImpl.h"
K
kun yu 已提交
13 14 15 16 17 18 19 20 21

namespace milvus {

std::shared_ptr<Connection>
Connection::Create() {
    return std::shared_ptr<Connection>(new ConnectionImpl());
}

Status
S
starlord 已提交
22
Connection::Destroy(std::shared_ptr<milvus::Connection>& connection_ptr) {
K
kun yu 已提交
23 24 25
    if (connection_ptr != nullptr) {
        return connection_ptr->Disconnect();
    }
K
kun yu 已提交
26 27 28 29 30 31 32 33 34
    return Status::OK();
}

//////////////////////////////////////////////////////////////////////////////////////////////
ConnectionImpl::ConnectionImpl() {
    client_proxy_ = std::make_shared<ClientProxy>();
}

Status
S
starlord 已提交
35
ConnectionImpl::Connect(const ConnectParam& param) {
K
kun yu 已提交
36 37 38 39
    return client_proxy_->Connect(param);
}

Status
S
starlord 已提交
40
ConnectionImpl::Connect(const std::string& uri) {
K
kun yu 已提交
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
    return client_proxy_->Connect(uri);
}

Status
ConnectionImpl::Connected() const {
    return client_proxy_->Connected();
}

Status
ConnectionImpl::Disconnect() {
    return client_proxy_->Disconnect();
}

std::string
ConnectionImpl::ClientVersion() const {
K
kun yu 已提交
56
    return client_proxy_->ClientVersion();
K
kun yu 已提交
57 58 59
}

Status
S
starlord 已提交
60
ConnectionImpl::CreateTable(const TableSchema& param) {
K
kun yu 已提交
61 62 63 64
    return client_proxy_->CreateTable(param);
}

bool
S
starlord 已提交
65
ConnectionImpl::HasTable(const std::string& table_name) {
K
kun yu 已提交
66 67 68 69
    return client_proxy_->HasTable(table_name);
}

Status
S
starlord 已提交
70
ConnectionImpl::DropTable(const std::string& table_name) {
K
kun yu 已提交
71 72 73
    return client_proxy_->DropTable(table_name);
}

K
kun yu 已提交
74
Status
S
starlord 已提交
75
ConnectionImpl::CreateIndex(const IndexParam& index_param) {
Y
Yu Kun 已提交
76
    return client_proxy_->CreateIndex(index_param);
K
kun yu 已提交
77 78 79
}

Status
G
groot 已提交
80 81 82
ConnectionImpl::Insert(const std::string& table_name, const std::string& partition_tag,
                       const std::vector<RowRecord>& record_array, std::vector<int64_t>& id_array) {
    return client_proxy_->Insert(table_name, partition_tag, record_array, id_array);
K
kun yu 已提交
83 84
}

85 86 87 88 89 90 91
Status
ConnectionImpl::GetVectorByID(const std::string& table_name, int64_t vector_id, RowRecord& vector_data) {
    return client_proxy_->GetVectorByID(table_name, vector_id, vector_data);
}

Status
ConnectionImpl::GetIDsInSegment(const std::string& table_name, const std::string& segment_name,
92
                                std::vector<int64_t>& id_array) {
93 94 95
    return client_proxy_->GetIDsInSegment(table_name, segment_name, id_array);
}

K
kun yu 已提交
96
Status
G
groot 已提交
97
ConnectionImpl::Search(const std::string& table_name, const std::vector<std::string>& partition_tags,
98
                       const std::vector<RowRecord>& query_record_array, int64_t topk, const std::string& extra_params,
99
                       TopKQueryResult& topk_query_result) {
100
    return client_proxy_->Search(table_name, partition_tags, query_record_array, topk, extra_params, topk_query_result);
101 102
}

K
kun yu 已提交
103
Status
S
starlord 已提交
104
ConnectionImpl::DescribeTable(const std::string& table_name, TableSchema& table_schema) {
K
kun yu 已提交
105 106 107 108
    return client_proxy_->DescribeTable(table_name, table_schema);
}

Status
S
starlord 已提交
109
ConnectionImpl::CountTable(const std::string& table_name, int64_t& row_count) {
Y
Yu Kun 已提交
110
    return client_proxy_->CountTable(table_name, row_count);
K
kun yu 已提交
111 112 113
}

Status
S
starlord 已提交
114
ConnectionImpl::ShowTables(std::vector<std::string>& table_array) {
K
kun yu 已提交
115 116 117
    return client_proxy_->ShowTables(table_array);
}

118 119 120 121 122
Status
ConnectionImpl::ShowTableInfo(const std::string& table_name, TableInfo& table_info) {
    return client_proxy_->ShowTableInfo(table_name, table_info);
}

K
kun yu 已提交
123 124 125 126 127 128 129 130 131 132
std::string
ConnectionImpl::ServerVersion() const {
    return client_proxy_->ServerVersion();
}

std::string
ConnectionImpl::ServerStatus() const {
    return client_proxy_->ServerStatus();
}

Y
Yu Kun 已提交
133
Status
134 135
ConnectionImpl::DeleteByID(const std::string& table_name, const std::vector<int64_t>& id_array) {
    return client_proxy_->DeleteByID(table_name, id_array);
Y
Yu Kun 已提交
136 137 138
}

Status
S
starlord 已提交
139
ConnectionImpl::PreloadTable(const std::string& table_name) const {
Y
Yu Kun 已提交
140
    return client_proxy_->PreloadTable(table_name);
Y
Yu Kun 已提交
141 142
}

143
Status
S
starlord 已提交
144
ConnectionImpl::DescribeIndex(const std::string& table_name, IndexParam& index_param) const {
145
    return client_proxy_->DescribeIndex(table_name, index_param);
Y
Yu Kun 已提交
146 147 148
}

Status
S
starlord 已提交
149
ConnectionImpl::DropIndex(const std::string& table_name) const {
150
    return client_proxy_->DropIndex(table_name);
Y
Yu Kun 已提交
151 152
}

G
groot 已提交
153 154 155 156 157 158
Status
ConnectionImpl::CreatePartition(const PartitionParam& param) {
    return client_proxy_->CreatePartition(param);
}

Status
159
ConnectionImpl::ShowPartitions(const std::string& table_name, PartitionTagList& partition_array) const {
G
groot 已提交
160 161 162 163 164 165 166 167
    return client_proxy_->ShowPartitions(table_name, partition_array);
}

Status
ConnectionImpl::DropPartition(const PartitionParam& param) {
    return client_proxy_->DropPartition(param);
}

168 169 170 171 172 173 174 175 176
Status
ConnectionImpl::GetConfig(const std::string& node_name, std::string& value) const {
    return client_proxy_->GetConfig(node_name, value);
}

Status
ConnectionImpl::SetConfig(const std::string& node_name, const std::string& value) const {
    return client_proxy_->SetConfig(node_name, value);
}
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192

Status
ConnectionImpl::FlushTable(const std::string& Status) {
    return client_proxy_->FlushTable(Status);
}

Status
ConnectionImpl::Flush() {
    return client_proxy_->Flush();
}

Status
ConnectionImpl::CompactTable(const std::string& table_name) {
    return client_proxy_->CompactTable(table_name);
}

S
starlord 已提交
193
}  // namespace milvus