mirror of https://github.com/milvus-io/milvus.git
remove SearchByID (#2341)
* fix #2264 Signed-off-by: yhmo <yihua.mo@zilliz.com> * typo Signed-off-by: yhmo <yihua.mo@zilliz.com> * fix ut Signed-off-by: yhmo <yihua.mo@zilliz.com> * typo Signed-off-by: yhmo <yihua.mo@zilliz.com> * Remove unnecessary memcpy Signed-off-by: yhmo <yihua.mo@zilliz.com> * remove SearchByID from C++SDK Signed-off-by: yhmo <yihua.mo@zilliz.com>pull/2407/head
parent
299cd9cd94
commit
7f87248611
|
@ -33,7 +33,7 @@ constexpr int64_t TOP_K = 10;
|
|||
constexpr int64_t NPROBE = 32;
|
||||
constexpr int64_t SEARCH_TARGET = BATCH_ENTITY_COUNT / 2; // change this value, result is different
|
||||
constexpr int64_t ADD_ENTITY_LOOP = 5;
|
||||
constexpr milvus::IndexType INDEX_TYPE = milvus::IndexType::IVFSQ8;
|
||||
constexpr milvus::IndexType INDEX_TYPE = milvus::IndexType::IVFFLAT;
|
||||
constexpr int32_t NLIST = 16384;
|
||||
|
||||
void
|
||||
|
@ -195,15 +195,19 @@ ClientTest::SearchEntitiesByID(const std::string& collection_name, int64_t topk,
|
|||
id_array.push_back(pair.first);
|
||||
}
|
||||
|
||||
std::vector<milvus::Entity> entities;
|
||||
milvus::Status stat = conn_->GetEntityByID(collection_name, id_array, entities);
|
||||
std::cout << "GetEntityByID function call status: " << stat.message() << std::endl;
|
||||
|
||||
JSON json_params = {{"nprobe", nprobe}};
|
||||
milvus_sdk::TimeRecorder rc("SearchByID");
|
||||
milvus::Status stat = conn_->SearchByID(collection_name,
|
||||
partition_tags,
|
||||
id_array,
|
||||
topk,
|
||||
json_params.dump(),
|
||||
topk_query_result);
|
||||
std::cout << "SearchByID function call status: " << stat.message() << std::endl;
|
||||
milvus_sdk::TimeRecorder rc("Search");
|
||||
stat = conn_->Search(collection_name,
|
||||
partition_tags,
|
||||
entities,
|
||||
topk,
|
||||
json_params.dump(),
|
||||
topk_query_result);
|
||||
std::cout << "Search function call status: " << stat.message() << std::endl;
|
||||
|
||||
if (topk_query_result.size() != id_array.size()) {
|
||||
std::cout << "ERROR! wrong result for query by id" << std::endl;
|
||||
|
|
|
@ -370,35 +370,6 @@ ClientProxy::Search(const std::string& collection_name, const std::vector<std::s
|
|||
}
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::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) {
|
||||
try {
|
||||
// step 1: convert vectors data
|
||||
::milvus::grpc::SearchByIDParam search_param;
|
||||
ConstructSearchParam(collection_name, partition_tag_array, topk, extra_params, search_param);
|
||||
|
||||
for (auto& id : id_array) {
|
||||
search_param.add_id_array(id);
|
||||
}
|
||||
|
||||
// step 2: search vectors
|
||||
::milvus::grpc::TopKQueryResult grpc_result;
|
||||
Status status = client_ptr_->SearchByID(search_param, grpc_result);
|
||||
if (grpc_result.row_num() == 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
// step 3: convert result array
|
||||
ConstructTopkResult(grpc_result, topk_query_result);
|
||||
|
||||
return status;
|
||||
} catch (std::exception& ex) {
|
||||
return Status(StatusCode::UnknownError, "Failed to search entities: " + std::string(ex.what()));
|
||||
}
|
||||
}
|
||||
|
||||
Status
|
||||
ClientProxy::GetCollectionInfo(const std::string& collection_name, CollectionParam& collection_param) {
|
||||
try {
|
||||
|
|
|
@ -82,11 +82,6 @@ class ClientProxy : public Connection {
|
|||
const std::vector<Entity>& entity_array, int64_t topk,
|
||||
const std::string& extra_params, TopKQueryResult& topk_query_result) override;
|
||||
|
||||
Status
|
||||
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) override;
|
||||
|
||||
Status
|
||||
GetCollectionInfo(const std::string& collection_name, CollectionParam& collection_param) override;
|
||||
|
||||
|
|
|
@ -178,25 +178,6 @@ GrpcClient::Search(const ::milvus::grpc::SearchParam& search_param,
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
Status
|
||||
GrpcClient::SearchByID(const grpc::SearchByIDParam& search_param, ::milvus::grpc::TopKQueryResult& topk_query_result) {
|
||||
::milvus::grpc::TopKQueryResult query_result;
|
||||
ClientContext context;
|
||||
::grpc::Status grpc_status = stub_->SearchByID(&context, search_param, &topk_query_result);
|
||||
|
||||
if (!grpc_status.ok()) {
|
||||
std::cerr << "SearchByID rpc failed!" << std::endl;
|
||||
std::cerr << grpc_status.error_message() << std::endl;
|
||||
return Status(StatusCode::RPCFailed, grpc_status.error_message());
|
||||
}
|
||||
if (topk_query_result.status().error_code() != grpc::SUCCESS) {
|
||||
std::cerr << topk_query_result.status().reason() << std::endl;
|
||||
return Status(StatusCode::ServerFailed, topk_query_result.status().reason());
|
||||
}
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status
|
||||
GrpcClient::GetCollectionInfo(const std::string& collection_name, ::milvus::grpc::CollectionSchema& grpc_schema) {
|
||||
ClientContext context;
|
||||
|
|
|
@ -59,9 +59,6 @@ class GrpcClient {
|
|||
Status
|
||||
Search(const grpc::SearchParam& search_param, ::milvus::grpc::TopKQueryResult& topk_query_result);
|
||||
|
||||
Status
|
||||
SearchByID(const grpc::SearchByIDParam& search_param, ::milvus::grpc::TopKQueryResult& topk_query_result);
|
||||
|
||||
Status
|
||||
GetCollectionInfo(const std::string& collection_name, grpc::CollectionSchema& grpc_schema);
|
||||
|
||||
|
|
|
@ -387,33 +387,6 @@ class Connection {
|
|||
const std::vector<Entity>& entity_array, int64_t topk,
|
||||
const std::string& extra_params, TopKQueryResult& topk_query_result) = 0;
|
||||
|
||||
/**
|
||||
* @brief Search entities in a collection by id
|
||||
*
|
||||
* This method is used to query entity in collection by id.
|
||||
*
|
||||
* @param collection_name, target collection's name.
|
||||
* @param partition_tag_array, target partitions, keep empty if no partition specified.
|
||||
* @param id_array, vectors id array to be queried.
|
||||
* @param topk, how many similarity entities will be returned.
|
||||
* @param extra_params, extra search parameters according to different index type, must be json format.
|
||||
* Note: extra_params is extra parameters list, it must be json format, for example:
|
||||
* For different index type, parameter list is different accordingly
|
||||
* FLAT/IVFLAT/SQ8/IVFPQ: {nprobe: 32}
|
||||
* ///< nprobe range:[1,999999]
|
||||
* NSG: {search_length:100}
|
||||
* ///< search_length range:[10, 300]
|
||||
* HNSW {ef: 64}
|
||||
* ///< ef range:[topk, 4096]
|
||||
* @param topk_query_result, result array.
|
||||
*
|
||||
* @return Indicate if query is successful.
|
||||
*/
|
||||
virtual Status
|
||||
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) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get collection information
|
||||
*
|
||||
|
|
|
@ -127,18 +127,6 @@ ConnectionImpl::Search(const std::string& collection_name, const PartitionTagLis
|
|||
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);
|
||||
}
|
||||
|
||||
Status
|
||||
ConnectionImpl::GetCollectionInfo(const std::string& collection_name, CollectionParam& collection_schema) {
|
||||
return client_proxy_->GetCollectionInfo(collection_name, collection_schema);
|
||||
|
|
|
@ -84,11 +84,6 @@ class ConnectionImpl : public Connection {
|
|||
const std::vector<Entity>& entity_array, int64_t topk,
|
||||
const std::string& extra_params, TopKQueryResult& topk_query_result) override;
|
||||
|
||||
Status
|
||||
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) override;
|
||||
|
||||
Status
|
||||
GetCollectionInfo(const std::string& collection_name, CollectionParam& collection_param) override;
|
||||
|
||||
|
|
Loading…
Reference in New Issue