aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/server/forcecommitcontext.cpp
blob: 04f9c5529f3ac36203f27b99e0c4900f1bc486f9 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "forcecommitcontext.h"
#include "forcecommitdonetask.h"
#include <vespa/searchcore/proton/common/docid_limit.h>
#include <vespa/searchcore/proton/reference/i_pending_gid_to_lid_changes.h>
#include <cassert>

namespace proton {

ForceCommitContext::ForceCommitContext(vespalib::Executor &executor,
                                       IDocumentMetaStore &documentMetaStore,
                                       PendingLidTrackerBase::Snapshot lidsToCommit,
                                       std::unique_ptr<IPendingGidToLidChanges> pending_gid_to_lid_changes,
                                       std::shared_ptr<IDestructorCallback> onDone)
    : _executor(executor),
      _task(std::make_unique<ForceCommitDoneTask>(documentMetaStore, std::move(pending_gid_to_lid_changes))),
      _committedDocIdLimit(0u),
      _docIdLimit(nullptr),
      _onDone(std::move(onDone)),
      _lidsToCommit(std::move(lidsToCommit))
{
}

ForceCommitContext::~ForceCommitContext()
{
    if (_docIdLimit != nullptr) {
        _docIdLimit->bumpUpLimit(_committedDocIdLimit);
    }
    if (!_task->empty()) {
        vespalib::Executor::Task::UP res = _executor.execute(std::move(_task));
        assert(!res);
    }
}

void
ForceCommitContext::reuseLids(std::vector<uint32_t> &&lids)
{
    _task->reuseLids(std::move(lids));
}

void
ForceCommitContext::holdUnblockShrinkLidSpace()
{
    _task->holdUnblockShrinkLidSpace();
}

void
ForceCommitContext::registerCommittedDocIdLimit(uint32_t committedDocIdLimit, DocIdLimit *docIdLimit)
{
    _committedDocIdLimit = committedDocIdLimit;
    _docIdLimit = docIdLimit;
}

}  // namespace proton