mirror of https://github.com/milvus-io/milvus.git
fix: [2.5] avoid segmentation faults caused by retrieving empty vector datasets (#40546)
issue: #40544 pr: #40545 Signed-off-by: xianliang.li <xianliang.li@zilliz.com>pull/40728/head
parent
b0078ceae3
commit
0dc4b73c81
|
@ -333,6 +333,12 @@ VectorDiskAnnIndex<T>::GetVector(const DatasetPtr dataset) const {
|
|||
PanicInfo(ErrorCode::UnexpectedError,
|
||||
"failed to get vector, index is sparse");
|
||||
}
|
||||
|
||||
// if dataset is empty, return empty vector
|
||||
if (dataset->GetRows() == 0) {
|
||||
return {};
|
||||
}
|
||||
|
||||
auto res = index_.GetVectorByIds(dataset);
|
||||
if (!res.has_value()) {
|
||||
PanicInfo(ErrorCode::UnexpectedError,
|
||||
|
|
|
@ -483,6 +483,11 @@ VectorMemIndex<T>::GetVector(const DatasetPtr dataset) const {
|
|||
"failed to get vector, index is sparse");
|
||||
}
|
||||
|
||||
// if dataset is empty, return empty vector
|
||||
if (dataset->GetRows() == 0) {
|
||||
return {};
|
||||
}
|
||||
|
||||
auto res = index_.GetVectorByIds(dataset);
|
||||
if (!res.has_value()) {
|
||||
PanicInfo(ErrorCode::UnexpectedError,
|
||||
|
|
Loading…
Reference in New Issue