aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storage/common/content_bucket_space_repo.cpp
blob: bddfa8126579989e93aff3120e35246f86e51f10 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "content_bucket_space_repo.h"
#include <vespa/document/bucket/fixed_bucket_spaces.h>

using document::BucketSpace;

namespace storage {

ContentBucketSpaceRepo::ContentBucketSpaceRepo(const ContentBucketDbOptions& db_opts)
    : _map()
{
    _map.emplace(document::FixedBucketSpaces::default_space(),
                 std::make_unique<ContentBucketSpace>(document::FixedBucketSpaces::default_space(), db_opts));
    _map.emplace(document::FixedBucketSpaces::global_space(),
                 std::make_unique<ContentBucketSpace>(document::FixedBucketSpaces::global_space(), db_opts));
}

ContentBucketSpace &
ContentBucketSpaceRepo::get(BucketSpace bucketSpace) const
{
    auto itr = _map.find(bucketSpace);
    assert(itr != _map.end());
    return *itr->second;
}

ContentBucketSpaceRepo::BucketSpaces
ContentBucketSpaceRepo::getBucketSpaces() const
{
    BucketSpaces result;
    for (const auto &elem : _map) {
        result.push_back(elem.first);
    }
    return result;
}

size_t
ContentBucketSpaceRepo::getBucketMemoryUsage() const
{
    size_t result = 0;
    for (const auto &elem : _map) {
        result += elem.second->bucketDatabase().getMemoryUsage();
    }
    return result;
}

}