mirror of https://github.com/milvus-io/milvus.git
Improve the assert information (#22578)
Signed-off-by: lixinguo <xinguo.li@zilliz.com> Co-authored-by: lixinguo <xinguo.li@zilliz.com>pull/22588/head
parent
d4fccdd135
commit
c196c55381
|
@ -49,14 +49,18 @@ class ThreadSafeVector {
|
|||
}
|
||||
const Type&
|
||||
operator[](int64_t index) const {
|
||||
Assert(index < size_);
|
||||
AssertInfo(index < size_,
|
||||
fmt::format(
|
||||
"index out of range, index={}, size_={}", index, size_));
|
||||
std::shared_lock lck(mutex_);
|
||||
return vec_[index];
|
||||
}
|
||||
|
||||
Type&
|
||||
operator[](int64_t index) {
|
||||
Assert(index < size_);
|
||||
AssertInfo(index < size_,
|
||||
fmt::format(
|
||||
"index out of range, index={}, size_={}", index, size_));
|
||||
std::shared_lock lck(mutex_);
|
||||
return vec_[index];
|
||||
}
|
||||
|
@ -271,7 +275,8 @@ class ConcurrentVectorImpl : public VectorBase {
|
|||
|
||||
const Type&
|
||||
operator[](ssize_t element_index) const {
|
||||
Assert(Dim == 1);
|
||||
AssertInfo(Dim == 1,
|
||||
fmt::format("The value of Dim is not 1, Dim={}", Dim));
|
||||
auto chunk_id = element_index / size_per_chunk_;
|
||||
auto chunk_offset = element_index % size_per_chunk_;
|
||||
return get_chunk(chunk_id)[chunk_offset];
|
||||
|
@ -353,7 +358,8 @@ class ConcurrentVector<BinaryVector>
|
|||
public:
|
||||
explicit ConcurrentVector(int64_t dim, int64_t size_per_chunk)
|
||||
: binary_dim_(dim), ConcurrentVectorImpl(dim / 8, size_per_chunk) {
|
||||
Assert(dim % 8 == 0);
|
||||
AssertInfo(dim % 8 == 0,
|
||||
fmt::format("dim is not a multiple of 8, dim={}", dim));
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue