MCPcopy Create free account
hub / github.com/VectorDB-NTU/RaBitQ-Library / main

Function main

sample/cpp/symqg_querying.cpp:19–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17size_t topk = 10;
18
19int main(int argc, char** argv) {
20 if (argc != 4) {
21 std::cerr << "Usage: " << argv[0] << " <arg1> <arg2> <arg3>\n"
22 << "arg1: path for index \n"
23 << "arg2: path for query file, format .fvecs\n"
24 << "arg3: path for groundtruth file format .ivecs\n";
25 exit(1);
26 }
27
28 char* index_file = argv[1];
29 char* query_file = argv[2];
30 char* gt_file = argv[3];
31
32 data_type query;
33 gt_type gt;
34 rabitqlib::load_vecs<float, data_type>(query_file, query);
35 rabitqlib::load_vecs<uint32_t, gt_type>(gt_file, gt);
36 size_t nq = query.rows();
37 size_t total_count = nq * topk;
38
39 index_type qg;
40 qg.load(index_file);
41
42 rabitqlib::StopW stopw;
43
44 std::vector<std::vector<float>> all_qps(test_round, std::vector<float>(efs.size()));
45 std::vector<std::vector<float>> all_recall(test_round, std::vector<float>(efs.size()));
46
47 for (size_t r = 0; r < test_round; r++) {
48 for (size_t i = 0; i < efs.size(); ++i) {
49 size_t ef = efs[i];
50 size_t total_correct = 0;
51 float total_time = 0;
52 qg.set_ef(ef);
53 std::vector<PID> results(topk);
54 for (size_t z = 0; z < nq; z++) {
55 stopw.reset();
56 qg.search(&query(z, 0), topk, results.data());
57 total_time += stopw.get_elapsed_micro();
58 for (size_t y = 0; y < topk; y++) {
59 for (size_t k = 0; k < topk; k++) {
60 if (gt(z, k) == results[y]) {
61 total_correct++;
62 break;
63 }
64 }
65 }
66 }
67 float qps = static_cast<float>(nq) / (total_time / 1e6F);
68 float recall =
69 static_cast<float>(total_correct) / static_cast<float>(total_count);
70
71 all_qps[r][i] = qps;
72 all_recall[r][i] = recall;
73 }
74 }
75
76 auto avg_qps = rabitqlib::horizontal_avg(all_qps);

Callers

nothing calls this directly

Calls 9

horizontal_avgFunction · 0.85
get_elapsed_microMethod · 0.80
rowsMethod · 0.45
loadMethod · 0.45
sizeMethod · 0.45
set_efMethod · 0.45
resetMethod · 0.45
searchMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected