summaryrefslogtreecommitdiff
path: root/src/mongo/db/clientcursor.cpp
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2012-04-19 17:51:54 -0700
committerAaron <aaron@10gen.com>2012-04-19 19:00:21 -0700
commit4a17a039e05076364049d3903da4c6cb5b562c69 (patch)
treea5697ac26342356a0eb04e1eeda3e3b3a9c5058c /src/mongo/db/clientcursor.cpp
parent131dd557b9ea7d7088198c6558bb91d835294693 (diff)
downloadmongo-4a17a039e05076364049d3903da4c6cb5b562c69.tar.gz
SERVER-4980 Add Cursor::keyFieldsOnly() and use it to implement projection in processGetMore via ClientCursor::fillQueryResultFromObject().
Diffstat (limited to 'src/mongo/db/clientcursor.cpp')
-rw-r--r--src/mongo/db/clientcursor.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/db/clientcursor.cpp b/src/mongo/db/clientcursor.cpp
index e31082c9ffb..608c2dd2a10 100644
--- a/src/mongo/db/clientcursor.cpp
+++ b/src/mongo/db/clientcursor.cpp
@@ -32,6 +32,7 @@
#include "../util/processinfo.h"
#include "../util/timer.h"
#include "mongo/client/dbclientinterface.h"
+#include "mongo/db/scanandorder.h"
namespace mongo {
@@ -418,6 +419,17 @@ namespace mongo {
return b.obj();
}
+ void ClientCursor::fillQueryResultFromObj( BufBuilder &b ) const {
+ const Projection::KeyOnly *keyFieldsOnly = c()->keyFieldsOnly();
+ if ( keyFieldsOnly ) {
+ mongo::fillQueryResultFromObj( b, 0, keyFieldsOnly->hydrate( c()->currKey() ) );
+ }
+ else {
+ DiskLoc loc = c()->currLoc();
+ mongo::fillQueryResultFromObj( b, fields.get(), c()->current(),
+ ( ( pq && pq->showDiskLoc() ) ? &loc : 0 ) );
+ }
+ }
/* call when cursor's location changes so that we can update the
cursorsbylocation map. if you are locked and internally iterating, only