Storage Engine API
namespace_details_collection_entry.h
Go to the documentation of this file.
1 // namespace_details_collection_entry.h
2 
3 #pragma once
4 
33 #include "mongo/base/string_data.h"
34 #include "mongo/bson/bsonobj.h"
36 #include "mongo/db/server_options.h"
38 
39 namespace mongo {
40 
41 class NamespaceDetails;
42 
43 class MMAPV1DatabaseCatalogEntry;
44 ;
45 class RecordStore;
46 class OperationContext;
47 
49 public:
52  RecordStore* namespacesRecordStore,
53  RecordId namespacesRecordId,
54  RecordStore* indexRecordStore,
56 
58 
59  CollectionOptions getCollectionOptions(OperationContext* opCtx) const final;
60 
61  int getTotalIndexCount(OperationContext* opCtx) const final;
62 
63  int getCompletedIndexCount(OperationContext* opCtx) const final;
64 
65  int getMaxAllowedIndexes() const final;
66 
67  void getAllIndexes(OperationContext* opCtx, std::vector<std::string>* names) const final;
68 
69  void getReadyIndexes(OperationContext* opCtx, std::vector<std::string>* names) const final;
70 
71  BSONObj getIndexSpec(OperationContext* opCtx, StringData idxName) const final;
72 
73  bool isIndexMultikey(OperationContext* opCtx,
74  StringData indexName,
75  MultikeyPaths* multikeyPaths) const final;
76  bool isIndexMultikey(int idxNo) const;
77 
78  bool setIndexIsMultikey(OperationContext* opCtx, int idxNo, bool multikey = true);
79  bool setIndexIsMultikey(OperationContext* opCtx,
80  StringData indexName,
81  const MultikeyPaths& multikeyPaths) final;
82 
83  RecordId getIndexHead(OperationContext* opCtx, StringData indexName) const final;
84 
85  void setIndexHead(OperationContext* opCtx, StringData indexName, const RecordId& newHead) final;
86 
87  bool isIndexReady(OperationContext* opCtx, StringData indexName) const final;
88 
89  KVPrefix getIndexPrefix(OperationContext* opCtx, StringData indexName) const final;
90 
91  Status removeIndex(OperationContext* opCtx, StringData indexName) final;
92 
93  Status prepareForIndexBuild(OperationContext* opCtx,
94  const IndexDescriptor* spec,
95  bool isBackgroundSecondaryBuild) final;
96 
97  void indexBuildSuccess(OperationContext* opCtx, StringData indexName) final;
98 
99  void updateTTLSetting(OperationContext* opCtx,
100  StringData idxName,
101  long long newExpireSeconds) final;
102 
103  void updateFlags(OperationContext* opCtx, int newValue) final;
104 
105  bool isEqualToMetadataUUID(OperationContext* opCtx, OptionalCollectionUUID uuid);
106 
107  void updateValidator(OperationContext* opCtx,
108  const BSONObj& validator,
109  StringData validationLevel,
110  StringData validationAction) final;
111 
112  void setIsTemp(OperationContext* opCtx, bool isTemp) final;
113 
114  void updateCappedSize(OperationContext* opCtx, long long size) final;
115 
116  // not part of interface, but available to my storage engine
117 
118  int _findIndexNumber(OperationContext* opCtx, StringData indexName) const;
119 
121  return _namespacesRecordId;
122  }
123 
127  void setNamespacesRecordId(OperationContext* opCtx, RecordId newId);
128 
129 private:
132 
133  // Where this entry lives in the _namespacesRecordStore.
135 
138 
143  void _updateSystemNamespaces(OperationContext* opCtx, const BSONObj& update);
144 
146 };
147 }
void updateValidator(OperationContext *opCtx, const BSONObj &validator, StringData validationLevel, StringData validationAction) final
Updates the validator for this collection.
Definition: namespace_details_collection_entry.cpp:448
void updateCappedSize(OperationContext *opCtx, long long size) final
Updates size of a capped Collection.
Definition: namespace_details_collection_entry.cpp:484
RecordStore * _namespacesRecordStore
Definition: namespace_details_collection_entry.h:131
Collection *const OperationContext *const const StringData OptionalCollectionUUID CollectionCatalogEntry *const details
Definition: collection_impl.cpp:80
Definition: collection_options.h:57
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
NamespaceDetailsCollectionCatalogEntry(StringData ns, NamespaceDetails *details, RecordStore *namespacesRecordStore, RecordId namespacesRecordId, RecordStore *indexRecordStore, MMAPV1DatabaseCatalogEntry *db)
Definition: namespace_details_collection_entry.cpp:53
Definition: collection_catalog_entry.h:47
bool isIndexReady(OperationContext *opCtx, StringData indexName) const final
Definition: namespace_details_collection_entry.cpp:196
int _findIndexNumber(OperationContext *opCtx, StringData indexName) const
Definition: namespace_details_collection_entry.cpp:208
void setIsTemp(OperationContext *opCtx, bool isTemp) final
Updates the 'temp' setting for this collection.
Definition: namespace_details_collection_entry.cpp:460
int getTotalIndexCount(OperationContext *opCtx) const final
Definition: namespace_details_collection_entry.cpp:88
void getReadyIndexes(OperationContext *opCtx, std::vector< std::string > *names) const final
Definition: namespace_details_collection_entry.cpp:110
void setIndexHead(OperationContext *opCtx, StringData indexName, const RecordId &newHead) final
Definition: namespace_details_collection_entry.cpp:188
MMAPV1DatabaseCatalogEntry * _db
Definition: namespace_details_collection_entry.h:137
CollectionOptions getCollectionOptions(OperationContext *opCtx) const final
Definition: namespace_details_collection_entry.cpp:68
Definition: namespace_details_collection_entry.h:48
NamespaceDetails * _details
Definition: namespace_details_collection_entry.h:130
void updateTTLSetting(OperationContext *opCtx, StringData idxName, long long newExpireSeconds) final
Definition: namespace_details_collection_entry.cpp:361
Definition: namespace_details.h:47
void updateFlags(OperationContext *opCtx, int newValue) final
Sets the flags field of CollectionOptions to newValue.
Definition: namespace_details_collection_entry.cpp:425
Status prepareForIndexBuild(OperationContext *opCtx, const IndexDescriptor *spec, bool isBackgroundSecondaryBuild) final
Definition: namespace_details_collection_entry.cpp:292
OperationContext Database StringData CollectionOptions bool const BSONObj &idIndex Status
Definition: database_impl.cpp:955
boost::optional< CollectionUUID > OptionalCollectionUUID
Definition: collection_options.h:55
RecordId getNamespacesRecordId()
Definition: namespace_details_collection_entry.h:120
KVPrefix getIndexPrefix(OperationContext *opCtx, StringData indexName) const final
Definition: namespace_details_collection_entry.cpp:203
Collection *const OperationContext *const const StringData OptionalCollectionUUID uuid
Definition: collection_impl.cpp:80
void setNamespacesRecordId(OperationContext *opCtx, RecordId newId)
'opCtx' is only allowed to be null when called from the constructor.
Definition: namespace_details_collection_entry.cpp:465
int getMaxAllowedIndexes() const final
Definition: namespace_details_collection_entry.cpp:96
void getAllIndexes(OperationContext *opCtx, std::vector< std::string > *names) const final
Definition: namespace_details_collection_entry.cpp:100
bool isEqualToMetadataUUID(OperationContext *opCtx, OptionalCollectionUUID uuid)
Compare the UUID argument to the UUID obtained from the metadata.
Definition: namespace_details_collection_entry.cpp:431
An abstraction used for storing documents in a collection or entries in an index.
Definition: record_store.h:282
int getCompletedIndexCount(OperationContext *opCtx) const final
Definition: namespace_details_collection_entry.cpp:92
void _updateSystemNamespaces(OperationContext *opCtx, const BSONObj &update)
Updates the entry for this namespace in '_namespacesRecordStore', updating '_namespacesRecordId' if n...
Definition: namespace_details_collection_entry.cpp:396
OperationContext Database * db
Definition: database_impl.cpp:949
bool isIndexMultikey(OperationContext *opCtx, StringData indexName, MultikeyPaths *multikeyPaths) const final
Returns true if the index identified by 'indexName' is multikey, and returns false otherwise.
Definition: namespace_details_collection_entry.cpp:123
void indexBuildSuccess(OperationContext *opCtx, StringData indexName) final
Definition: namespace_details_collection_entry.cpp:330
~NamespaceDetailsCollectionCatalogEntry()
Definition: namespace_details_collection_entry.h:57
A KVPrefix may be prepended to the keys of entries in an underlying KV store.
Definition: kv_prefix.h:44
RecordId _namespacesRecordId
Definition: namespace_details_collection_entry.h:134
Collection *const OperationContext *const opCtx
Definition: collection_impl.cpp:80
RecordId getIndexHead(OperationContext *opCtx, StringData indexName) const final
Definition: namespace_details_collection_entry.cpp:173
Definition: mmap_v1_database_catalog_entry.h:54
BSONObj getIndexSpec(OperationContext *opCtx, StringData idxName) const final
Definition: namespace_details_collection_entry.cpp:180
RecordStore * _indexRecordStore
Definition: namespace_details_collection_entry.h:136
const NamespaceString & ns() const
Definition: collection_catalog_entry.h:52
bool setIndexIsMultikey(OperationContext *opCtx, int idxNo, bool multikey=true)
Definition: namespace_details_collection_entry.cpp:147
Status removeIndex(OperationContext *opCtx, StringData indexName) final
Definition: namespace_details_collection_entry.cpp:243