summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog/index_catalog_noop.h
blob: 12b97c208f8a8a86685fa47be675a6965a9e3baa (plain)
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/**
 *    Copyright (C) 2018-present MongoDB, Inc.
 *
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the Server Side Public License, version 1,
 *    as published by MongoDB, Inc.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    Server Side Public License for more details.
 *
 *    You should have received a copy of the Server Side Public License
 *    along with this program. If not, see
 *    <http://www.mongodb.com/licensing/server-side-public-license>.
 *
 *    As a special exception, the copyright holders give permission to link the
 *    code of portions of this program with the OpenSSL library under certain
 *    conditions as described in each individual source file and distribute
 *    linked combinations including the program with the OpenSSL library. You
 *    must comply with the Server Side Public License in all respects for
 *    all of the code used other than as permitted herein. If you modify file(s)
 *    with this exception, you may extend this exception to your version of the
 *    file(s), but you are not obligated to do so. If you do not wish to do so,
 *    delete this exception statement from your version. If you delete this
 *    exception statement from all source files in the program, then also delete
 *    it in the license file.
 */

#pragma once

#include "mongo/db/catalog/index_catalog.h"

namespace mongo {

/**
 * IndexCatalog implementation used for testing only.
 * Unit tests may override functions selectively to use as mock objects.
 */
class IndexCatalogNoop : public IndexCatalog {
public:
    Status init(OperationContext* const opCtx) override {
        return Status::OK();
    }

    bool haveAnyIndexes() const override {
        return false;
    }

    bool haveAnyIndexesInProgress() const override {
        return false;
    }

    int numIndexesTotal(OperationContext* const opCtx) const override {
        return 0;
    }

    int numIndexesReady(OperationContext* const opCtx) const override {
        return 0;
    }

    int numIndexesInProgress(OperationContext* const opCtx) const override {
        return 0;
    }

    bool haveIdIndex(OperationContext* const opCtx) const override {
        return false;
    }

    BSONObj getDefaultIdIndexSpec() const override {
        return {};
    }

    IndexDescriptor* findIdIndex(OperationContext* const opCtx) const override {
        return nullptr;
    }

    IndexDescriptor* findIndexByName(OperationContext* const opCtx,
                                     const StringData name,
                                     const bool includeUnfinishedIndexes = false) const override {
        return nullptr;
    }

    IndexDescriptor* findIndexByKeyPatternAndOptions(
        OperationContext* const opCtx,
        const BSONObj& key,
        const BSONObj& indexSpec,
        const bool includeUnfinishedIndexes = false) const override {
        return nullptr;
    }

    void findIndexesByKeyPattern(
        OperationContext* const opCtx,
        const BSONObj& key,
        const bool includeUnfinishedIndexes,
        std::vector<const IndexDescriptor*>* const matches) const override {}

    IndexDescriptor* findShardKeyPrefixedIndex(OperationContext* const opCtx,
                                               const BSONObj& shardKey,
                                               const bool requireSingleKey) const override {
        return nullptr;
    }

    void findIndexByType(OperationContext* const opCtx,
                         const std::string& type,
                         std::vector<const IndexDescriptor*>& matches,
                         const bool includeUnfinishedIndexes = false) const override {}

    const IndexDescriptor* refreshEntry(OperationContext* const opCtx,
                                        const IndexDescriptor* const oldDesc) override {
        return nullptr;
    }

    const IndexCatalogEntry* getEntry(const IndexDescriptor* const desc) const override {
        return nullptr;
    }

    std::shared_ptr<const IndexCatalogEntry> getEntryShared(const IndexDescriptor*) const override {
        return nullptr;
    }

    std::vector<std::shared_ptr<const IndexCatalogEntry>> getAllReadyEntriesShared()
        const override {
        return {};
    }

    std::unique_ptr<IndexIterator> getIndexIterator(
        OperationContext* const opCtx, const bool includeUnfinishedIndexes) const override {
        return {};
    }

    IndexCatalogEntry* createIndexEntry(OperationContext* opCtx,
                                        std::unique_ptr<IndexDescriptor> descriptor,
                                        CreateIndexEntryFlags flags) override {
        return nullptr;
    }

    StatusWith<BSONObj> createIndexOnEmptyCollection(OperationContext* const opCtx,
                                                     const BSONObj spec) override {
        return spec;
    }

    StatusWith<BSONObj> prepareSpecForCreate(OperationContext* const opCtx,
                                             const BSONObj& original) const override {
        return original;
    }

    std::vector<BSONObj> removeExistingIndexes(OperationContext* const opCtx,
                                               const std::vector<BSONObj>& indexSpecsToBuild,
                                               const bool removeIndexBuildsToo) const override {
        return indexSpecsToBuild;
    }

    std::vector<BSONObj> removeExistingIndexesNoChecks(
        OperationContext* const opCtx,
        const std::vector<BSONObj>& indexSpecsToBuild) const override {
        return {};
    }

    void dropAllIndexes(OperationContext* opCtx,
                        bool includingIdIndex,
                        std::function<void(const IndexDescriptor*)> onDropFn) override {}

    void dropAllIndexes(OperationContext* opCtx, bool includingIdIndex) override {}

    Status dropIndex(OperationContext* const opCtx, const IndexDescriptor* const desc) override {
        return Status::OK();
    }

    Status dropUnfinishedIndex(OperationContext* const opCtx,
                               const IndexDescriptor* const desc) override {
        return Status::OK();
    }

    Status dropIndexEntry(OperationContext* opCtx, IndexCatalogEntry* entry) override {
        return Status::OK();
    }

    void deleteIndexFromDisk(OperationContext* opCtx, const std::string& indexName) override {}

    std::vector<BSONObj> getAndClearUnfinishedIndexes(OperationContext* const opCtx) {
        return {};
    }

    bool isMultikey(const IndexDescriptor* const idx) {
        return false;
    }

    MultikeyPaths getMultikeyPaths(OperationContext* const opCtx,
                                   const IndexDescriptor* const idx) {
        return {};
    }

    void setMultikeyPaths(OperationContext* const opCtx,
                          Collection* coll,
                          const IndexDescriptor* const desc,
                          const MultikeyPaths& multikeyPaths) override {}

    Status indexRecords(OperationContext* const opCtx,
                        Collection* coll,
                        const std::vector<BsonRecord>& bsonRecords,
                        int64_t* const keysInsertedOut) override {
        return Status::OK();
    }

    Status updateRecord(OperationContext* const opCtx,
                        Collection* coll,
                        const BSONObj& oldDoc,
                        const BSONObj& newDoc,
                        const RecordId& recordId,
                        int64_t* const keysInsertedOut,
                        int64_t* const keysDeletedOut) override {
        return Status::OK();
    };

    void unindexRecord(OperationContext* const opCtx,
                       const BSONObj& obj,
                       const RecordId& loc,
                       const bool noWarn,
                       int64_t* const keysDeletedOut) override {}

    virtual Status compactIndexes(OperationContext* opCtx) override {
        return Status::OK();
    }

    std::string getAccessMethodName(const BSONObj& keyPattern) override {
        return "";
    }

    std::string::size_type getLongestIndexNameLength(OperationContext* opCtx) const override {
        return 0U;
    }

    BSONObj fixIndexKey(const BSONObj& key) const override {
        return {};
    }

    void prepareInsertDeleteOptions(OperationContext* opCtx,
                                    const NamespaceString& ns,
                                    const IndexDescriptor* desc,
                                    InsertDeleteOptions* options) const override {}

    void indexBuildSuccess(OperationContext* opCtx,
                           const Collection* coll,
                           IndexCatalogEntry* index) override {}
};

}  // namespace mongo