aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h
blob: b945c67660b9df16b658ff4e35e2e0152efff864 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <vespa/searchcore/proton/matching/matching_stats.h>
#include <vespa/searchcore/proton/reprocessing/i_reprocessing_task.h>
#include <vespa/searchlib/common/serialnum.h>
#include <vespa/searchlib/util/searchable_stats.h>
#include <vespa/vespalib/stllike/string.h>
#include <vespa/vespalib/util/idestructorcallback.h>

namespace search::index { class Schema; }

namespace document { class DocumentId; }

namespace searchcorespi {
    class IFlushTarget;
    class IIndexManager;
}
namespace proton::index {
    struct IndexConfig;
}

namespace proton {

namespace matching { class SessionManager; }

class DocumentDBConfig;
class DocumentSubDbInitializer;
class DocumentSubDbInitializerResult;
class FeedHandler;
class IDocumentDBReference;
class IDocumentRetriever;
class IFeedView;
class IIndexWriter;
class IReplayConfig;
class ISearchHandler;
class ISummaryAdapter;
class ISummaryManager;
class PendingLidTrackerBase;
class ReconfigParams;
class RemoveDocumentsOperation;
class TransientResourceUsage;
struct IAttributeManager;
struct IBucketStateCalculator;
struct IDocumentDBReferenceResolver;
struct IDocumentMetaStoreContext;

/**
 * Interface for a document sub database that handles a subset of the documents that belong to a
 * DocumentDB.
 *
 * Documents can be inserted/updated/removed to a sub database via a feed view,
 * searched via a search view and retrieved via a document retriever.
 * A sub database is separate and independent from other sub databases.
 */
class IDocumentSubDB
{
public:
    using UP = std::unique_ptr<IDocumentSubDB>;
    using SerialNum = search::SerialNum;
    using Schema = search::index::Schema;
    using SchemaSP = std::shared_ptr<Schema>;
    using IFlushTargetList = std::vector<std::shared_ptr<searchcorespi::IFlushTarget>>;
    using IndexConfig = index::IndexConfig;
    using OnDone = std::shared_ptr<vespalib::IDestructorCallback>;
public:
    IDocumentSubDB() { }
    virtual ~IDocumentSubDB() { }
    virtual uint32_t getSubDbId() const = 0;
    virtual vespalib::string getName() const = 0;

    virtual std::unique_ptr<DocumentSubDbInitializer>
    createInitializer(const DocumentDBConfig &configSnapshot, SerialNum configSerialNum,
                      const IndexConfig &indexCfg) const = 0;

    // Called by master thread
    virtual void setup(const DocumentSubDbInitializerResult &initResult) = 0;
    virtual void initViews(const DocumentDBConfig &configSnapshot, const std::shared_ptr<matching::SessionManager> &sessionManager) = 0;

    virtual IReprocessingTask::List
    applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot,
                SerialNum serialNum, const ReconfigParams &params, IDocumentDBReferenceResolver &resolver) = 0;
    virtual void setBucketStateCalculator(const std::shared_ptr<IBucketStateCalculator> &calc, OnDone) = 0;

    virtual std::shared_ptr<ISearchHandler> getSearchView() const = 0;
    virtual std::shared_ptr<IFeedView> getFeedView() const = 0;
    virtual void clearViews() = 0;
    virtual const std::shared_ptr<ISummaryManager> &getSummaryManager() const = 0;
    virtual std::shared_ptr<IAttributeManager> getAttributeManager() const = 0;
    virtual const std::shared_ptr<searchcorespi::IIndexManager> &getIndexManager() const = 0;
    virtual const std::shared_ptr<ISummaryAdapter> &getSummaryAdapter() const = 0;
    virtual const std::shared_ptr<IIndexWriter> &getIndexWriter() const = 0;
    virtual IDocumentMetaStoreContext &getDocumentMetaStoreContext() = 0;
    virtual const IDocumentMetaStoreContext &getDocumentMetaStoreContext() const = 0;
    virtual IFlushTargetList getFlushTargets() = 0;
    virtual size_t getNumDocs() const = 0;
    virtual size_t getNumActiveDocs() const = 0;
    /**
     * Needed by FeedRouter::handleRemove().
     * TODO: remove together with FeedEngine.
     **/
    virtual bool hasDocument(const document::DocumentId &id) = 0;
    virtual void onReplayDone() = 0;
    virtual void onReprocessDone(SerialNum serialNum) = 0;

    /*
     * Get oldest flushed serial for components.
     */
    virtual SerialNum getOldestFlushedSerial() = 0;

    /*
     * Get newest flushed serial.  Used to validate that we've not lost
     * last part of transaction log.
     */
    virtual SerialNum getNewestFlushedSerial()  = 0;
    virtual void pruneRemovedFields(SerialNum serialNum) = 0;
    virtual void setIndexSchema(const SchemaSP &schema, SerialNum serialNum) = 0;
    virtual search::SearchableStats getSearchableStats() const = 0;
    virtual std::unique_ptr<IDocumentRetriever> getDocumentRetriever() = 0;

    virtual matching::MatchingStats getMatcherStats(const vespalib::string &rankProfile) const = 0;
    virtual void close() = 0;
    virtual std::shared_ptr<IDocumentDBReference> getDocumentDBReference() = 0;
    virtual void tearDownReferences(IDocumentDBReferenceResolver &resolver) = 0;
    virtual void validateDocStore(FeedHandler &op, SerialNum serialNum) const = 0;
    virtual PendingLidTrackerBase & getUncommittedLidsTracker() = 0;
    virtual TransientResourceUsage get_transient_resource_usage() const = 0;
};

} // namespace proton