aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/expression/attribute_map_lookup_node.h
blob: 8b8fb4fac87f22d66f3e22b78f7add8bf7394c1f (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include "attributenode.h"

namespace search::expression {

/**
 * Extract map value from attribute for the map key specified in the
 * grouping expression.
 */
class AttributeMapLookupNode : public AttributeNode
{
public:
    using IAttributeVector = search::attribute::IAttributeVector;
    class KeyHandler;
private:
    vespalib::string        _keyAttributeName;
    vespalib::string        _valueAttributeName;
    vespalib::string        _key;
    vespalib::string        _keySourceAttributeName;
    const IAttributeVector *_keyAttribute;
    const IAttributeVector *_keySourceAttribute;

    std::unique_ptr<KeyHandler> makeKeyHandlerHelper() const;
    std::unique_ptr<KeyHandler> makeKeyHandler() const;
    void cleanup() override;
    void wireAttributes(const search::attribute::IAttributeContext & attrCtx) override;
    std::pair<std::unique_ptr<ResultNode>, std::unique_ptr<Handler>>
    createResultHandler(bool preserveAccurateType, const attribute::IAttributeVector & attribute) const override;
public:
    DECLARE_NBO_SERIALIZE;
    DECLARE_EXPRESSIONNODE(AttributeMapLookupNode);
    AttributeMapLookupNode();
    AttributeMapLookupNode(vespalib::stringref name, vespalib::stringref keyAttributeName, vespalib::stringref valueAttributeName, vespalib::stringref key, vespalib::stringref keySourceAttributeName);
    AttributeMapLookupNode(const AttributeMapLookupNode &);
    AttributeMapLookupNode(AttributeMapLookupNode &&) = delete;
    ~AttributeMapLookupNode() override;
    AttributeMapLookupNode &operator=(const AttributeMapLookupNode &rhs);
    AttributeMapLookupNode &operator=(AttributeMapLookupNode &&rhs) = delete;
    void visitMembers(vespalib::ObjectVisitor &visitor) const override;
};

}