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 
89  void refreshUUID(OperationContext* opCtx) {
90  std::abort();
91  }
92 
93  const IndexCatalog* getIndexCatalog() const {
94  std::abort();
95  }
97  std::abort();
98  }
99 
100  const RecordStore* getRecordStore() const {
101  std::abort();
102  }
104  std::abort();
105  }
106 
107  CursorManager* getCursorManager() const {
108  std::abort();
109  }
110 
111  bool requiresIdIndex() const {
112  std::abort();
113  }
114 
115  Snapshotted<BSONObj> docFor(OperationContext* opCtx, const RecordId& loc) const {
116  std::abort();
117  }
118 
119  bool findDoc(OperationContext* opCtx, const RecordId& loc, Snapshotted<BSONObj>* out) const {
120  std::abort();
121  }
122 
123  std::unique_ptr<SeekableRecordCursor> getCursor(OperationContext* opCtx, bool forward) const {
124  std::abort();
125  }
126 
127  std::vector<std::unique_ptr<RecordCursor>> getManyCursors(OperationContext* opCtx) const {
128  std::abort();
129  }
130 
131  void deleteDocument(OperationContext* opCtx,
132  StmtId stmtId,
133  const RecordId& loc,
134  OpDebug* opDebug,
135  bool fromMigrate,
136  bool noWarn,
137  Collection::StoreDeletedDoc storeDeletedDoc) {
138  std::abort();
139  }
140 
141  Status insertDocuments(OperationContext* opCtx,
142  std::vector<InsertStatement>::const_iterator begin,
143  std::vector<InsertStatement>::const_iterator end,
144  OpDebug* opDebug,
145  bool enforceQuota,
146  bool fromMigrate) {
147  std::abort();
148  }
149 
150  Status insertDocument(OperationContext* opCtx,
151  const InsertStatement& doc,
152  OpDebug* opDebug,
153  bool enforceQuota,
154  bool fromMigrate) {
155  std::abort();
156  }
157 
159  const DocWriter* const* docs,
160  Timestamp* timestamps,
161  size_t nDocs) {
162  std::abort();
163  }
164 
165  Status insertDocument(OperationContext* opCtx,
166  const BSONObj& doc,
167  const std::vector<MultiIndexBlock*>& indexBlocks,
168  bool enforceQuota) {
169  std::abort();
170  }
171 
172  RecordId updateDocument(OperationContext* opCtx,
173  const RecordId& oldLocation,
174  const Snapshotted<BSONObj>& oldDoc,
175  const BSONObj& newDoc,
176  bool enforceQuota,
177  bool indexesAffected,
178  OpDebug* opDebug,
179  OplogUpdateEntryArgs* args) {
180  std::abort();
181  }
182 
184  std::abort();
185  }
186 
188  const RecordId& loc,
189  const Snapshotted<RecordData>& oldRec,
190  const char* damageSource,
191  const mutablebson::DamageVector& damages,
192  OplogUpdateEntryArgs* args) {
193  std::abort();
194  }
195 
197  std::abort();
198  }
199  Status truncate(OperationContext* opCtx) {
200  std::abort();
201  }
202 
203  Status validate(OperationContext* opCtx,
204  ValidateCmdLevel level,
205  bool background,
206  std::unique_ptr<Lock::CollectionLock> collLk,
207  ValidateResults* results,
208  BSONObjBuilder* output) {
209  std::abort();
210  }
211 
212  Status touch(OperationContext* opCtx,
213  bool touchData,
214  bool touchIndexes,
215  BSONObjBuilder* output) const {
216  std::abort();
217  }
218 
219  void cappedTruncateAfter(OperationContext* opCtx, RecordId end, bool inclusive) {
220  std::abort();
221  }
222 
223  StatusWithMatchExpression parseValidator(
224  OperationContext* opCtx,
225  const BSONObj& validator,
226  MatchExpressionParser::AllowedFeatureSet allowedFeatures,
227  boost::optional<ServerGlobalParams::FeatureCompatibility::Version>
228  maxFeatureCompatibilityVersion) const {
229  std::abort();
230  }
231 
232  Status setValidator(OperationContext* opCtx, BSONObj validator) {
233  std::abort();
234  }
235 
236  Status setValidationLevel(OperationContext* opCtx, StringData newLevel) {
237  std::abort();
238  }
239  Status setValidationAction(OperationContext* opCtx, StringData newAction) {
240  std::abort();
241  }
242 
243  StringData getValidationLevel() const {
244  std::abort();
245  }
246  StringData getValidationAction() const {
247  std::abort();
248  }
249 
250  Status updateValidator(OperationContext* opCtx,
251  BSONObj newValidator,
252  StringData newLevel,
253  StringData newAction) {
254  std::abort();
255  }
256 
257  bool isCapped() const {
258  std::abort();
259  }
260 
261  std::shared_ptr<CappedInsertNotifier> getCappedInsertNotifier() const {
262  std::abort();
263  }
264 
265  uint64_t numRecords(OperationContext* opCtx) const {
266  std::abort();
267  }
268 
269  uint64_t dataSize(OperationContext* opCtx) const {
270  std::abort();
271  }
272 
273  uint64_t getIndexSize(OperationContext* opCtx, BSONObjBuilder* details, int scale) {
274  std::abort();
275  }
276 
277  boost::optional<Timestamp> getMinimumVisibleSnapshot() {
278  std::abort();
279  }
280 
281  void setMinimumVisibleSnapshot(Timestamp name) {
282  std::abort();
283  }
284 
286  return false;
287  }
288 
290  std::abort();
291  }
292 
293  const CollatorInterface* getDefaultCollator() const {
294  std::abort();
295  }
296 
298  std::abort();
299  }
300 };
301 } // 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:187
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:236
DatabaseCatalogEntry * dbce() const
Definition: collection_mock.h:50
IndexCatalog * getIndexCatalog()
Definition: collection_mock.h:96
Definition: snapshot.h:69
bool ok() const
Definition: collection_mock.h:71
Definition: record_store.h:671
void deleteDocument(OperationContext *opCtx, StmtId stmtId, const RecordId &loc, OpDebug *opDebug, bool fromMigrate, bool noWarn, Collection::StoreDeletedDoc storeDeletedDoc)
Definition: collection_mock.h:131
Status truncate(OperationContext *opCtx)
Definition: collection_mock.h:199
bool isCapped() const
Definition: collection_mock.h:257
std::unique_ptr< SeekableRecordCursor > getCursor(OperationContext *opCtx, bool forward) const
Definition: collection_mock.h:123
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
StringData getValidationLevel() const
Definition: collection_mock.h:243
Definition: collection_catalog_entry.h:47
const CollatorInterface * getDefaultCollator() const
Definition: collection_mock.h:293
uint64_t numRecords(OperationContext *opCtx) const
Definition: collection_mock.h:265
OperationContext Database StringData BSONObj CollectionOptions::ParseKind bool const BSONObj &idIndex Status
Definition: database_impl.cpp:956
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:111
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:297
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:239
std::shared_ptr< CappedInsertNotifier > getCappedInsertNotifier() const
Definition: collection_mock.h:261
CollectionCatalogEntry * getCatalogEntry()
Definition: collection_mock.h:75
Status insertDocument(OperationContext *opCtx, const InsertStatement &doc, OpDebug *opDebug, bool enforceQuota, bool fromMigrate)
Definition: collection_mock.h:150
Status insertDocument(OperationContext *opCtx, const BSONObj &doc, const std::vector< MultiIndexBlock *> &indexBlocks, bool enforceQuota)
Definition: collection_mock.h:165
void cappedTruncateAfter(OperationContext *opCtx, RecordId end, bool inclusive)
Definition: collection_mock.h:219
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:223
const IndexCatalog * getIndexCatalog() const
Definition: collection_mock.h:93
bool haveCappedWaiters()
Returns true if there may be waiters.
Definition: collection_mock.h:285
boost::optional< Timestamp > getMinimumVisibleSnapshot()
Definition: collection_mock.h:277
CollectionMock(const NamespaceString &ns)
Definition: collection_mock.h:42
const RecordStore * getRecordStore() const
Definition: collection_mock.h:100
Definition: index_key_validate.h:40
Status touch(OperationContext *opCtx, bool touchData, bool touchIndexes, BSONObjBuilder *output) const
Definition: collection_mock.h:212
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:196
bool updateWithDamagesSupported() const
Definition: collection_mock.h:183
void setMinimumVisibleSnapshot(Timestamp name)
Definition: collection_mock.h:281
Status insertDocumentsForOplog(OperationContext *opCtx, const DocWriter *const *docs, Timestamp *timestamps, size_t nDocs)
Definition: collection_mock.h:158
void refreshUUID(OperationContext *opCtx)
Definition: collection_mock.h:89
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:203
OperationContext Database StringData BSONObj options
Definition: database_impl.cpp:949
Snapshotted< BSONObj > docFor(OperationContext *opCtx, const RecordId &loc) const
Definition: collection_mock.h:115
const CollectionCatalogEntry * getCatalogEntry() const
Definition: collection_mock.h:78
Status updateValidator(OperationContext *opCtx, BSONObj newValidator, StringData newLevel, StringData newAction)
Definition: collection_mock.h:250
StringData getValidationAction() const
Definition: collection_mock.h:246
uint64_t getIndexSize(OperationContext *opCtx, BSONObjBuilder *details, int scale)
Definition: collection_mock.h:273
std::vector< std::unique_ptr< RecordCursor > > getManyCursors(OperationContext *opCtx) const
Definition: collection_mock.h:127
void notifyCappedWaitersIfNeeded()
Used to notify any waiters when new documents may be visible in the capped collection.
Definition: collection_mock.h:289
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:269
bool findDoc(OperationContext *opCtx, const RecordId &loc, Snapshotted< BSONObj > *out) const
Definition: collection_mock.h:119
RecordStore * getRecordStore()
Definition: collection_mock.h:103
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:141
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:172
CursorManager * getCursorManager() const
Definition: collection_mock.h:107
Status setValidator(OperationContext *opCtx, BSONObj validator)
Definition: collection_mock.h:232