mirror of https://github.com/milvus-io/milvus.git
Add param check for BruteForceSearch in segcore (#20838)
Signed-off-by: yudong.cai <yudong.cai@zilliz.com> Signed-off-by: yudong.cai <yudong.cai@zilliz.com>pull/20908/head
parent
5a6a92d603
commit
4c5ffc832c
|
@ -19,6 +19,18 @@
|
|||
|
||||
namespace milvus::query {
|
||||
|
||||
void
|
||||
CheckBruteForceSearchParam(const FieldMeta& field, const SearchInfo& search_info) {
|
||||
auto data_type = field.get_data_type();
|
||||
auto& metric_type = search_info.metric_type_;
|
||||
|
||||
AssertInfo(datatype_is_vector(data_type), "[BruteForceSearch] Data type isn't vector type");
|
||||
bool is_float_data_type = (data_type == DataType::VECTOR_FLOAT);
|
||||
bool is_float_metric_type =
|
||||
IsMetricType(metric_type, knowhere::metric::IP) || IsMetricType(metric_type, knowhere::metric::L2);
|
||||
AssertInfo(is_float_data_type == is_float_metric_type, "[BruteForceSearch] Data type and metric type mis-match");
|
||||
}
|
||||
|
||||
SubSearchResult
|
||||
BruteForceSearch(const dataset::SearchDataset& dataset,
|
||||
const void* chunk_data_raw,
|
||||
|
|
|
@ -12,11 +12,16 @@
|
|||
#pragma once
|
||||
|
||||
#include "common/BitsetView.h"
|
||||
#include "common/FieldMeta.h"
|
||||
#include "common/QueryInfo.h"
|
||||
#include "query/SubSearchResult.h"
|
||||
#include "query/helper.h"
|
||||
|
||||
namespace milvus::query {
|
||||
|
||||
void
|
||||
CheckBruteForceSearchParam(const FieldMeta& field, const SearchInfo& search_info);
|
||||
|
||||
SubSearchResult
|
||||
BruteForceSearch(const dataset::SearchDataset& dataset,
|
||||
const void* chunk_data_raw,
|
||||
|
|
|
@ -123,6 +123,7 @@ SearchOnGrowing(const segcore::SegmentGrowingImpl& segment,
|
|||
auto size_per_chunk = element_end - element_begin;
|
||||
|
||||
auto sub_view = bitset.subview(element_begin, size_per_chunk);
|
||||
CheckBruteForceSearchParam(field, info);
|
||||
auto sub_qr = BruteForceSearch(search_dataset, chunk_data, size_per_chunk, sub_view);
|
||||
|
||||
// convert chunk uid to segment uid
|
||||
|
|
|
@ -86,7 +86,9 @@ SearchOnSealed(const Schema& schema,
|
|||
auto vec_data = record.get_field_data_base(field_id);
|
||||
AssertInfo(vec_data->num_chunk() == 1, "num chunk not equal to 1 for sealed segment");
|
||||
auto chunk_data = vec_data->get_chunk_data(0);
|
||||
auto sub_qr = query::BruteForceSearch(dataset, chunk_data, row_count, bitset);
|
||||
|
||||
CheckBruteForceSearchParam(field, search_info);
|
||||
auto sub_qr = BruteForceSearch(dataset, chunk_data, row_count, bitset);
|
||||
|
||||
result.distances_ = std::move(sub_qr.mutable_distances());
|
||||
result.seg_offsets_ = std::move(sub_qr.mutable_seg_offsets());
|
||||
|
|
Loading…
Reference in New Issue