aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/attribute/document_field_populator.h
blob: ef6e3de97f229619e3f986e859df51a467db5b62 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/searchcore/proton/reprocessing/i_reprocessing_rewriter.h>
#include <vespa/searchlib/attribute/attributeguard.h>

namespace proton {

/**
 * Class used to populate a document field based on the content from an attribute vector.
 */
class DocumentFieldPopulator : public IReprocessingRewriter
{
private:
    using AttributeVectorSP = std::shared_ptr<search::AttributeVector>;
    vespalib::string  _fieldName;
    AttributeVectorSP _attr;
    vespalib::string  _subDbName;
    int64_t           _documentsPopulated;

public:
    DocumentFieldPopulator(const vespalib::string &fieldName,
                           AttributeVectorSP attr,
                           const vespalib::string &subDbName);

    ~DocumentFieldPopulator() override;

    const search::AttributeVector &getAttribute() const {
        return *_attr;
    }

    void handleExisting(uint32_t lid, const std::shared_ptr<document::Document> &doc) override;
};

} // namespace proton