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

#include "feedoperation.h"
#include "lidvectorcontext.h"
#include <map>

namespace proton {

class RemoveDocumentsOperation : public FeedOperation
{
protected:
    using LidsToRemoveMap = std::map<uint32_t, LidVectorContext::SP>;
    LidsToRemoveMap _lidsToRemoveMap;

    RemoveDocumentsOperation(Type type);

    void serializeLidsToRemove(vespalib::nbostream &os) const;
    void deserializeLidsToRemove(vespalib::nbostream &is);
public:
    ~RemoveDocumentsOperation() override { }

    void setLidsToRemove(uint32_t subDbId, const LidVectorContext::SP &lidsToRemove) {
        _lidsToRemoveMap[subDbId] = lidsToRemove;
    }

    bool hasLidsToRemove() const {
        return !_lidsToRemoveMap.empty();
    }

    const LidVectorContext::SP
    getLidsToRemove(uint32_t subDbId) const {
        auto found = _lidsToRemoveMap.find(subDbId);
        return (found != _lidsToRemoveMap.end()) ? found->second : LidVectorContext::SP();
    }

};

} // namespace proton