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  void addUUID(OperationContext* opCtx, CollectionUUID uuid, Collection* coll) final;
106 
107  bool isEqualToMetadataUUID(OperationContext* opCtx, OptionalCollectionUUID uuid);
108 
109  void updateValidator(OperationContext* opCtx,
110  const BSONObj& validator,
111  StringData validationLevel,
112  StringData validationAction) final;
113 
114  void setIsTemp(OperationContext* opCtx, bool isTemp) final;
115 
116  void updateCappedSize(OperationContext* opCtx, long long size) final;
117 
118  // not part of interface, but available to my storage engine
119 
120  int _findIndexNumber(OperationContext* opCtx, StringData indexName) const;
121 
123  return _namespacesRecordId;
124  }
125 
129  void setNamespacesRecordId(OperationContext* opCtx, RecordId newId);
130 
131 private:
134 
135  // Where this entry lives in the _namespacesRecordStore.
137 
140 
145  void _updateSystemNamespaces(OperationContext* opCtx, const BSONObj& update);
146 
148 };
149 }
void updateValidator(OperationContext *opCtx, const BSONObj &validator, StringData validationLevel, StringData validationAction) final
Updates the validator for this collection.
Definition: namespace_details_collection_entry.cpp:469
void updateCappedSize(OperationContext *opCtx, long long size) final
Updates size of a capped Collection.
Definition: namespace_details_collection_entry.cpp:505
RecordStore * _namespacesRecordStore
Definition: namespace_details_collection_entry.h:133
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
OperationContext Database StringData BSONObj CollectionOptions::ParseKind bool const BSONObj &idIndex Status
Definition: database_impl.cpp:956
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 &#39;temp&#39; setting for this collection.
Definition: namespace_details_collection_entry.cpp:481
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 addUUID(OperationContext *opCtx, CollectionUUID uuid, Collection *coll) final
Assigns a new UUID to this collection.
Definition: namespace_details_collection_entry.cpp:431
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:139
CollectionOptions getCollectionOptions(OperationContext *opCtx) const final
Definition: namespace_details_collection_entry.cpp:68
Definition: namespace_details_collection_entry.h:48
UUID CollectionUUID
A CollectionUUID is a 128-bit unique identifier, per RFC 4122, v4.
Definition: collection_options.h:53
NamespaceDetails * _details
Definition: namespace_details_collection_entry.h:132
void updateTTLSetting(OperationContext *opCtx, StringData idxName, long long newExpireSeconds) final
Definition: namespace_details_collection_entry.cpp:361
this is NOT safe through a yield right now.
Definition: collection.h:160
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
boost::optional< CollectionUUID > OptionalCollectionUUID
Definition: collection_options.h:55
RecordId getNamespacesRecordId()
Definition: namespace_details_collection_entry.h:122
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)
&#39;opCtx&#39; is only allowed to be null when called from the constructor.
Definition: namespace_details_collection_entry.cpp:486
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:452
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 &#39;_namespacesRecordStore&#39;, updating &#39;_namespacesRecordId&#39; 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 &#39;indexName&#39; 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:136
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:138
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