From 027e452ea0da50958525218a74d51558b36193c3 Mon Sep 17 00:00:00 2001 From: Wei-Cheng Chang Date: Wed, 27 Jul 2022 16:02:22 -0700 Subject: [PATCH] Fix HNSW returned index array overflow issue (#156) Co-authored-by: Wei-Cheng Chang --- pecos/core/libpecos.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pecos/core/libpecos.cpp b/pecos/core/libpecos.cpp index 913cb13..912d96e 100644 --- a/pecos/core/libpecos.cpp +++ b/pecos/core/libpecos.cpp @@ -453,8 +453,9 @@ extern "C" { int thread_id = omp_get_thread_num(); \ auto& ret_pairs = searchers[thread_id].predict_single(feat_mat.get_row(qid), efS, topk); \ for (uint32_t k=0; k < ret_pairs.size(); k++) { \ - ret_val[qid * topk + k] = ret_pairs[k].dist; \ - ret_idx[qid * topk + k] = ret_pairs[k].node_id; \ + uint64_t offset = static_cast(qid) * topk; \ + ret_val[offset + k] = ret_pairs[k].dist; \ + ret_idx[offset + k] = ret_pairs[k].node_id; \ } \ } \ }