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

#include "requestcontext.h"
#include <vespa/eval/eval/fast_value.h>
#include <vespa/eval/eval/value_codec.h>
#include <vespa/searchlib/attribute/attributevector.h>
#include <vespa/searchlib/fef/iqueryenvironment.h>
#include <vespa/searchlib/fef/query_value.h>
#include <vespa/vespalib/util/issue.h>

#include <vespa/log/log.h>
LOG_SETUP(".proton.matching.requestcontext");

using vespalib::eval::FastValueBuilderFactory;
using vespalib::Issue;

namespace proton {

using search::attribute::IAttributeVector;

RequestContext::RequestContext(const Doom & doom, IAttributeContext & attributeContext,
                               const search::fef::IQueryEnvironment& query_env,
                               search::fef::IObjectStore& shared_store,
                               const search::attribute::AttributeBlueprintParams& attribute_blueprint_params,
                               const MetaStoreReadGuardSP * metaStoreReadGuard)
    : _doom(doom),
      _attributeContext(attributeContext),
      _query_env(query_env),
      _shared_store(shared_store),
      _attribute_blueprint_params(attribute_blueprint_params),
      _metaStoreReadGuard(metaStoreReadGuard)
{ }

const search::attribute::IAttributeVector *
RequestContext::getAttribute(const vespalib::string &name) const
{
    return _attributeContext.getAttribute(name);
}

const search::attribute::IAttributeVector *
RequestContext::getAttributeStableEnum(const vespalib::string &name) const
{
    return _attributeContext.getAttributeStableEnum(name);
}

void
RequestContext::asyncForAttribute(const vespalib::string &name, std::unique_ptr<IAttributeFunctor> func) const
{
    _attributeContext.asyncForAttribute(name, std::move(func));
}

const vespalib::eval::Value*
RequestContext::get_query_tensor(const vespalib::string& tensor_name) const
{
    try {
        auto value = search::fef::QueryValue::from_config(tensor_name, _query_env.getIndexEnvironment());
        value.prepare_shared_state(_query_env, _shared_store);
        return value.lookup_value(_shared_store);
    } catch (const search::fef::InvalidValueTypeException& ex) {
        Issue::report("Invalid type '%s' for query tensor '%s'",
                      ex.getMessage().c_str(), tensor_name.c_str());
        return nullptr;
    }
}

}