diff options
-rw-r--r-- | db/clientcursor.cpp | 24 | ||||
-rw-r--r-- | db/clientcursor.h | 7 |
2 files changed, 31 insertions, 0 deletions
diff --git a/db/clientcursor.cpp b/db/clientcursor.cpp index beea31b8be5..bc0945714e5 100644 --- a/db/clientcursor.cpp +++ b/db/clientcursor.cpp @@ -310,6 +310,30 @@ namespace mongo { return true; } + BSONElement ClientCursor::getFieldDotted( const string& name , bool * fromKey ) { + + map<string,int>::const_iterator i = _indexedFields.find( name ); + if ( i == _indexedFields.end() ) { + if ( fromKey ) + *fromKey = false; + return current().getFieldDotted( name ); + } + + int x = i->second; + + BSONObjIterator it( currKey() ); + while ( x && it.more() ) { + it.next(); + x--; + } + assert( x == 0 ); + + if ( fromKey ) + *fromKey = true; + return it.next(); + } + + /* call when cursor's location changes so that we can update the cursorsbylocation map. if you are locked and internally iterating, only need to call when you are ready to "unlock". diff --git a/db/clientcursor.h b/db/clientcursor.h index ef50f500517..c585bb25663 100644 --- a/db/clientcursor.h +++ b/db/clientcursor.h @@ -236,6 +236,13 @@ namespace mongo { */ bool getFieldsDotted( const string& name, BSONElementSet &ret ); + /** + * same as BSONObj::getFieldDotted + * if it can be retrieved from key, it is + * @return if this was retrieved from key + */ + BSONElement getFieldDotted( const string& name , bool * fromKey = 0 ); + bool currentIsDup() { return _c->getsetdup( _c->currLoc() ); } bool currentMatches() { |