Add more error messages in segcore (#8012)

Signed-off-by: fishpenguin <kun.yu@zilliz.com>
pull/8035/head
yukun 2021-09-16 10:23:53 +08:00 committed by GitHub
parent 8ee55aad0a
commit 8b3893e030
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 11 deletions

View File

@ -19,13 +19,13 @@
namespace milvus::segcore {
void
VectorFieldIndexing::BuildIndexRange(int64_t ack_beg, int64_t ack_end, const VectorBase* vec_base) {
assert(field_meta_.get_data_type() == DataType::VECTOR_FLOAT);
AssertInfo(field_meta_.get_data_type() == DataType::VECTOR_FLOAT, "Data type of vector field is not VECTOR_FLOAT");
auto dim = field_meta_.get_dim();
auto source = dynamic_cast<const ConcurrentVector<FloatVector>*>(vec_base);
Assert(source);
AssertInfo(source, "vec_base can't cast to ConcurrentVector type");
auto num_chunk = source->num_chunk();
assert(ack_end <= num_chunk);
AssertInfo(ack_end <= num_chunk, "ack_end is bigger than num_chunk");
auto conf = get_build_params();
data_.grow_to_at_least(ack_end);
for (int chunk_id = ack_beg; chunk_id < ack_end; chunk_id++) {
@ -43,13 +43,13 @@ knowhere::Config
VectorFieldIndexing::get_build_params() const {
// TODO
auto type_opt = field_meta_.get_metric_type();
Assert(type_opt.has_value());
AssertInfo(type_opt.has_value(), "Metric type of field meta doesn't have value");
auto metric_type = type_opt.value();
auto type_name = MetricTypeToName(metric_type);
auto& config = segcore_config_.at(metric_type);
auto base_params = config.build_params;
Assert(base_params.count("nlist"));
AssertInfo(base_params.count("nlist"), "Can't get nlist from index params");
base_params[knowhere::meta::DIM] = field_meta_.get_dim();
base_params[knowhere::Metric::TYPE] = type_name;
@ -60,13 +60,13 @@ knowhere::Config
VectorFieldIndexing::get_search_params(int top_K) const {
// TODO
auto type_opt = field_meta_.get_metric_type();
Assert(type_opt.has_value());
AssertInfo(type_opt.has_value(), "Metric type of field meta doesn't have value");
auto metric_type = type_opt.value();
auto type_name = MetricTypeToName(metric_type);
auto& config = segcore_config_.at(metric_type);
auto base_params = config.search_params;
Assert(base_params.count("nprobe"));
AssertInfo(base_params.count("nprobe"), "Can't get nprobe from base params");
base_params[knowhere::meta::TOPK] = top_K;
base_params[knowhere::Metric::TYPE] = type_name;
@ -100,9 +100,9 @@ template <typename T>
void
ScalarFieldIndexing<T>::BuildIndexRange(int64_t ack_beg, int64_t ack_end, const VectorBase* vec_base) {
auto source = dynamic_cast<const ConcurrentVector<T>*>(vec_base);
Assert(source);
AssertInfo(source, "vec_base can't cast to ConcurrentVector type");
auto num_chunk = source->num_chunk();
assert(ack_end <= num_chunk);
AssertInfo(ack_end <= num_chunk, "Ack_end is bigger than num_chunk");
data_.grow_to_at_least(ack_end);
for (int chunk_id = ack_beg; chunk_id < ack_end; chunk_id++) {
const auto& chunk = source->get_chunk(chunk_id);

View File

@ -17,7 +17,7 @@ ScalarIndexVector::do_search_ids(const IdArray& ids) const {
auto res_ids = std::make_unique<IdArray>();
// TODO: support string array
static_assert(std::is_same_v<T, int64_t>);
Assert(ids.has_int_id());
AssertInfo(ids.has_int_id(), "ids doesn't have int_id field");
auto src_ids = ids.int_id();
auto dst_ids = res_ids->mutable_int_id();
std::vector<SegOffset> dst_offsets;
@ -39,7 +39,7 @@ ScalarIndexVector::do_search_ids(const IdArray& ids) const {
}
// TODO: for repeated key, decide the final offset with Timestamp
// no repeated key, simplified logic
Assert(iter_beg + 1 == iter_end);
AssertInfo(iter_beg + 1 == iter_end, "There are no repeated keys in more than one results");
auto [entry_id, entry_offset] = *iter_beg;
dst_ids->add_data(entry_id);