blob: 1fa6c7c391752689673fc091fb5a7c5a44bc67e1 (
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/searchlib/fef/i_ranking_assets_repo.h>
#include <vespa/searchlib/fef/fieldinfo.h>
#include <vespa/searchlib/fef/iindexenvironment.h>
#include <vespa/searchlib/fef/properties.h>
#include <vespa/searchlib/fef/tablemanager.h>
#include <vespa/searchcommon/common/schema.h>
#include <vespa/eval/eval/value_cache/constant_value.h>
namespace proton::matching {
/**
* Index environment implementation for the proton matching pipeline.
**/
class IndexEnvironment : public search::fef::IIndexEnvironment
{
private:
using FieldNameMap = vespalib::hash_map<string, uint32_t>;
search::fef::TableManager _tableManager;
search::fef::Properties _properties;
FieldNameMap _fieldNames;
std::vector<search::fef::FieldInfo> _fields;
mutable FeatureMotivation _motivation;
const search::fef::IRankingAssetsRepo& _rankingAssetsRepo;
uint32_t _distributionKey;
/**
* Extract field information from the given schema and populate
* this index environment.
**/
void extractFields(const search::index::Schema &schema);
void insertField(const search::fef::FieldInfo &field);
public:
/**
* Sets up this index environment based on the given schema and
* properties.
*
* @param distributionKey the distribution key for this node.
* @param schema the index schema
* @param props config
* @param constantValueRepo repo used to access constant values for ranking
* @param rankingExpressions processed config about ranking expressions
* @param onnxModels processed config about onnx models
**/
IndexEnvironment(uint32_t distributionKey,
const search::index::Schema &schema,
search::fef::Properties props,
const search::fef::IRankingAssetsRepo& constantValueRepo);
~IndexEnvironment() override;
const search::fef::Properties &getProperties() const override;
uint32_t getNumFields() const override;
const search::fef::FieldInfo *getField(uint32_t id) const override;
const search::fef::FieldInfo *getFieldByName(const string &name) const override;
const search::fef::ITableManager &getTableManager() const override;
FeatureMotivation getFeatureMotivation() const override;
void hintFeatureMotivation(FeatureMotivation motivation) const override;
void hintFieldAccess(uint32_t fieldId) const override;
void hintAttributeAccess(const string &name) const override;
uint32_t getDistributionKey() const override { return _distributionKey; }
vespalib::eval::ConstantValue::UP getConstantValue(const vespalib::string &name) const override {
return _rankingAssetsRepo.getConstant(name);
}
vespalib::string getRankingExpression(const vespalib::string &name) const override {
return _rankingAssetsRepo.getExpression(name);
}
const search::fef::OnnxModel *getOnnxModel(const vespalib::string &name) const override {
return _rankingAssetsRepo.getOnnxModel(name);
}
};
}
|