aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/common/i_compactable_lid_space.h
blob: 80cc8cb7a17c4ba2f8d86893551ffc16fef91abe (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 <cstdint>
#include <cstddef>

namespace search::common {

/**
 * Interface for a component that has a lid space that can be compacted and shrunk.
 */
struct ICompactableLidSpace {
    virtual ~ICompactableLidSpace() = default;

    /**
     * Compacts the lid space down to the wanted given doc id limit.
     * After this, the remaining lid space is a candidate for shrinking (freeing of memory resources).
     */
    virtual void compactLidSpace(uint32_t wantedDocLidLimit) = 0;

    /**
     * Returns whether this lid space can be shrunk down to the wanted doc id limit.
     */
    virtual bool canShrinkLidSpace() const = 0;

    /*
     * Returns how much memory (in bytes) that can be saved by shrinking lid space.
     */
    virtual size_t getEstimatedShrinkLidSpaceGain() const = 0;

    /**
     * Shrinks this lid space down to the wanted doc id limit (frees memory resources).
     */
    virtual void shrinkLidSpace() = 0;
};

}