bool touch( std::string& ns, std::string& errmsg, bool touch_data, bool touch_indexes, BSONObjBuilder& result ) { if (touch_data) { log() << "touching namespace " << ns << endl; touchNs( ns ); log() << "touching namespace " << ns << " complete" << endl; } if (touch_indexes) { // enumerate indexes std::vector< std::string > indexes; { Client::ReadContext ctx(ns); NamespaceDetails *nsd = nsdetails(ns); massert( 16153, "namespace does not exist", nsd ); NamespaceDetails::IndexIterator ii = nsd->ii(); while ( ii.more() ) { IndexDetails& idx = ii.next(); indexes.push_back( idx.indexNamespace() ); } } for ( std::vector<std::string>::const_iterator it = indexes.begin(); it != indexes.end(); it++ ) { touchNs( *it ); } } return true; }
bool touch( std::string& ns, std::string& errmsg, bool touch_data, bool touch_indexes, BSONObjBuilder& result ) { if (touch_data) { log() << "touching namespace " << ns << endl; Timer t; int numRanges = touchNs( ns ); result.append( "data", BSON( "numRanges" << numRanges << "millis" << t.millis() ) ); log() << "touching namespace " << ns << " complete" << endl; } if (touch_indexes) { Timer t; // enumerate indexes std::vector< std::string > indexes; { Client::ReadContext ctx(ns); NamespaceDetails *nsd = nsdetails(ns); massert( 16153, "namespace does not exist", nsd ); NamespaceDetails::IndexIterator ii = nsd->ii(); while ( ii.more() ) { IndexDetails& idx = ii.next(); indexes.push_back( idx.indexNamespace() ); } } int numRanges = 0; for ( std::vector<std::string>::const_iterator it = indexes.begin(); it != indexes.end(); it++ ) { numRanges += touchNs( *it ); } result.append( "indexes", BSON( "num" << static_cast<int>(indexes.size()) << "numRanges" << numRanges << "millis" << t.millis() ) ); } return true; }