blob: 9277a4c2670818e7936b97ce9eee147d7b5c0cd6 (
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
27
28
29
30
31
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "matching_elements.h"
#include <algorithm>
namespace search {
MatchingElements::MatchingElements() = default;
MatchingElements::~MatchingElements() = default;
void
MatchingElements::add_matching_elements(uint32_t docid, const vespalib::string &field_name, const std::vector<uint32_t> &elements)
{
auto &list = _map[key_t(docid, field_name)];
std::vector<uint32_t> new_list;
std::set_union(list.begin(), list.end(), elements.begin(), elements.end(), std::back_inserter(new_list));
list = std::move(new_list);
}
const std::vector<uint32_t> &
MatchingElements::get_matching_elements(uint32_t docid, const vespalib::string &field_name) const
{
static const std::vector<uint32_t> empty;
auto res = _map.find(key_t(docid, field_name));
if (res == _map.end()) {
return empty;
}
return res->second;
}
} // namespace search
|