aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/vespa/vespalib/datastore/compact_buffer_candidates.h
blob: db82ebd4eae24aa34047d0f3c0e45611a271efbf (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "compact_buffer_candidate.h"
#include <vector>

namespace vespalib::datastore {

/*
 * Class representing candidate buffers for compaction.
 */
class CompactBufferCandidates {
    std::vector<CompactBufferCandidate> _candidates;
    size_t                            _used;
    size_t                            _dead;
    uint32_t                          _max_buffers;
    double                            _active_buffers_ratio;
    double                            _ratio;
    size_t                            _slack;
    uint32_t                          _free_buffers;
public:
    CompactBufferCandidates(uint32_t num_buffers, uint32_t max_buffers, double active_buffers_ratio, double ratio, size_t slack);
    ~CompactBufferCandidates();
    void add(uint32_t buffer_id, size_t used, size_t dead);
    void set_free_buffers(uint32_t free_buffers);
    void select(std::vector<uint32_t>& buffers);
};

}