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

#pragma once

#include <vespa/searchlib/fef/blueprint.h>

namespace search::features {

/**
 * Feature for the specific replacement of the expression:
 *
 *      reduce(
 *          join(
 *              tensorFromLabels(attribute(A)),
 *              tensorFromWeightedset(query(Q)),
 *              f(x,y)(x*y)
 *          ),
 *          max
 *      )
 *
 * where A is an array attribute of int or long type and Q is a query that parses as
 * a weighted set. This expression is replaced with this feature to avoid incurring
 * the cost of creating temporary tensors.
 */
class InternalMaxReduceProdJoinBlueprint : public fef::Blueprint {
private:
    vespalib::string _attribute;
    vespalib::string _queryVector;
    vespalib::string _attrKey;
    vespalib::string _queryVectorKey;

public:
    InternalMaxReduceProdJoinBlueprint();
    ~InternalMaxReduceProdJoinBlueprint() override;

    fef::ParameterDescriptions getDescriptions() const override;
    fef::Blueprint::UP createInstance() const override;
    bool setup(const fef::IIndexEnvironment &env, const fef::ParameterList &params) override;
    void prepareSharedState(const fef::IQueryEnvironment & queryEnv, fef::IObjectStore & objectStore) const override;
    fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override;
    void visitDumpFeatures(const fef::IIndexEnvironment &env, fef::IDumpFeatureVisitor &visitor) const override;

};

}