2020-02-17 15:40:58 +00:00
|
|
|
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
|
2019-09-17 02:51:48 +00:00
|
|
|
//
|
2020-02-17 15:40:58 +00:00
|
|
|
// 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
|
2019-09-17 02:51:48 +00:00
|
|
|
//
|
2020-02-17 15:40:58 +00:00
|
|
|
// 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.
|
2019-09-17 02:51:48 +00:00
|
|
|
|
2019-12-20 06:08:45 +00:00
|
|
|
#include "interface/ConnectionImpl.h"
|
2019-07-22 02:14:23 +00:00
|
|
|
|
|
|
|
namespace milvus {
|
|
|
|
|
|
|
|
std::shared_ptr<Connection>
|
|
|
|
Connection::Create() {
|
|
|
|
return std::shared_ptr<Connection>(new ConnectionImpl());
|
|
|
|
}
|
|
|
|
|
|
|
|
Status
|
2019-09-28 02:28:51 +00:00
|
|
|
Connection::Destroy(std::shared_ptr<milvus::Connection>& connection_ptr) {
|
2019-07-24 11:29:18 +00:00
|
|
|
if (connection_ptr != nullptr) {
|
|
|
|
return connection_ptr->Disconnect();
|
|
|
|
}
|
2019-07-22 02:14:23 +00:00
|
|
|
return Status::OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
ConnectionImpl::ConnectionImpl() {
|
|
|
|
client_proxy_ = std::make_shared<ClientProxy>();
|
|
|
|
}
|
|
|
|
|
|
|
|
Status
|
2019-09-28 02:28:51 +00:00
|
|
|
ConnectionImpl::Connect(const ConnectParam& param) {
|
2019-07-22 02:14:23 +00:00
|
|
|
return client_proxy_->Connect(param);
|
|
|
|
}
|
|
|
|
|
|
|
|
Status
|
2019-09-28 02:28:51 +00:00
|
|
|
ConnectionImpl::Connect(const std::string& uri) {
|
2019-07-22 02:14:23 +00:00
|
|
|
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 {
|
2019-08-07 11:12:56 +00:00
|
|
|
return client_proxy_->ClientVersion();
|
2019-07-22 02:14:23 +00:00
|
|
|
}
|
|
|
|
|
2020-03-08 06:27:16 +00:00
|
|
|
std::string
|
|
|
|
ConnectionImpl::ServerVersion() const {
|
|
|
|
return client_proxy_->ServerVersion();
|
2019-07-22 02:14:23 +00:00
|
|
|
}
|
|
|
|
|
2020-03-08 06:27:16 +00:00
|
|
|
std::string
|
|
|
|
ConnectionImpl::ServerStatus() const {
|
|
|
|
return client_proxy_->ServerStatus();
|
2019-07-22 02:14:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Status
|
2020-03-08 06:27:16 +00:00
|
|
|
ConnectionImpl::GetConfig(const std::string& node_name, std::string& value) const {
|
|
|
|
return client_proxy_->GetConfig(node_name, value);
|
2019-07-22 02:14:23 +00:00
|
|
|
}
|
|
|
|
|
2019-07-24 11:29:18 +00:00
|
|
|
Status
|
2020-03-08 06:27:16 +00:00
|
|
|
ConnectionImpl::SetConfig(const std::string& node_name, const std::string& value) const {
|
|
|
|
return client_proxy_->SetConfig(node_name, value);
|
2019-07-22 02:14:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Status
|
2020-03-08 06:27:16 +00:00
|
|
|
ConnectionImpl::CreateCollection(const CollectionParam& param) {
|
|
|
|
return client_proxy_->CreateCollection(param);
|
2019-07-22 02:14:23 +00:00
|
|
|
}
|
|
|
|
|
2020-03-08 06:27:16 +00:00
|
|
|
bool
|
|
|
|
ConnectionImpl::HasCollection(const std::string& collection_name) {
|
|
|
|
return client_proxy_->HasCollection(collection_name);
|
2020-02-29 08:11:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Status
|
2020-03-08 06:27:16 +00:00
|
|
|
ConnectionImpl::DropCollection(const std::string& collection_name) {
|
|
|
|
return client_proxy_->DropCollection(collection_name);
|
2020-02-29 08:11:31 +00:00
|
|
|
}
|
|
|
|
|
2019-07-22 02:14:23 +00:00
|
|
|
Status
|
2020-03-08 06:27:16 +00:00
|
|
|
ConnectionImpl::CreateIndex(const IndexParam& index_param) {
|
|
|
|
return client_proxy_->CreateIndex(index_param);
|
2020-02-29 08:11:31 +00:00
|
|
|
}
|
|
|
|
|
2019-07-22 02:14:23 +00:00
|
|
|
Status
|
2020-03-08 06:27:16 +00:00
|
|
|
ConnectionImpl::Insert(const std::string& collection_name, const std::string& partition_tag,
|
|
|
|
const std::vector<Entity>& entity_array, std::vector<int64_t>& id_array) {
|
|
|
|
return client_proxy_->Insert(collection_name, partition_tag, entity_array, id_array);
|
2019-07-22 02:14:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Status
|
2020-03-08 06:27:16 +00:00
|
|
|
ConnectionImpl::GetEntityByID(const std::string& collection_name, int64_t entity_id, Entity& entity_data) {
|
|
|
|
return client_proxy_->GetEntityByID(collection_name, entity_id, entity_data);
|
2019-07-22 02:14:23 +00:00
|
|
|
}
|
|
|
|
|
2020-04-25 06:49:32 +00:00
|
|
|
Status
|
|
|
|
ConnectionImpl::GetEntitiesByID(const std::string& collection_name,
|
|
|
|
const std::vector<int64_t>& id_array,
|
|
|
|
std::vector<Entity>& entities_data) {
|
|
|
|
return client_proxy_->GetEntitiesByID(collection_name, id_array, entities_data);
|
|
|
|
}
|
|
|
|
|
2019-07-22 02:14:23 +00:00
|
|
|
Status
|
2020-03-08 06:27:16 +00:00
|
|
|
ConnectionImpl::GetIDsInSegment(const std::string& collection_name, const std::string& segment_name,
|
|
|
|
std::vector<int64_t>& id_array) {
|
|
|
|
return client_proxy_->GetIDsInSegment(collection_name, segment_name, id_array);
|
2019-07-22 02:14:23 +00:00
|
|
|
}
|
|
|
|
|
2020-02-29 08:11:31 +00:00
|
|
|
Status
|
2020-04-25 06:49:32 +00:00
|
|
|
ConnectionImpl::Search(const std::string& collection_name, const PartitionTagList& partition_tag_array,
|
2020-03-08 06:27:16 +00:00
|
|
|
const std::vector<Entity>& entity_array, int64_t topk, const std::string& extra_params,
|
|
|
|
TopKQueryResult& topk_query_result) {
|
2020-04-25 06:49:32 +00:00
|
|
|
return client_proxy_->Search(collection_name,
|
|
|
|
partition_tag_array,
|
|
|
|
entity_array,
|
|
|
|
topk,
|
|
|
|
extra_params,
|
|
|
|
topk_query_result);
|
|
|
|
}
|
|
|
|
|
|
|
|
Status
|
|
|
|
ConnectionImpl::SearchByID(const std::string& collection_name, const PartitionTagList& partition_tag_array,
|
|
|
|
const std::vector<int64_t>& id_array, int64_t topk,
|
|
|
|
const std::string& extra_params, TopKQueryResult& topk_query_result) {
|
|
|
|
return client_proxy_->SearchByID(collection_name,
|
|
|
|
partition_tag_array,
|
|
|
|
id_array,
|
|
|
|
topk,
|
|
|
|
extra_params,
|
|
|
|
topk_query_result);
|
2020-02-29 08:11:31 +00:00
|
|
|
}
|
|
|
|
|
2020-03-08 06:27:16 +00:00
|
|
|
Status
|
|
|
|
ConnectionImpl::DescribeCollection(const std::string& collection_name, CollectionParam& collection_schema) {
|
|
|
|
return client_proxy_->DescribeCollection(collection_name, collection_schema);
|
2019-07-22 02:14:23 +00:00
|
|
|
}
|
|
|
|
|
2020-03-08 06:27:16 +00:00
|
|
|
Status
|
|
|
|
ConnectionImpl::CountCollection(const std::string& collection_name, int64_t& row_count) {
|
|
|
|
return client_proxy_->CountCollection(collection_name, row_count);
|
2019-07-22 02:14:23 +00:00
|
|
|
}
|
|
|
|
|
2019-08-13 07:37:16 +00:00
|
|
|
Status
|
2020-03-08 06:27:16 +00:00
|
|
|
ConnectionImpl::ShowCollections(std::vector<std::string>& collection_array) {
|
|
|
|
return client_proxy_->ShowCollections(collection_array);
|
2019-08-13 07:37:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Status
|
2020-04-25 06:49:32 +00:00
|
|
|
ConnectionImpl::ShowCollectionInfo(const std::string& collection_name, std::string& collection_info) {
|
2020-03-08 06:27:16 +00:00
|
|
|
return client_proxy_->ShowCollectionInfo(collection_name, collection_info);
|
2019-08-13 07:37:16 +00:00
|
|
|
}
|
|
|
|
|
2019-08-21 08:53:31 +00:00
|
|
|
Status
|
2020-03-08 06:27:16 +00:00
|
|
|
ConnectionImpl::DeleteByID(const std::string& collection_name, const std::vector<int64_t>& id_array) {
|
|
|
|
return client_proxy_->DeleteByID(collection_name, id_array);
|
2019-08-13 07:37:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Status
|
2020-03-08 06:27:16 +00:00
|
|
|
ConnectionImpl::PreloadCollection(const std::string& collection_name) const {
|
|
|
|
return client_proxy_->PreloadCollection(collection_name);
|
2019-08-13 07:37:16 +00:00
|
|
|
}
|
|
|
|
|
2019-11-07 08:46:31 +00:00
|
|
|
Status
|
2020-03-08 06:27:16 +00:00
|
|
|
ConnectionImpl::DescribeIndex(const std::string& collection_name, IndexParam& index_param) const {
|
|
|
|
return client_proxy_->DescribeIndex(collection_name, index_param);
|
2019-11-07 08:46:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Status
|
2020-03-08 06:27:16 +00:00
|
|
|
ConnectionImpl::DropIndex(const std::string& collection_name) const {
|
|
|
|
return client_proxy_->DropIndex(collection_name);
|
2019-11-07 08:46:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Status
|
2020-03-08 06:27:16 +00:00
|
|
|
ConnectionImpl::CreatePartition(const PartitionParam& partition_param) {
|
|
|
|
return client_proxy_->CreatePartition(partition_param);
|
2019-11-07 08:46:31 +00:00
|
|
|
}
|
|
|
|
|
2019-12-31 02:47:52 +00:00
|
|
|
Status
|
2020-03-08 06:27:16 +00:00
|
|
|
ConnectionImpl::ShowPartitions(const std::string& collection_name, PartitionTagList& partition_array) const {
|
|
|
|
return client_proxy_->ShowPartitions(collection_name, partition_array);
|
2019-12-31 02:47:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Status
|
2020-03-08 06:27:16 +00:00
|
|
|
ConnectionImpl::DropPartition(const PartitionParam& partition_param) {
|
|
|
|
return client_proxy_->DropPartition(partition_param);
|
2019-12-31 02:47:52 +00:00
|
|
|
}
|
2020-02-29 08:11:31 +00:00
|
|
|
|
|
|
|
Status
|
2020-03-08 06:27:16 +00:00
|
|
|
ConnectionImpl::FlushCollection(const std::string& Status) {
|
|
|
|
return client_proxy_->FlushCollection(Status);
|
2020-02-29 08:11:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Status
|
|
|
|
ConnectionImpl::Flush() {
|
|
|
|
return client_proxy_->Flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
Status
|
2020-03-08 06:27:16 +00:00
|
|
|
ConnectionImpl::CompactCollection(const std::string& collection_name) {
|
|
|
|
return client_proxy_->CompactCollection(collection_name);
|
2020-02-29 08:11:31 +00:00
|
|
|
}
|
|
|
|
|
2020-04-16 06:54:12 +00:00
|
|
|
/*******************************New Interface**********************************/
|
|
|
|
|
|
|
|
Status
|
|
|
|
ConnectionImpl::CreateHybridCollection(const HMapping& mapping) {
|
|
|
|
return client_proxy_->CreateHybridCollection(mapping);
|
|
|
|
}
|
|
|
|
|
|
|
|
Status
|
|
|
|
ConnectionImpl::InsertEntity(const std::string& collection_name,
|
|
|
|
const std::string& partition_tag,
|
|
|
|
HEntity& entities,
|
|
|
|
std::vector<uint64_t>& id_array) {
|
|
|
|
return client_proxy_->InsertEntity(collection_name, partition_tag, entities, id_array);
|
|
|
|
}
|
|
|
|
|
|
|
|
Status
|
|
|
|
ConnectionImpl::HybridSearch(const std::string& collection_name,
|
|
|
|
const std::vector<std::string>& partition_list,
|
|
|
|
BooleanQueryPtr& boolean_query,
|
|
|
|
const std::string& extra_params,
|
|
|
|
TopKQueryResult& topk_query_result) {
|
|
|
|
return client_proxy_->HybridSearch(collection_name, partition_list, boolean_query, extra_params, topk_query_result);
|
|
|
|
}
|
|
|
|
|
2019-09-28 02:28:51 +00:00
|
|
|
} // namespace milvus
|