Storage Engine API
record_store_validate_adaptor.h
Go to the documentation of this file.
1 /*-
2  * Copyright (C) 2017 MongoDB Inc.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Affero General Public License, version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Affero General Public License for more details.
12  *
13  * You should have received a copy of the GNU Affero General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * As a special exception, the copyright holders give permission to link the
17  * code of portions of this program with the OpenSSL library under certain
18  * conditions as described in each individual source file and distribute
19  * linked combinations including the program with the OpenSSL library. You
20  * must comply with the GNU Affero General Public License in all respects for
21  * all of the code used other than as permitted herein. If you modify file(s)
22  * with this exception, you may extend this exception to your version of the
23  * file(s), but you are not obligated to do so. If you do not wish to do so,
24  * delete this exception statement from your version. If you delete this
25  * exception statement from all source files in the program, then also delete
26  * it in the license file.
27  */
28 
29 #pragma once
30 
33 #include "mongo/db/index/index_access_method.h"
34 #include "mongo/db/index/index_descriptor.h"
35 #include "mongo/db/operation_context.h"
37 
38 namespace mongo {
39 
40 class IndexConsistency;
41 
42 namespace {
43 
44 using ValidateResultsMap = std::map<std::string, ValidateResults>;
45 }
46 
52 public:
53  RecordStoreValidateAdaptor(OperationContext* opCtx,
54  IndexConsistency* indexConsistency,
55  ValidateCmdLevel level,
56  IndexCatalog* ic,
57  ValidateResultsMap* irm)
58 
59  : _opCtx(opCtx),
60  _indexConsistency(indexConsistency),
61  _level(level),
62  _indexCatalog(ic),
63  _indexNsResultsMap(irm) {}
64 
69  virtual Status validate(const RecordId& recordId, const RecordData& record, size_t* dataSize);
70 
75  void traverseIndex(const IndexAccessMethod* iam,
76  const IndexDescriptor* descriptor,
77  ValidateResults* results,
78  int64_t* numTraversedKeys);
79 
84  void traverseRecordStore(RecordStore* recordStore,
85  ValidateCmdLevel level,
86  ValidateResults* results,
87  BSONObjBuilder* output);
88 
92  void validateIndexKeyCount(IndexDescriptor* idx, int64_t numRecs, ValidateResults& results);
93 
94 private:
95  OperationContext* _opCtx; // Not owned.
98  IndexCatalog* _indexCatalog; // Not owned.
99  ValidateResultsMap* _indexNsResultsMap; // Not owned.
100 };
101 } // namespace
ValidateCmdLevel
Definition: record_store.h:93
IndexCatalog * _indexCatalog
Definition: record_store_validate_adaptor.h:98
Definition: record_store.h:671
IndexConsistency * _indexConsistency
Definition: record_store_validate_adaptor.h:96
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
OperationContext * _opCtx
Definition: index_consistency.h:242
OperationContext Database StringData BSONObj CollectionOptions::ParseKind bool const BSONObj &idIndex Status
Definition: database_impl.cpp:956
A replacement for the Record class.
Definition: record_data.h:43
ValidateResultsMap * _indexNsResultsMap
Definition: record_store_validate_adaptor.h:99
This is so when a RecordStore is validating all records it can call back to someone to check if a rec...
Definition: record_store.h:685
const IndexDescriptor * idx
Definition: coll_mod.cpp:70
RecordStoreValidateAdaptor(OperationContext *opCtx, IndexConsistency *indexConsistency, ValidateCmdLevel level, IndexCatalog *ic, ValidateResultsMap *irm)
Definition: record_store_validate_adaptor.h:53
how many: 1 per Collection.
Definition: index_catalog.h:62
Collection *const OperationContext *const const StringData OptionalCollectionUUID CollectionCatalogEntry *const RecordStore *const recordStore
Definition: collection_impl.cpp:80
Definition: index_consistency.h:84
OperationContext * _opCtx
Definition: record_store_validate_adaptor.h:95
An abstraction used for storing documents in a collection or entries in an index. ...
Definition: record_store.h:282
IndexCatalogEntry *const OperationContext *const const StringData CollectionCatalogEntry *const std::unique_ptr< IndexDescriptor > descriptor
Definition: index_catalog_entry_impl.cpp:58
The record store validate adaptor is used to keep track of the index consistency during a validation ...
Definition: record_store_validate_adaptor.h:51
Collection *const OperationContext *const opCtx
Definition: collection_impl.cpp:80
ValidateCmdLevel _level
Definition: record_store_validate_adaptor.h:97