blob: ba91cb2aebcee6e3e01ce64a54673adb0753e3e4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
struct TopK {
static constexpr size_t K = 100;
Hit hits[K];
size_t recall(const TopK &other) {
size_t overlap = 0;
size_t i = 0;
size_t j = 0;
while (i < K && j < K) {
if (hits[i].docid == other.hits[j].docid) {
++overlap;
++i;
++j;
} else if (hits[i].distance < other.hits[j].distance) {
++i;
} else {
++j;
}
}
return overlap;
}
};
|