aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcorespi/index/indexmaintainercontext.h
blob: ca147ad77064f250f0cd643c92d21a059f794535 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include "ithreadingservice.h"
#include "iindexmanager.h"
#include <vespa/searchlib/common/tunefileinfo.h>
#include <vespa/searchlib/common/fileheadercontext.h>
#include <vespa/vespalib/util/threadexecutor.h>

namespace searchcorespi::index {

/**
 * Class that keeps the long-lived context used by an index maintainer.
 */
class IndexMaintainerContext {
private:
    IThreadingService &_threadingService;
    IIndexManager::Reconfigurer &_reconfigurer;
    const search::common::FileHeaderContext &_fileHeaderContext;
    vespalib::Executor & _warmupExecutor;

public:
    IndexMaintainerContext(IThreadingService &threadingService,
                           IIndexManager::Reconfigurer &reconfigurer,
                           const search::common::FileHeaderContext &fileHeaderContext,
                           vespalib::Executor & warmupExecutor);

    /**
     * Returns the treading service that encapsulates the thread model used for writing.
     */
    IThreadingService &getThreadingService() const {
        return _threadingService;
    }

    /**
     * Returns the reconfigurer used to signal when the index maintainer has changed.
     */
    IIndexManager::Reconfigurer &getReconfigurer() const {
        return _reconfigurer;
    }

    /**
     * Returns the context used to insert extra tags into file headers before writing them.
     */
    const search::common::FileHeaderContext &getFileHeaderContext() const {
        return _fileHeaderContext;
    }

    /**
     * @return The executor that should be used for warmup.
     */
    vespalib::Executor & getWarmupExecutor() const {  return _warmupExecutor; }
};

}