BSONObj getKey( const BSONObj& obj , const BSONObj& keyPattern , ScriptingFunction func , double avgSize , Scope * s ) { if ( func ) { BSONObjBuilder b( obj.objsize() + 32 ); b.append( "0" , obj ); int res = s->invoke( func , b.obj() ); uassert( 10041 , (string)"invoke failed in $keyf: " + s->getError() , res == 0 ); int type = s->type("return"); uassert( 10042 , "return of $key has to be an object" , type == Object ); return s->getObject( "return" ); } return obj.extractFields( keyPattern , true ); }
bool ShardChunkManager::belongsToMe( const BSONObj& obj ) const { if ( _rangesMap.size() == 0 ) return false; return _belongsToMe( obj.extractFields( _key , true ) ); }