2020-02-17 23:40:58 +08:00
|
|
|
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
|
2019-09-17 10:51:48 +08:00
|
|
|
//
|
2020-02-17 23:40:58 +08: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 10:51:48 +08:00
|
|
|
//
|
2020-02-17 23:40:58 +08: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 10:51:48 +08:00
|
|
|
|
2019-07-24 19:29:18 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "GrpcClient.h"
|
2019-09-28 10:28:51 +08:00
|
|
|
#include "MilvusApi.h"
|
2019-07-24 19:29:18 +08:00
|
|
|
|
2019-09-27 11:13:26 +08:00
|
|
|
#include <memory>
|
2019-09-28 10:28:51 +08:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2019-09-27 11:13:26 +08:00
|
|
|
|
2019-07-24 19:29:18 +08:00
|
|
|
namespace milvus {
|
|
|
|
|
|
|
|
class ClientProxy : public Connection {
|
2019-09-27 11:13:26 +08:00
|
|
|
public:
|
2019-07-24 19:29:18 +08:00
|
|
|
// Implementations of the Connection interface
|
2019-09-27 11:13:26 +08:00
|
|
|
Status
|
2020-03-08 14:27:16 +08:00
|
|
|
Connect(const ConnectParam& connect_param) override;
|
2019-07-24 19:29:18 +08:00
|
|
|
|
2019-09-27 11:13:26 +08:00
|
|
|
Status
|
2019-09-28 10:28:51 +08:00
|
|
|
Connect(const std::string& uri) override;
|
2019-07-24 19:29:18 +08:00
|
|
|
|
2019-09-27 11:13:26 +08:00
|
|
|
Status
|
2019-07-24 19:29:18 +08:00
|
|
|
Connected() const override;
|
|
|
|
|
2019-09-27 11:13:26 +08:00
|
|
|
Status
|
2019-07-24 19:29:18 +08:00
|
|
|
Disconnect() override;
|
|
|
|
|
2020-03-08 14:27:16 +08:00
|
|
|
std::string
|
|
|
|
ClientVersion() const override;
|
|
|
|
|
|
|
|
std::string
|
|
|
|
ServerVersion() const override;
|
|
|
|
|
|
|
|
std::string
|
|
|
|
ServerStatus() const override;
|
|
|
|
|
|
|
|
Status
|
|
|
|
GetConfig(const std::string& node_name, std::string& value) const override;
|
|
|
|
|
|
|
|
Status
|
|
|
|
SetConfig(const std::string& node_name, const std::string& value) const override;
|
|
|
|
|
2019-09-27 11:13:26 +08:00
|
|
|
Status
|
2020-03-08 14:27:16 +08:00
|
|
|
CreateCollection(const CollectionParam& param) override;
|
2019-07-24 19:29:18 +08:00
|
|
|
|
2019-09-27 11:13:26 +08:00
|
|
|
bool
|
2020-03-08 14:27:16 +08:00
|
|
|
HasCollection(const std::string& collection_name) override;
|
2019-07-24 19:29:18 +08:00
|
|
|
|
2019-09-27 11:13:26 +08:00
|
|
|
Status
|
2020-03-08 14:27:16 +08:00
|
|
|
DropCollection(const std::string& collection_name) override;
|
2019-07-24 19:29:18 +08:00
|
|
|
|
2019-09-27 11:13:26 +08:00
|
|
|
Status
|
2019-09-28 10:28:51 +08:00
|
|
|
CreateIndex(const IndexParam& index_param) override;
|
2019-07-24 19:29:18 +08:00
|
|
|
|
2019-09-27 11:13:26 +08:00
|
|
|
Status
|
2020-03-08 14:27:16 +08:00
|
|
|
Insert(const std::string& collection_name,
|
|
|
|
const std::string& partition_tag,
|
|
|
|
const std::vector<Entity>& entity_array,
|
2019-09-28 10:28:51 +08:00
|
|
|
std::vector<int64_t>& id_array) override;
|
2019-07-24 19:29:18 +08:00
|
|
|
|
2020-02-29 16:11:31 +08:00
|
|
|
Status
|
2020-05-12 09:27:58 +08:00
|
|
|
GetEntityByID(const std::string& collection_name,
|
|
|
|
const std::vector<int64_t>& id_array,
|
|
|
|
std::vector<Entity>& entities_data) override;
|
2020-02-29 16:11:31 +08:00
|
|
|
|
2020-04-25 14:49:32 +08:00
|
|
|
Status
|
2020-05-12 09:27:58 +08:00
|
|
|
ListIDInSegment(const std::string& collection_name, const std::string& segment_name,
|
2020-02-29 16:11:31 +08:00
|
|
|
std::vector<int64_t>& id_array) override;
|
|
|
|
|
2019-09-27 11:13:26 +08:00
|
|
|
Status
|
2020-03-08 14:27:16 +08:00
|
|
|
Search(const std::string& collection_name, const std::vector<std::string>& partition_tag_array,
|
|
|
|
const std::vector<Entity>& entity_array, int64_t topk,
|
|
|
|
const std::string& extra_params, TopKQueryResult& topk_query_result) override;
|
2020-02-29 16:11:31 +08:00
|
|
|
|
2019-09-27 11:13:26 +08:00
|
|
|
Status
|
2020-05-12 09:27:58 +08:00
|
|
|
GetCollectionInfo(const std::string& collection_name, CollectionParam& collection_param) override;
|
2019-07-24 19:29:18 +08:00
|
|
|
|
2019-09-27 11:13:26 +08:00
|
|
|
Status
|
2020-05-12 09:27:58 +08:00
|
|
|
CountEntities(const std::string& collection_name, int64_t& entity_count) override;
|
2019-07-24 19:29:18 +08:00
|
|
|
|
2019-09-27 11:13:26 +08:00
|
|
|
Status
|
2020-05-12 09:27:58 +08:00
|
|
|
ListCollections(std::vector<std::string>& collection_array) override;
|
2019-07-24 19:29:18 +08:00
|
|
|
|
2020-02-29 16:11:31 +08:00
|
|
|
Status
|
2020-05-12 09:27:58 +08:00
|
|
|
GetCollectionStats(const std::string& collection_name, std::string& collection_stats) override;
|
2019-07-24 19:29:18 +08:00
|
|
|
|
2019-09-27 11:13:26 +08:00
|
|
|
Status
|
2020-05-12 09:27:58 +08:00
|
|
|
DeleteEntityByID(const std::string& collection_name, const std::vector<int64_t>& id_array) override;
|
2019-08-13 15:37:16 +08:00
|
|
|
|
2019-09-27 11:13:26 +08:00
|
|
|
Status
|
2020-05-12 09:27:58 +08:00
|
|
|
LoadCollection(const std::string& collection_name) const override;
|
2019-08-13 15:37:16 +08:00
|
|
|
|
2019-09-27 11:13:26 +08:00
|
|
|
Status
|
2020-05-12 09:27:58 +08:00
|
|
|
GetIndexInfo(const std::string& collection_name, IndexParam& index_param) const override;
|
2019-08-13 15:37:16 +08:00
|
|
|
|
2019-09-27 11:13:26 +08:00
|
|
|
Status
|
2020-03-08 14:27:16 +08:00
|
|
|
DropIndex(const std::string& collection_name) const override;
|
2019-08-13 15:37:16 +08:00
|
|
|
|
2019-11-07 16:46:31 +08:00
|
|
|
Status
|
|
|
|
CreatePartition(const PartitionParam& partition_param) override;
|
|
|
|
|
2020-05-12 09:27:58 +08:00
|
|
|
bool
|
|
|
|
HasPartition(const std::string& collection_name, const std::string& partition_tag) const override;
|
2019-11-07 16:46:31 +08:00
|
|
|
|
|
|
|
Status
|
2020-05-12 09:27:58 +08:00
|
|
|
ListPartitions(const std::string& collection_name, PartitionTagList& partition_tag_array) const override;
|
2019-11-07 16:46:31 +08:00
|
|
|
|
2019-12-31 10:47:52 +08:00
|
|
|
Status
|
2020-05-12 09:27:58 +08:00
|
|
|
DropPartition(const PartitionParam& partition_param) override;
|
2020-02-29 16:11:31 +08:00
|
|
|
|
|
|
|
Status
|
2020-05-12 09:27:58 +08:00
|
|
|
Flush(const std::vector<std::string>& collection_name_array) override;
|
2020-02-29 16:11:31 +08:00
|
|
|
|
|
|
|
Status
|
2020-05-12 09:27:58 +08:00
|
|
|
Compact(const std::string& collection_name) override;
|
2020-02-29 16:11:31 +08:00
|
|
|
|
2020-04-16 14:54:12 +08:00
|
|
|
/*******************************New Interface**********************************/
|
|
|
|
|
|
|
|
Status
|
|
|
|
CreateHybridCollection(const HMapping& mapping) override;
|
|
|
|
|
|
|
|
Status
|
|
|
|
InsertEntity(const std::string& collection_name,
|
|
|
|
const std::string& partition_tag,
|
|
|
|
HEntity& entities,
|
|
|
|
std::vector<uint64_t>& id_array) override;
|
|
|
|
|
|
|
|
Status
|
|
|
|
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) override;
|
|
|
|
|
2019-09-27 11:13:26 +08:00
|
|
|
private:
|
2019-12-31 10:47:52 +08:00
|
|
|
std::shared_ptr<::grpc::Channel> channel_;
|
2019-08-07 19:12:56 +08:00
|
|
|
std::shared_ptr<GrpcClient> client_ptr_;
|
2019-07-24 19:29:18 +08:00
|
|
|
bool connected_ = false;
|
|
|
|
};
|
|
|
|
|
2019-09-28 10:28:51 +08:00
|
|
|
} // namespace milvus
|