aboutsummaryrefslogtreecommitdiffstats
path: root/searchsummary/src/vespa/searchsummary/docsummary/attribute_combiner_dfw.h
blob: 3cfadc3e2c589f8e97f649078f647f12c386e747 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "simple_dfw.h"
#include <memory>

namespace search {
class MatchingElements;
class MatchingElementsFields;
}
namespace search::attribute { class IAttributeContext; }

namespace vespalib { class Stash; }

namespace search::docsummary {

class DocsumFieldWriterState;
class DynamicDocsumWriter;

/*
 * This class reads values from multiple struct field attributes and
 * inserts them as an array of struct or a map of struct.
 */
class AttributeCombinerDFW : public SimpleDFW
{
protected:
    uint32_t _stateIndex;
    const bool _filter_elements;
    vespalib::string _fieldName;
    std::shared_ptr<MatchingElementsFields> _matching_elems_fields;
    AttributeCombinerDFW(const vespalib::string &fieldName, bool filter_elements,
                         std::shared_ptr<MatchingElementsFields> matching_elems_fields);
protected:
    virtual DocsumFieldWriterState* allocFieldWriterState(search::attribute::IAttributeContext &context, vespalib::Stash& stash, const MatchingElements* matching_elements) const = 0;
public:
    ~AttributeCombinerDFW() override;
    bool isGenerated() const override { return true; }
    bool setFieldWriterStateIndex(uint32_t fieldWriterStateIndex) override;
    static std::unique_ptr<DocsumFieldWriter> create(const vespalib::string &fieldName, search::attribute::IAttributeContext &attrCtx,
                                                     bool filter_elements, std::shared_ptr<MatchingElementsFields> matching_elems_fields);
    void insertField(uint32_t docid, GetDocsumsState& state, vespalib::slime::Inserter &target) const override;
};

}