aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storage/distributor/bucketlistmerger.h
blob: 63f2061c532a3e75cd2fd579fb50ea35733e0012 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <vespa/document/bucket/bucketid.h>
#include <vespa/storageapi/buckets/bucketinfo.h>
#include <vector>

namespace storage::distributor {

/**
   Merges two sorted lists of buckets.

   Creates two lists:
   - One list containing buckets missing from the old list, or that are in both and have different checksums (to get updated bucket information)
   - One list containing buckets missing from the new list (to be deleted).
*/
class BucketListMerger
{
public:
    using BucketEntry = std::pair<document::BucketId, api::BucketInfo>;
    using BucketList = std::vector<BucketEntry>;

    BucketListMerger(const BucketList& newList, const BucketList& oldList, uint64_t timestamp);

    const std::vector<BucketEntry>& getAddedEntries() const { return _addedEntries; }
    const std::vector<document::BucketId>& getRemovedEntries() const { return _removedEntries; }
    uint64_t getTimestamp() const { return _timestamp; }
private:
    std::vector<BucketEntry>        _addedEntries;
    std::vector<document::BucketId> _removedEntries;
    uint64_t                        _timestamp;
};

}