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

#include "forcecommitdonetask.h"
#include <vespa/searchcore/proton/documentmetastore/i_document_meta_store.h>
#include <vespa/searchcore/proton/reference/i_pending_gid_to_lid_changes.h>

namespace proton {

ForceCommitDoneTask::ForceCommitDoneTask(IDocumentMetaStore &documentMetaStore, std::unique_ptr<IPendingGidToLidChanges> pending_gid_to_lid_changes)
    : _lidsToReuse(),
      _holdUnblockShrinkLidSpace(false),
      _documentMetaStore(documentMetaStore),
      _pending_gid_to_lid_changes(std::move(pending_gid_to_lid_changes))
{
}

ForceCommitDoneTask::~ForceCommitDoneTask() = default;

void
ForceCommitDoneTask::reuseLids(std::vector<uint32_t> &&lids)
{
    assert(_lidsToReuse.empty());
    _lidsToReuse = std::move(lids);
}

void
ForceCommitDoneTask::run()
{
    if (_pending_gid_to_lid_changes) {
        _pending_gid_to_lid_changes->notify_done();
    }
    if (!_lidsToReuse.empty()) {
        _documentMetaStore.removes_complete(_lidsToReuse);
    }
    if (_holdUnblockShrinkLidSpace) {
        _documentMetaStore.holdUnblockShrinkLidSpace();
    }
}

}  // namespace proton