blob: 55e7a9bfbb4a7f5265d4940fd0914284c16828e6 (
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "attribute_access_recorder.h"
#include <vespa/vespalib/stllike/hash_set.hpp>
using search::attribute::IAttributeVector;
namespace streaming {
AttributeAccessRecorder::AttributeAccessRecorder(std::unique_ptr<IAttributeContext> ctx)
: _ctx(std::move(ctx)),
_accessed_attributes()
{
}
AttributeAccessRecorder::~AttributeAccessRecorder() = default;
void
AttributeAccessRecorder::asyncForAttribute(const vespalib::string& name, std::unique_ptr<search::attribute::IAttributeFunctor> func) const
{
_ctx->asyncForAttribute(name, std::move(func));
}
const IAttributeVector*
AttributeAccessRecorder::getAttribute(const string& name) const
{
auto ret = _ctx->getAttribute(name);
if (ret != nullptr) {
_accessed_attributes.insert(name);
}
return ret;
}
const IAttributeVector*
AttributeAccessRecorder::getAttributeStableEnum(const string& name) const
{
auto ret = _ctx->getAttributeStableEnum(name);
if (ret != nullptr) {
_accessed_attributes.insert(name);
}
return ret;
}
void
AttributeAccessRecorder::getAttributeList(std::vector<const IAttributeVector*>& list) const
{
_ctx->getAttributeList(list);
}
void
AttributeAccessRecorder::releaseEnumGuards()
{
_ctx->releaseEnumGuards();
}
std::vector<vespalib::string>
AttributeAccessRecorder::get_accessed_attributes() const
{
std::vector<vespalib::string> result;
result.reserve(_accessed_attributes.size());
for (auto& attr : _accessed_attributes) {
result.emplace_back(attr);
}
return result;
}
}
|