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

#pragma once

#include <vespa/searchcore/proton/documentmetastore/i_document_meta_store_context.h>

namespace proton {

class DocumentSubDBCollection;

/**
 * Class that takes and owns read guards of the document meta stores of the 3 sub databases.
 * Provides stats regarding the number of documents in the sub databases.
 */
struct DocumentMetaStoreReadGuards
{
    IDocumentMetaStoreContext::IReadGuard::SP readydms;
    IDocumentMetaStoreContext::IReadGuard::SP notreadydms;
    IDocumentMetaStoreContext::IReadGuard::SP remdms;

    DocumentMetaStoreReadGuards(const DocumentSubDBCollection &subDBs);
    ~DocumentMetaStoreReadGuards();

    uint32_t numActiveDocs() const {
        return readydms ? readydms->get().getNumActiveLids() : 0;
    }
    uint32_t numReadyDocs() const {
        return readydms ? readydms->get().getNumUsedLids() : 0;
    }
    uint32_t numTotalDocs() const {
        return numReadyDocs() + (notreadydms ? notreadydms->get().getNumUsedLids() : 0);
    }
    uint32_t numRemovedDocs() const {
        return remdms ? remdms->get().getNumUsedLids() : 0;
    }
};

} // namespace proton