aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/server/i_lid_space_compaction_handler.h
blob: 6954d36ee0c99797661c755fc7373bc46eb754f4 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/searchlib/common/lid_usage_stats.h>
#include <vespa/vespalib/stllike/string.h>
#include <memory>
#include <vector>

namespace vespalib { class IDestructorCallback; }
namespace search { struct DocumentMetaData; }
namespace proton::documentmetastore { class OperationListener; }

namespace proton {

class MoveOperation;
class CompactLidSpaceOperation;
struct IDocumentScanIterator;

/**
 * Interface for handling of lid space compaction, used by a LidSpaceCompactionJob.
 *
 * An implementation of this interface is typically working over a single document sub db.
 */
struct ILidSpaceCompactionHandler
{
    using SP = std::shared_ptr<ILidSpaceCompactionHandler>;
    using Vector = std::vector<SP>;

    virtual ~ILidSpaceCompactionHandler() = default;

    /**
     * Returns the name of this handler.
     */
    virtual vespalib::string getName() const = 0;

    /**
     * Sets the listener used to get notifications on the operations handled by the document meta store.
     *
     * A call to this function should replace the previous listener if set.
     */
    virtual void set_operation_listener(std::shared_ptr<documentmetastore::OperationListener> op_listener) = 0;

    /**
     * Returns the id of the sub database this handler is operating over.
     */
    virtual uint32_t getSubDbId() const = 0;

    /**
     * Returns the current lid status of the underlying components.
     */
    virtual search::LidUsageStats getLidStatus() const = 0;

    /**
     * Returns an iterator for scanning documents.
     */
    virtual std::unique_ptr<IDocumentScanIterator> getIterator() const = 0;

    /**
     * Return the meta data associated with the given lid
     */
    virtual search::DocumentMetaData getMetaData(uint32_t lid) const = 0;

    /**
     * Creates a move operation for moving the given document to the given lid.
     */
    virtual std::unique_ptr<MoveOperation> createMoveOperation(const search::DocumentMetaData &document, uint32_t moveToLid) const = 0;

    /**
     * Performs the actual move operation.
     */
    virtual void handleMove(const MoveOperation &op, std::shared_ptr<vespalib::IDestructorCallback> moveDoneCtx) = 0;

    /**
     * Compacts the underlying lid space by starting using the new lid limit.
     */
    virtual void handleCompactLidSpace(const CompactLidSpaceOperation &op, std::shared_ptr<vespalib::IDestructorCallback> compact_done_context) = 0;
};

} // namespace proton