summaryrefslogtreecommitdiff
path: root/src/mongo/db/index/index_descriptor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/index/index_descriptor.cpp')
-rw-r--r--src/mongo/db/index/index_descriptor.cpp89
1 files changed, 41 insertions, 48 deletions
diff --git a/src/mongo/db/index/index_descriptor.cpp b/src/mongo/db/index/index_descriptor.cpp
index 523b778163d..9d0de13b4d1 100644
--- a/src/mongo/db/index/index_descriptor.cpp
+++ b/src/mongo/db/index/index_descriptor.cpp
@@ -35,61 +35,54 @@
namespace mongo {
- namespace {
- void populateOptionsMap( std::map<StringData, BSONElement>& theMap,
- const BSONObj& spec ) {
-
- BSONObjIterator it( spec );
- while ( it.more() ) {
- const BSONElement e = it.next();
-
- StringData fieldName = e.fieldNameStringData();
- if ( fieldName == "key" ||
- fieldName == "ns" ||
- fieldName == "name" ||
- fieldName == "v" || // not considered for equivalence
- fieldName == "textIndexVersion" || // same as "v"
- fieldName == "2dsphereIndexVersion" || // same as "v"
- fieldName == "background" || // this is a creation time option only
- fieldName == "dropDups" || // this is now ignored
- fieldName == "sparse" || // checked specially
- fieldName == "unique" // check specially
- ) {
- continue;
- }
- theMap[ fieldName ] = e;
- }
+namespace {
+void populateOptionsMap(std::map<StringData, BSONElement>& theMap, const BSONObj& spec) {
+ BSONObjIterator it(spec);
+ while (it.more()) {
+ const BSONElement e = it.next();
+
+ StringData fieldName = e.fieldNameStringData();
+ if (fieldName == "key" || fieldName == "ns" || fieldName == "name" ||
+ fieldName == "v" || // not considered for equivalence
+ fieldName == "textIndexVersion" || // same as "v"
+ fieldName == "2dsphereIndexVersion" || // same as "v"
+ fieldName == "background" || // this is a creation time option only
+ fieldName == "dropDups" || // this is now ignored
+ fieldName == "sparse" || // checked specially
+ fieldName == "unique" // check specially
+ ) {
+ continue;
}
+ theMap[fieldName] = e;
}
+}
+}
- bool IndexDescriptor::areIndexOptionsEquivalent( const IndexDescriptor* other ) const {
-
- if ( isSparse() != other->isSparse() ) {
- return false;
- }
-
- if ( !isIdIndex() &&
- unique() != other->unique() ) {
- // Note: { _id: 1 } or { _id: -1 } implies unique: true.
- return false;
- }
+bool IndexDescriptor::areIndexOptionsEquivalent(const IndexDescriptor* other) const {
+ if (isSparse() != other->isSparse()) {
+ return false;
+ }
- // Then compare the rest of the options.
+ if (!isIdIndex() && unique() != other->unique()) {
+ // Note: { _id: 1 } or { _id: -1 } implies unique: true.
+ return false;
+ }
- std::map<StringData, BSONElement> existingOptionsMap;
- populateOptionsMap( existingOptionsMap, infoObj() );
+ // Then compare the rest of the options.
- std::map<StringData, BSONElement> newOptionsMap;
- populateOptionsMap( newOptionsMap, other->infoObj() );
+ std::map<StringData, BSONElement> existingOptionsMap;
+ populateOptionsMap(existingOptionsMap, infoObj());
- return existingOptionsMap == newOptionsMap;
- }
+ std::map<StringData, BSONElement> newOptionsMap;
+ populateOptionsMap(newOptionsMap, other->infoObj());
- void IndexDescriptor::_checkOk() const {
- if ( _magic == 123987 )
- return;
- log() << "uh oh: " << (void*)(this) << " " << _magic;
- invariant(0);
- }
+ return existingOptionsMap == newOptionsMap;
+}
+void IndexDescriptor::_checkOk() const {
+ if (_magic == 123987)
+ return;
+ log() << "uh oh: " << (void*)(this) << " " << _magic;
+ invariant(0);
+}
}