mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-11-30 02:48:45 +08:00
Check the offsets of search result (#26383)
Signed-off-by: yah01 <yah2er0ne@outlook.com>
This commit is contained in:
parent
d30a920226
commit
911406c822
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "SegmentInterface.h"
|
#include "SegmentInterface.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
#include "exceptions/EasyAssert.h"
|
||||||
#include "pkVisitor.h"
|
#include "pkVisitor.h"
|
||||||
|
|
||||||
namespace milvus::segcore {
|
namespace milvus::segcore {
|
||||||
@ -86,12 +87,20 @@ ReduceHelper::FilterInvalidSearchResult(SearchResult* search_result) {
|
|||||||
", expected size = " + std::to_string(nq * topK));
|
", expected size = " + std::to_string(nq * topK));
|
||||||
std::vector<int64_t> real_topks(nq, 0);
|
std::vector<int64_t> real_topks(nq, 0);
|
||||||
uint32_t valid_index = 0;
|
uint32_t valid_index = 0;
|
||||||
|
auto segment = static_cast<SegmentInterface*>(search_result->segment_);
|
||||||
auto& offsets = search_result->seg_offsets_;
|
auto& offsets = search_result->seg_offsets_;
|
||||||
auto& distances = search_result->distances_;
|
auto& distances = search_result->distances_;
|
||||||
for (auto i = 0; i < nq; ++i) {
|
for (auto i = 0; i < nq; ++i) {
|
||||||
for (auto j = 0; j < topK; ++j) {
|
for (auto j = 0; j < topK; ++j) {
|
||||||
auto index = i * topK + j;
|
auto index = i * topK + j;
|
||||||
if (offsets[index] != INVALID_SEG_OFFSET) {
|
if (offsets[index] != INVALID_SEG_OFFSET) {
|
||||||
|
AssertInfo(0 <= offsets[index] &&
|
||||||
|
offsets[index] < segment->get_row_count(),
|
||||||
|
fmt::format("invalid offset {}, segment {} with "
|
||||||
|
"rows num {}, data or index corruption",
|
||||||
|
offsets[index],
|
||||||
|
segment->get_segment_id(),
|
||||||
|
segment->get_row_count()));
|
||||||
real_topks[i]++;
|
real_topks[i]++;
|
||||||
offsets[valid_index] = offsets[index];
|
offsets[valid_index] = offsets[index];
|
||||||
distances[valid_index] = distances[index];
|
distances[valid_index] = distances[index];
|
||||||
|
Loading…
Reference in New Issue
Block a user