Refine the information while assertion failed (#22434)

Signed-off-by: yah01 <yang.cen@zilliz.com>
This commit is contained in:
yah01 2023-03-02 09:07:48 +08:00 committed by GitHub
parent 74d158e149
commit 1ee10f3224
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 11 deletions

View File

@ -16,10 +16,13 @@
#pragma once
#include <deque>
#include <fmt/core.h>
#include <boost_ext/dynamic_bitset_ext.hpp>
#include "exceptions/EasyAssert.h"
#include <deque>
#include "common/Types.h"
#include "exceptions/EasyAssert.h"
#include "knowhere/bitsetview.h"
namespace milvus {
@ -52,9 +55,8 @@ class BitsetView : public knowhere::BitsetView {
}
AssertInfo((offset & 0x7) == 0, "offset is not divisible by 8");
AssertInfo((offset + size) <= this->size(), "offset + size cross the border.[offset=" + std::to_string(offset) +
"][size=" + std::to_string(size) +
"][this.size()=" + std::to_string(this->size()) + "]");
AssertInfo(offset + size <= this->size(),
fmt::format("index out of range, offset={}, size={}, bitset.size={}", offset, size, this->size()));
return {data() + (offset >> 3), size};
}
};

View File

@ -11,6 +11,7 @@
#pragma once
#include <fmt/core.h>
#include <tbb/concurrent_vector.h>
#include <atomic>
@ -284,8 +285,9 @@ class ConcurrentVectorImpl : public VectorBase {
if (element_count <= 0) {
return;
}
auto chunk_max_size = chunks_.size();
AssertInfo(chunk_id < chunk_max_size, "chunk_id=" + std::to_string(chunk_id));
auto chunk_num = chunks_.size();
AssertInfo(chunk_id < chunk_num,
fmt::format("chunk_id out of chunk num, chunk_id={}, chunk_num={}", chunk_id, chunk_num));
Chunk& chunk = chunks_[chunk_id];
auto ptr = chunk.data();
std::copy_n(source + source_offset * Dim, element_count * Dim, ptr + chunk_offset * Dim);

View File

@ -155,10 +155,9 @@ SegmentSealedImpl::LoadFieldData(const LoadFieldDataInfo& info) {
AssertInfo(info.field_data != nullptr, "Field info blob is null");
auto size = info.row_count;
if (row_count_opt_.has_value()) {
AssertInfo(row_count_opt_.value() == size, "field (" + std::to_string(field_id.get()) +
") data has different row count (" + std::to_string(size) +
") than other column's row count (" +
std::to_string(row_count_opt_.value()) + ")");
AssertInfo(row_count_opt_.value() == size,
fmt::format("field {} has different row count {} to other column's {}", field_id.get(), size,
row_count_opt_.value()));
}
if (SystemProperty::Instance().IsSystem(field_id)) {