aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/reprocessing/reprocess_documents_task.h
blob: 002a09a182de4427b02d9536011b2c37d5877e29 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include "i_reprocessing_task.h"
#include <vespa/searchcore/proton/docsummary/isummarymanager.h>
#include <vespa/searchcore/proton/attribute/i_attribute_manager.h>
#include "attribute_reprocessing_initializer.h"
#include "document_reprocessing_handler.h"
#include "i_reprocessing_initializer.h"

namespace proton
{

/**
 * The reprocessing documents task handles reprocessing of documents,
 * e.g. populate attributes from document store when adding attribute
 * aspect on existing field and populating documents in document store
 * when removing attribute aspect on existing field.
 */
class ReprocessDocumentsTask : public IReprocessingTask,
                               public search::IDocumentStoreVisitorProgress
{
    using clock = std::chrono::steady_clock;
    proton::ISummaryManager::SP          _sm;
    std::shared_ptr<const document::DocumentTypeRepo>       _docTypeRepo;
    vespalib::string                     _subDbName;
    double                               _visitorProgress;
    double                               _visitorCost;
    DocumentReprocessingHandler          _handler;
    clock::time_point                    _start;
    clock::time_point                    _lastLogTime;
    double                               _loggedProgress;

public:
    ReprocessDocumentsTask(IReprocessingInitializer &initializer,
                           const proton::ISummaryManager::SP &sm,
                           const std::shared_ptr<const document::DocumentTypeRepo> &docTypeRepo,
                           const vespalib::string &subDbName,
                           uint32_t docIdLimit);

    void run() override;
    void updateProgress(double progress) override;
    Progress getProgress() const override;
};

} // namespace proton