aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/attribute/attribute_usage_sampler_functor.cpp
blob: 0af77f3e8cf588ade4ac1ff8e6f52fd3a3120b5e (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "attribute_usage_sampler_functor.h"
#include "attribute_usage_sampler_context.h"
#include "attribute_config_inspector.h"
#include <vespa/searchlib/attribute/attributevector.h>

using search::attribute::BasicType;

namespace proton {

AttributeUsageSamplerFunctor::AttributeUsageSamplerFunctor(
        std::shared_ptr<AttributeUsageSamplerContext> samplerContext,
        const std::string &subDbName)
    : _samplerContext(samplerContext),
      _subDbName(subDbName)
{
}

AttributeUsageSamplerFunctor::~AttributeUsageSamplerFunctor() = default;

void
AttributeUsageSamplerFunctor::operator()(const search::attribute::IAttributeVector & iAttributeVector)
{
    // Executed by attribute writer thread
    const auto & attributeVector = dynamic_cast<const search::AttributeVector &>(iAttributeVector);
    search::AddressSpaceUsage usage = attributeVector.getAddressSpaceUsage();
    vespalib::string attributeName = attributeVector.getName();
    _samplerContext->merge(usage, attributeName, _subDbName);
}

}