aboutsummaryrefslogtreecommitdiffstats
path: root/eval/src/tests/ann/find-with-nns.h
blob: dd0f937cc573389a77e327c84305ceb489e61f86 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

TopK find_with_nns(uint32_t sk, NNS_API &nns, uint32_t qid) {
    TopK result;
    const PointVector &qv = generatedQueries[qid];
    vespalib::ConstArrayRef<float> query(qv.v, NUM_DIMS);
    auto rv = nns.topK(result.K, query, sk);
    for (size_t i = 0; i < result.K; ++i) {
        result.hits[i] = Hit(rv[i].docid, rv[i].sq.distance);
    }
    return result;
}