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

#include "tensor_factory_blueprint.h"
#include <vespa/eval/eval/function.h>

#include <vespa/log/log.h>
LOG_SETUP(".features.tensor_factory_blueprint");

using namespace search::fef;
using vespalib::eval::Function;

namespace search {
namespace features {

vespalib::string TensorFactoryBlueprint::ATTRIBUTE_SOURCE = "attribute";
vespalib::string TensorFactoryBlueprint::QUERY_SOURCE = "query";

bool
TensorFactoryBlueprint::extractSource(const vespalib::string &source)
{
    vespalib::string error;
    bool unwrapOk = Function::unwrap(source, _sourceType, _sourceParam, error);
    if (!unwrapOk) {
        LOG(error, "Failed to extract source param: '%s'", error.c_str());
        return false;
    }
    if (_sourceType != ATTRIBUTE_SOURCE && _sourceType != QUERY_SOURCE) {
        LOG(error, "Expected source type '%s' or '%s', but it was '%s'",
                ATTRIBUTE_SOURCE.c_str(), QUERY_SOURCE.c_str(), _sourceType.c_str());
        return false;
    }
    return true;
}

TensorFactoryBlueprint::TensorFactoryBlueprint(const vespalib::string &baseName)
    : Blueprint(baseName),
      _sourceType(),
      _sourceParam(),
      _dimension("0"), // default dimension is set to the source param if not specified.
      _valueType(vespalib::eval::ValueType::error_type())
{
}

TensorFactoryBlueprint::~TensorFactoryBlueprint() {}

} // namespace features
} // namespace search