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

#pragma once

#include <cstddef>
#include <cstdint>

namespace vespalib::datastore {

/*
 * Class representing candidate buffer for compaction.
 */
class CompactBufferCandidate {
    uint32_t _buffer_id;
    size_t   _used;
    size_t   _dead;
public:
    CompactBufferCandidate(uint32_t buffer_id, size_t used, size_t dead) noexcept
        : _buffer_id(buffer_id),
          _used(used),
          _dead(dead)
    {
    }

    CompactBufferCandidate() noexcept
        : CompactBufferCandidate(0, 0, 0)
    {
    }

    bool operator<(const CompactBufferCandidate& rhs) const noexcept { return _dead > rhs._dead; }
    uint32_t get_buffer_id() const noexcept { return _buffer_id; }
    size_t get_used() const noexcept { return _used; }
    size_t get_dead() const noexcept { return _dead; }
};

}