aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/server/maintenancedocumentsubdb.cpp
blob: 314b41055490ad6772b39b5cf14da41e1b499faa (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "maintenancedocumentsubdb.h"
#include <vespa/searchcore/proton/common/ipendinglidtracker.h>

namespace proton {

MaintenanceDocumentSubDB::MaintenanceDocumentSubDB()
    : _name(""),
      _sub_db_id(0),
      _meta_store(nullptr),
      _retriever(nullptr),
      _feed_view(nullptr)
{
}

MaintenanceDocumentSubDB::~MaintenanceDocumentSubDB() = default;

MaintenanceDocumentSubDB::MaintenanceDocumentSubDB(const vespalib::string& name,
                                                   uint32_t sub_db_id,
                                                   IDocumentMetaStore::SP meta_store,
                                                   IDocumentRetriever::SP retriever,
                                                   IFeedView::SP feed_view,
                                                   const ILidCommitState  * pendingLidsForCommit)
    : _name(name),
      _sub_db_id(sub_db_id),
      _meta_store(std::move(meta_store)),
      _retriever(std::move(retriever)),
      _feed_view(std::move(feed_view)),
      _pendingLidsForCommit(pendingLidsForCommit)
{
}

void
MaintenanceDocumentSubDB::clear()
{
    _name = "";
    _sub_db_id = 0;
    _meta_store.reset();
    _retriever.reset();
    _feed_view.reset();
    _pendingLidsForCommit = nullptr;
}

bool
MaintenanceDocumentSubDB::lidNeedsCommit(search::DocumentIdT lid) const {
    return ((_pendingLidsForCommit != nullptr) &&
            (_pendingLidsForCommit->getState(lid) != ILidCommitState::State::COMPLETED));
}

}