diff options
author | Dwight <dwight@10gen.com> | 2011-07-05 11:39:36 -0400 |
---|---|---|
committer | Dwight <dwight@10gen.com> | 2011-07-05 11:39:36 -0400 |
commit | e9170171f9f55e18a2bdf13d8d0b1dbfb2e71b8f (patch) | |
tree | c63e92eb5577a1e6780fb482e3f4e4de6ce385f7 | |
parent | 611a71264a008ff8c53a3c37ea4e092a72b78258 (diff) | |
download | mongo-e9170171f9f55e18a2bdf13d8d0b1dbfb2e71b8f.tar.gz |
use new index version on reindex command
-rw-r--r-- | bson/bson-inl.h | 11 | ||||
-rw-r--r-- | bson/bsonobj.h | 5 | ||||
-rw-r--r-- | db/dbcommands.cpp | 2 |
3 files changed, 17 insertions, 1 deletions
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<string>& 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<DBClientCursor> 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 ); } |