aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/reprocessing/document_reprocessing_handler.cpp
blob: 09e6e8c727e78897828fdd61f0980b21715f1f84 (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
48
49
50
51
52
53
54
55
56
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "document_reprocessing_handler.h"

#include <vespa/log/log.h>
LOG_SETUP(".proton.reprocessing.document_reprocessing_handler");

namespace proton {

void
DocumentReprocessingHandler::rewriteVisit(uint32_t lid, const std::shared_ptr<document::Document> &doc)
{
    if (lid == 0 || lid >= _docIdLimit)
        return;
    for (const auto &reader : _readers) {
        reader->handleExisting(lid, doc);
    }
    for (const auto &rewriter : _rewriters) {
        rewriter->handleExisting(lid, doc);
    }
}

DocumentReprocessingHandler::DocumentReprocessingHandler(uint32_t docIdLimit)
    : _readers(),
      _rewriters(),
      _rewriteVisitor(*this),
      _docIdLimit(docIdLimit)
{}

DocumentReprocessingHandler::~DocumentReprocessingHandler() = default;

void
DocumentReprocessingHandler::visit(uint32_t lid, const std::shared_ptr<document::Document> &doc)
{
    if (lid == 0 || lid >= _docIdLimit)
        return;
    for (const auto &reader : _readers) {
        reader->handleExisting(lid, doc);
    }
}

void
DocumentReprocessingHandler::visit(uint32_t lid)
{
    (void) lid;
}

void
DocumentReprocessingHandler::done()
{
    for (const auto &reader : _readers) {
        reader->done();
    }
}

} // namespace proton