aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/common/alloc_strategy.h
blob: b4936f955c3d1de8b978080e076a1b1065c31682 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/searchcommon/common/growstrategy.h>
#include <vespa/vespalib/datastore/compaction_strategy.h>
#include <iosfwd>

namespace proton {

/*
 * Class representing allocation strategy for large data structures
 * owned by a document sub db (e.g. attribute vectors, document meta store).
 */
class AllocStrategy
{
public:
    using CompactionStrategy = vespalib::datastore::CompactionStrategy;
protected:
    const search::GrowStrategy       _grow_strategy;
    const CompactionStrategy         _compaction_strategy;
    const uint32_t                   _amortize_count;

public:
    AllocStrategy(const search::GrowStrategy& grow_strategy,
                  const CompactionStrategy& compaction_strategy,
                  uint32_t amortize_count);

    AllocStrategy();
    ~AllocStrategy();

    bool operator==(const AllocStrategy &rhs) const noexcept;
    bool operator!=(const AllocStrategy &rhs) const noexcept {
        return !operator==(rhs);
    }
    const search::GrowStrategy& get_grow_strategy() const noexcept { return _grow_strategy; }
    const CompactionStrategy& get_compaction_strategy() const noexcept { return _compaction_strategy; }
    uint32_t get_amortize_count() const noexcept { return _amortize_count; }
};

std::ostream& operator<<(std::ostream& os, const AllocStrategy&alloc_strategy);

}