From e9170171f9f55e18a2bdf13d8d0b1dbfb2e71b8f Mon Sep 17 00:00:00 2001 From: Dwight Date: Tue, 5 Jul 2011 11:39:36 -0400 Subject: use new index version on reindex command --- bson/bson-inl.h | 11 +++++++++++ bson/bsonobj.h | 5 +++++ db/dbcommands.cpp | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/bson/bson-inl.h b/bson/bson-inl.h index 71b7c50bab7..54431549852 100644 --- a/bson/bson-inl.h +++ b/bson/bson-inl.h @@ -974,4 +974,15 @@ dodouble: assert( ! j.more() ); } + inline BSONObj BSONObj::removeField(const StringData& name) const { + BSONObjBuilder b; + BSONObjIterator i(*this); + while ( i.more() ) { + BSONElement e = i.next(); + const char *fname = e.fieldName(); + if( strcmp(name.data(), fname) ) + b.append(e); + } + return b.obj(); + } } diff --git a/bson/bsonobj.h b/bson/bsonobj.h index 1e0cb9f591b..cb1749142c1 100644 --- a/bson/bsonobj.h +++ b/bson/bsonobj.h @@ -148,6 +148,11 @@ namespace mongo { /** note: addFields always adds _id even if not specified */ int addFields(BSONObj& from, set& fields); /* returns n added */ + /** remove specified field and return a new object with the remaining fields. + slowish as builds a full new object + */ + BSONObj removeField(const StringData& name) const; + /** returns # of top level fields in the object note: iterates to count the fields */ diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp index 8085f1b632b..894fde77664 100644 --- a/db/dbcommands.cpp +++ b/db/dbcommands.cpp @@ -929,7 +929,7 @@ namespace mongo { auto_ptr i = db.getIndexes( toDeleteNs ); BSONObjBuilder b; while ( i->more() ) { - BSONObj o = i->next().getOwned(); + BSONObj o = i->next().removeField("v").getOwned(); b.append( BSONObjBuilder::numStr( all.size() ) , o ); all.push_back( o ); } -- cgit v1.2.1