aboutsummaryrefslogtreecommitdiffstats
path: root/streamingvisitors/src/vespa/searchvisitor/attribute_access_recorder.h
blob: d3a765af32b44a3eb2b1544990a8ad84a256ece5 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/searchcommon/attribute/iattributecontext.h>
#include <vespa/vespalib/stllike/hash_set.h>

namespace streaming {

/*
 * This class wraps an IAttributeContext and records accesses to attribute
 * vectors.
 */
class AttributeAccessRecorder : public search::attribute::IAttributeContext
{
    std::unique_ptr<search::attribute::IAttributeContext> _ctx;
    mutable vespalib::hash_set<vespalib::string> _accessed_attributes;

public:
    AttributeAccessRecorder(std::unique_ptr<IAttributeContext> ctx);
    ~AttributeAccessRecorder() override;
    void asyncForAttribute(const vespalib::string& name, std::unique_ptr<search::attribute::IAttributeFunctor> func) const override;
    const search::attribute::IAttributeVector* getAttribute(const string& name) const override;
    const search::attribute::IAttributeVector * getAttributeStableEnum(const string& name) const override;
    void getAttributeList(std::vector<const search::attribute::IAttributeVector *>& list) const override;
    void releaseEnumGuards() override;
    std::vector<vespalib::string> get_accessed_attributes() const;
};

}