From a79c8cfc2f3d778c9aa11d782b76adeec4624b37 Mon Sep 17 00:00:00 2001 From: Hari Khalsa Date: Thu, 20 Mar 2014 14:57:34 -0400 Subject: SERVER-13292 fast path simple/fully covered projections --- src/mongo/db/exec/projection_exec.cpp | 36 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'src/mongo/db/exec/projection_exec.cpp') diff --git a/src/mongo/db/exec/projection_exec.cpp b/src/mongo/db/exec/projection_exec.cpp index 15a224cbe72..afa60132631 100644 --- a/src/mongo/db/exec/projection_exec.cpp +++ b/src/mongo/db/exec/projection_exec.cpp @@ -249,7 +249,23 @@ namespace mongo { } BSONObjBuilder bob; - if (!requiresDocument()) { + if (member->hasObj()) { + MatchDetails matchDetails; + + // If it's a positional projection we need a MatchDetails. + if (transformRequiresDetails()) { + matchDetails.requestElemMatchKey(); + verify(NULL != _queryExpression); + verify(_queryExpression->matchesBSON(member->obj, &matchDetails)); + } + + Status projStatus = transform(member->obj, &bob, &matchDetails); + if (!projStatus.isOK()) { + return projStatus; + } + } + else { + verify(!requiresDocument()); // Go field by field. if (_includeID) { BSONElement elt; @@ -273,24 +289,6 @@ namespace mongo { } } } - else { - // Planner should have done this. - verify(member->hasObj()); - - MatchDetails matchDetails; - - // If it's a positional projection we need a MatchDetails. - if (transformRequiresDetails()) { - matchDetails.requestElemMatchKey(); - verify(NULL != _queryExpression); - verify(_queryExpression->matchesBSON(member->obj, &matchDetails)); - } - - Status projStatus = transform(member->obj, &bob, &matchDetails); - if (!projStatus.isOK()) { - return projStatus; - } - } for (MetaMap::const_iterator it = _meta.begin(); it != _meta.end(); ++it) { if (META_GEONEAR_DIST == it->second) { -- cgit v1.2.1