ConnectionImpl.cpp 4.7 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.

S
starlord 已提交
18
#include "sdk/interface/ConnectionImpl.h"
K
kun yu 已提交
19 20 21 22 23 24 25 26 27

namespace milvus {

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

Status
S
starlord 已提交
28
Connection::Destroy(std::shared_ptr<milvus::Connection>& connection_ptr) {
K
kun yu 已提交
29 30 31
    if (connection_ptr != nullptr) {
        return connection_ptr->Disconnect();
    }
K
kun yu 已提交
32 33 34 35 36 37 38 39 40
    return Status::OK();
}

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

Status
S
starlord 已提交
41
ConnectionImpl::Connect(const ConnectParam& param) {
K
kun yu 已提交
42 43 44 45
    return client_proxy_->Connect(param);
}

Status
S
starlord 已提交
46
ConnectionImpl::Connect(const std::string& uri) {
K
kun yu 已提交
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
    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 已提交
62
    return client_proxy_->ClientVersion();
K
kun yu 已提交
63 64 65
}

Status
S
starlord 已提交
66
ConnectionImpl::CreateTable(const TableSchema& param) {
K
kun yu 已提交
67 68 69 70
    return client_proxy_->CreateTable(param);
}

bool
S
starlord 已提交
71
ConnectionImpl::HasTable(const std::string& table_name) {
K
kun yu 已提交
72 73 74 75
    return client_proxy_->HasTable(table_name);
}

Status
S
starlord 已提交
76
ConnectionImpl::DropTable(const std::string& table_name) {
K
kun yu 已提交
77 78 79
    return client_proxy_->DropTable(table_name);
}

K
kun yu 已提交
80
Status
S
starlord 已提交
81
ConnectionImpl::CreateIndex(const IndexParam& index_param) {
Y
Yu Kun 已提交
82
    return client_proxy_->CreateIndex(index_param);
K
kun yu 已提交
83 84 85
}

Status
G
groot 已提交
86 87 88
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 已提交
89 90 91
}

Status
G
groot 已提交
92 93 94 95
ConnectionImpl::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) {
    return client_proxy_->Search(table_name, partiton_tags, query_record_array, query_range_array, topk, nprobe,
S
starlord 已提交
96
                                 topk_query_result_array);
K
kun yu 已提交
97 98 99
}

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

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

Status
S
starlord 已提交
110
ConnectionImpl::ShowTables(std::vector<std::string>& table_array) {
K
kun yu 已提交
111 112 113 114 115 116 117 118 119 120 121 122 123
    return client_proxy_->ShowTables(table_array);
}

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

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

Y
Yu Kun 已提交
124 125 126 127 128
std::string
ConnectionImpl::DumpTaskTables() const {
    return client_proxy_->DumpTaskTables();
}

Y
Yu Kun 已提交
129
Status
G
groot 已提交
130 131
ConnectionImpl::DeleteByDate(const std::string& table_name, const Range& range) {
    return client_proxy_->DeleteByDate(table_name, range);
Y
Yu Kun 已提交
132 133 134
}

Status
S
starlord 已提交
135
ConnectionImpl::PreloadTable(const std::string& table_name) const {
Y
Yu Kun 已提交
136
    return client_proxy_->PreloadTable(table_name);
Y
Yu Kun 已提交
137 138
}

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

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

G
groot 已提交
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
Status
ConnectionImpl::CreatePartition(const PartitionParam& param) {
    return client_proxy_->CreatePartition(param);
}

Status
ConnectionImpl::ShowPartitions(const std::string& table_name, PartitionList& partition_array) const {
    return client_proxy_->ShowPartitions(table_name, partition_array);
}

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

S
starlord 已提交
164
}  // namespace milvus