aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/fef/verify_feature.cpp
blob: 438b57902a2771c6493a62ae4fb9def9b57a515d (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "verify_feature.h"
#include "blueprintresolver.h"
#include "blueprintfactory.h"
#include "iindexenvironment.h"
#include <vespa/vespalib/util/stringfmt.h>

using vespalib::make_string_short::fmt;

namespace search::fef {

bool verifyFeature(const BlueprintFactory &factory,
                   const IIndexEnvironment &indexEnv,
                   const std::string &featureName,
                   const std::string &desc,
                   std::vector<Message> & errors)
{
    indexEnv.hintFeatureMotivation(IIndexEnvironment::VERIFY_SETUP);
    BlueprintResolver resolver(factory, indexEnv);
    resolver.addSeed(featureName);
    bool result = resolver.compile();
    if (!result) {
        const BlueprintResolver::Warnings & warnings(resolver.getWarnings());
        for (const auto & msg : warnings) {
            errors.emplace_back(Level::WARNING, msg);
        }
        vespalib::string msg = fmt("verification failed: %s (%s)",BlueprintResolver::describe_feature(featureName).c_str(), desc.c_str());
        errors.emplace_back(Level::ERROR, msg);
    }
    return result;
}

}