aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdbhandler.h
blob: f4cd23ef712de61ff89da1da67a19d0bc72dd742 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "ibucketdbhandler.h"
#include "ibucketdbhandlerinitializer.h"
#include "bucket_create_notifier.h"

namespace proton::bucketdb {

class BucketDBOwner;

/**
 * The BucketDBHandler class handles operations on a bucket db.
 */
class BucketDBHandler : public IBucketDBHandler,
                        public IBucketDBHandlerInitializer
{
private:
    struct MetaStoreDesc
    {
        IDocumentMetaStore *_dms;
        search::SerialNum   _flushedSerialNum;

        MetaStoreDesc(IDocumentMetaStore *dms,
                      search::SerialNum flushedSerialNum)
            : _dms(dms),
              _flushedSerialNum(flushedSerialNum)
        {
        }
    };

    BucketDBOwner             &_bucketDB;
    std::vector<MetaStoreDesc> _dmsv;
    BucketCreateNotifier       _bucketCreateNotifier;

public:
    explicit BucketDBHandler(BucketDBOwner &bucketDB);
    ~BucketDBHandler() override;

    void addDocumentMetaStore(IDocumentMetaStore *dms, search::SerialNum flushedSerialNum) override;
    void handleSplit(search::SerialNum serialNum, const BucketId &source,
                     const BucketId &target1, const BucketId &target2) override;
    void handleJoin(search::SerialNum serialNum, const BucketId &source1,
                    const BucketId &source2, const BucketId &target) override;
    void handleCreateBucket(const BucketId &bucketId) override;
    void handleDeleteBucket(const BucketId &bucketId) override;

    IBucketCreateNotifier &getBucketCreateNotifier() { return _bucketCreateNotifier; }
};

}