Storage Engine API
collection_mock.h
Go to the documentation of this file.
1 
29 #pragma once
30 
32 
33 namespace mongo {
34 
38 class CollectionMock : virtual public Collection::Impl,
39  virtual CappedCallback,
40  virtual UpdateNotifier {
41 public:
42  CollectionMock(const NamespaceString& ns) : _ns(ns) {}
43  ~CollectionMock() = default;
44 
45  void init(OperationContext* opCtx) {
46  std::abort();
47  }
48 
49 private:
51  std::abort();
52  }
53 
55  std::abort();
56  }
57 
58  Status aboutToDeleteCapped(OperationContext* opCtx, const RecordId& loc, RecordData data) {
59  std::abort();
60  }
61 
62  Status recordStoreGoingToUpdateInPlace(OperationContext* opCtx, const RecordId& loc) {
63  std::abort();
64  }
65  const NamespaceString _ns;
66 
67 public:
68  const NamespaceString& ns() const {
69  return _ns;
70  }
71  bool ok() const {
72  std::abort();
73  }
74 
76  std::abort();
77  }
79  std::abort();
80  }
81 
83  std::abort();
84  }
85  const CollectionInfoCache* infoCache() const {
86  std::abort();
87  }
88  const IndexCatalog* getIndexCatalog() const {
89  std::abort();
90  }
92  std::abort();
93  }
94 
95  const RecordStore* getRecordStore() const {
96  std::abort();
97  }
99  std::abort();
100  }
101 
102  CursorManager* getCursorManager() const {
103  std::abort();
104  }
105 
106  bool requiresIdIndex() const {
107  std::abort();
108  }
109 
110  Snapshotted<BSONObj> docFor(OperationContext* opCtx, const RecordId& loc) const {
111  std::abort();
112  }
113 
114  bool findDoc(OperationContext* opCtx, const RecordId& loc, Snapshotted<BSONObj>* out) const {
115  std::abort();
116  }
117 
118  std::unique_ptr<SeekableRecordCursor> getCursor(OperationContext* opCtx, bool forward) const {
119  std::abort();
120  }
121 
122  std::vector<std::unique_ptr<RecordCursor>> getManyCursors(OperationContext* opCtx) const {
123  std::abort();
124  }
125 
126  void deleteDocument(OperationContext* opCtx,
127  StmtId stmtId,
128  const RecordId& loc,
129  OpDebug* opDebug,
130  bool fromMigrate,
131  bool noWarn,
132  Collection::StoreDeletedDoc storeDeletedDoc) {
133  std::abort();
134  }
135 
136  Status insertDocuments(OperationContext* opCtx,
137  std::vector<InsertStatement>::const_iterator begin,
138  std::vector<InsertStatement>::const_iterator end,
139  OpDebug* opDebug,
140  bool enforceQuota,
141  bool fromMigrate) {
142  std::abort();
143  }
144 
145  Status insertDocument(OperationContext* opCtx,
146  const InsertStatement& doc,
147  OpDebug* opDebug,
148  bool enforceQuota,
149  bool fromMigrate) {
150  std::abort();
151  }
152 
154  const DocWriter* const* docs,
155  Timestamp* timestamps,
156  size_t nDocs) {
157  std::abort();
158  }
159 
160  Status insertDocument(OperationContext* opCtx,
161  const BSONObj& doc,
162  const std::vector<MultiIndexBlock*>& indexBlocks,
163  bool enforceQuota) {
164  std::abort();
165  }
166 
167  RecordId updateDocument(OperationContext* opCtx,
168  const RecordId& oldLocation,
169  const Snapshotted<BSONObj>& oldDoc,
170  const BSONObj& newDoc,
171  bool enforceQuota,
172  bool indexesAffected,
173  OpDebug* opDebug,
174  OplogUpdateEntryArgs* args) {
175  std::abort();
176  }
177 
179  std::abort();
180  }
181 
183  const RecordId& loc,
184  const Snapshotted<RecordData>& oldRec,
185  const char* damageSource,
186  const mutablebson::DamageVector& damages,
187  OplogUpdateEntryArgs* args) {
188  std::abort();
189  }
190 
191  StatusWith<CompactStats> compact(OperationContext* opCtx, const CompactOptions* options) {
192  std::abort();
193  }
194  Status truncate(OperationContext* opCtx) {
195  std::abort();
196  }
197 
198  Status validate(OperationContext* opCtx,
199  ValidateCmdLevel level,
200  bool background,
201  std::unique_ptr<Lock::CollectionLock> collLk,
202  ValidateResults* results,
203  BSONObjBuilder* output) {
204  std::abort();
205  }
206 
207  Status touch(OperationContext* opCtx,
208  bool touchData,
209  bool touchIndexes,
210  BSONObjBuilder* output) const {
211  std::abort();
212  }
213 
214  void cappedTruncateAfter(OperationContext* opCtx, RecordId end, bool inclusive) {
215  std::abort();
216  }
217 
218  StatusWithMatchExpression parseValidator(
219  OperationContext* opCtx,
220  const BSONObj& validator,
221  MatchExpressionParser::AllowedFeatureSet allowedFeatures,
222  boost::optional<ServerGlobalParams::FeatureCompatibility::Version>
223  maxFeatureCompatibilityVersion) const {
224  std::abort();
225  }
226 
227  Status setValidator(OperationContext* opCtx, BSONObj validator) {
228  std::abort();
229  }
230 
231  Status setValidationLevel(OperationContext* opCtx, StringData newLevel) {
232  std::abort();
233  }
234  Status setValidationAction(OperationContext* opCtx, StringData newAction) {
235  std::abort();
236  }
237 
238  StringData getValidationLevel() const {
239  std::abort();
240  }
241  StringData getValidationAction() const {
242  std::abort();
243  }
244 
245  Status updateValidator(OperationContext* opCtx,
246  BSONObj newValidator,
247  StringData newLevel,
248  StringData newAction) {
249  std::abort();
250  }
251 
252  bool isCapped() const {
253  std::abort();
254  }
255 
256  std::shared_ptr<CappedInsertNotifier> getCappedInsertNotifier() const {
257  std::abort();
258  }
259 
260  uint64_t numRecords(OperationContext* opCtx) const {
261  std::abort();
262  }
263 
264  uint64_t dataSize(OperationContext* opCtx) const {
265  std::abort();
266  }
267 
268  uint64_t getIndexSize(OperationContext* opCtx, BSONObjBuilder* details, int scale) {
269  std::abort();
270  }
271 
272  boost::optional<Timestamp> getMinimumVisibleSnapshot() {
273  std::abort();
274  }
275 
276  void setMinimumVisibleSnapshot(Timestamp name) {
277  std::abort();
278  }
279 
281  return false;
282  }
283 
285  std::abort();
286  }
287 
288  const CollatorInterface* getDefaultCollator() const {
289  std::abort();
290  }
291 
293  std::abort();
294  }
295 };
296 } // namespace mongo
StatusWith< RecordData > updateDocumentWithDamages(OperationContext *opCtx, const RecordId &loc, const Snapshotted< RecordData > &oldRec, const char *damageSource, const mutablebson::DamageVector &damages, OplogUpdateEntryArgs *args)
Definition: collection_mock.h:182
ValidateCmdLevel
Definition: record_store.h:93
void init(OperationContext *opCtx)
Definition: collection_mock.h:45
Status aboutToDeleteCapped(OperationContext *opCtx, const RecordId &loc, RecordData data)
This will be called right before loc is deleted when wrapping.
Definition: collection_mock.h:58
StoreDeletedDoc
Definition: collection.h:164
Status setValidationLevel(OperationContext *opCtx, StringData newLevel)
Definition: collection_mock.h:231
DatabaseCatalogEntry * dbce() const
Definition: collection_mock.h:50
IndexCatalog * getIndexCatalog()
Definition: collection_mock.h:91
Definition: snapshot.h:69
bool ok() const
Definition: collection_mock.h:71
Definition: record_store.h:673
void deleteDocument(OperationContext *opCtx, StmtId stmtId, const RecordId &loc, OpDebug *opDebug, bool fromMigrate, bool noWarn, Collection::StoreDeletedDoc storeDeletedDoc)
Definition: collection_mock.h:126
Status truncate(OperationContext *opCtx)
Definition: collection_mock.h:194
bool isCapped() const
Definition: collection_mock.h:252
std::unique_ptr< SeekableRecordCursor > getCursor(OperationContext *opCtx, bool forward) const
Definition: collection_mock.h:118
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
StringData getValidationLevel() const
Definition: collection_mock.h:238
Definition: collection_catalog_entry.h:47
const CollatorInterface * getDefaultCollator() const
Definition: collection_mock.h:288
uint64_t numRecords(OperationContext *opCtx) const
Definition: collection_mock.h:260
const CollectionInfoCache * infoCache() const
Definition: collection_mock.h:85
A replacement for the Record class.
Definition: record_data.h:43
bool requiresIdIndex() const
Definition: collection_mock.h:106
Definition: collection.h:166
Definition: record_store.h:78
This class comprises a mock Collection for use by UUIDCatalog unit tests.
Definition: collection_mock.h:38
bool inclusive
Definition: btree_interface.cpp:335
const NamespaceString & ns() const
Definition: collection_mock.h:68
Definition: collection.h:77
Allows inserting a Record "in-place" without creating a copy ahead of time.
Definition: record_store.h:62
OptionalCollectionUUID uuid() const
Definition: collection_mock.h:292
std::shared_ptr< void > data
Definition: ephemeral_for_test_record_store_test.cpp:74
how many: 1 per Collection.
Definition: index_catalog.h:62
CollectionCatalogEntry * details() const
Definition: collection_mock.h:54
Status setValidationAction(OperationContext *opCtx, StringData newAction)
Definition: collection_mock.h:234
std::shared_ptr< CappedInsertNotifier > getCappedInsertNotifier() const
Definition: collection_mock.h:256
CollectionCatalogEntry * getCatalogEntry()
Definition: collection_mock.h:75
Status insertDocument(OperationContext *opCtx, const InsertStatement &doc, OpDebug *opDebug, bool enforceQuota, bool fromMigrate)
Definition: collection_mock.h:145
OperationContext Database StringData CollectionOptions bool const BSONObj &idIndex Status
Definition: database_impl.cpp:955
void cappedTruncateAfter(OperationContext *opCtx, RecordId end, bool inclusive)
Definition: collection_mock.h:214
boost::optional< CollectionUUID > OptionalCollectionUUID
Definition: collection_options.h:55
StatusWithMatchExpression parseValidator(OperationContext *opCtx, const BSONObj &validator, MatchExpressionParser::AllowedFeatureSet allowedFeatures, boost::optional< ServerGlobalParams::FeatureCompatibility::Version > maxFeatureCompatibilityVersion) const
Definition: collection_mock.h:218
const IndexCatalog * getIndexCatalog() const
Definition: collection_mock.h:88
bool haveCappedWaiters()
Returns true if there may be waiters.
Definition: collection_mock.h:280
boost::optional< Timestamp > getMinimumVisibleSnapshot()
Definition: collection_mock.h:272
CollectionMock(const NamespaceString &ns)
Definition: collection_mock.h:42
const RecordStore * getRecordStore() const
Definition: collection_mock.h:95
Definition: index_key_validate.h:40
Status insertDocument(OperationContext *opCtx, const BSONObj &doc, const std::vector< MultiIndexBlock * > &indexBlocks, bool enforceQuota)
Definition: collection_mock.h:160
Status touch(OperationContext *opCtx, bool touchData, bool touchIndexes, BSONObjBuilder *output) const
Definition: collection_mock.h:207
Status recordStoreGoingToUpdateInPlace(OperationContext *opCtx, const RecordId &loc)
Definition: collection_mock.h:62
CollectionInfoCache * infoCache()
Definition: collection_mock.h:82
An abstraction used for storing documents in a collection or entries in an index.
Definition: record_store.h:282
When a capped collection is modified (delete/insert/etc) then certain notifications need to be made,...
Definition: capped_callback.h:44
StatusWith< CompactStats > compact(OperationContext *opCtx, const CompactOptions *options)
Definition: collection_mock.h:191
bool updateWithDamagesSupported() const
Definition: collection_mock.h:178
void setMinimumVisibleSnapshot(Timestamp name)
Definition: collection_mock.h:276
Status insertDocumentsForOplog(OperationContext *opCtx, const DocWriter *const *docs, Timestamp *timestamps, size_t nDocs)
Definition: collection_mock.h:153
Definition: database_catalog_entry.h:50
Status validate(OperationContext *opCtx, ValidateCmdLevel level, bool background, std::unique_ptr< Lock::CollectionLock > collLk, ValidateResults *results, BSONObjBuilder *output)
Definition: collection_mock.h:198
Snapshotted< BSONObj > docFor(OperationContext *opCtx, const RecordId &loc) const
Definition: collection_mock.h:110
const CollectionCatalogEntry * getCatalogEntry() const
Definition: collection_mock.h:78
Status updateValidator(OperationContext *opCtx, BSONObj newValidator, StringData newLevel, StringData newAction)
Definition: collection_mock.h:245
StringData getValidationAction() const
Definition: collection_mock.h:241
uint64_t getIndexSize(OperationContext *opCtx, BSONObjBuilder *details, int scale)
Definition: collection_mock.h:268
std::vector< std::unique_ptr< RecordCursor > > getManyCursors(OperationContext *opCtx) const
Definition: collection_mock.h:122
void notifyCappedWaitersIfNeeded()
Used to notify any waiters when new documents may be visible in the capped collection.
Definition: collection_mock.h:284
Database *const OperationContext *const const StringData name
Definition: database_impl.cpp:82
Collection *const OperationContext *const opCtx
Definition: collection_impl.cpp:80
uint64_t dataSize(OperationContext *opCtx) const
Definition: collection_mock.h:264
bool findDoc(OperationContext *opCtx, const RecordId &loc, Snapshotted< BSONObj > *out) const
Definition: collection_mock.h:114
RecordStore * getRecordStore()
Definition: collection_mock.h:98
this is for storing things that you want to cache about a single collection life cycle is managed for...
Definition: collection_info_cache.h:47
const NamespaceString _ns
Definition: collection_mock.h:65
Status insertDocuments(OperationContext *opCtx, std::vector< InsertStatement >::const_iterator begin, std::vector< InsertStatement >::const_iterator end, OpDebug *opDebug, bool enforceQuota, bool fromMigrate)
Definition: collection_mock.h:136
RecordId updateDocument(OperationContext *opCtx, const RecordId &oldLocation, const Snapshotted< BSONObj > &oldDoc, const BSONObj &newDoc, bool enforceQuota, bool indexesAffected, OpDebug *opDebug, OplogUpdateEntryArgs *args)
Definition: collection_mock.h:167
CursorManager * getCursorManager() const
Definition: collection_mock.h:102
Status setValidator(OperationContext *opCtx, BSONObj validator)
Definition: collection_mock.h:227