Skip to content

Commit

Permalink
Put the sort in the right place (after all dists done)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnlees committed Mar 16, 2024
1 parent b5c658e commit 90c1ee4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,6 @@ sparse_coo query_db_sparse(std::vector<Reference> &ref_sketches,
row_dist = acc;
}
}
if (min_dists.size() < kNN || row_dist < min_dists.top().dist()) {
min_dists.push(SparseDist(row_dist, j));
if (min_dists.size() > kNN) {
min_dists.pop();
}
}
}
if ((i * ref_sketches.size() + j) % update_every == 0) {
#pragma omp critical
Expand All @@ -403,6 +397,14 @@ sparse_coo query_db_sparse(std::vector<Reference> &ref_sketches,
}
}
}

if (min_dists.size() < kNN || row_dist < min_dists.top().dist()) {
min_dists.push(SparseDist(row_dist, j));
if (min_dists.size() > kNN) {
min_dists.pop();
}
}

long offset = i * kNN;
std::fill_n(i_vec.begin() + offset, kNN, i);
for (int k = 0; k < kNN; ++k) {
Expand Down

0 comments on commit 90c1ee4

Please sign in to comment.