summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/planner_access.cpp
diff options
context:
space:
mode:
authorMax Hirschhorn <max.hirschhorn@mongodb.com>2016-06-03 13:26:35 -0400
committerMax Hirschhorn <max.hirschhorn@mongodb.com>2016-06-03 13:26:35 -0400
commitcecbe424d32cbb475d9b0384d29b98a9fba9c89f (patch)
tree0ce2632b078fee8865f15a56cf07c684a8260c21 /src/mongo/db/query/planner_access.cpp
parent8900002b731358b0beedadb2ceb4e3156de402b6 (diff)
downloadmongo-cecbe424d32cbb475d9b0384d29b98a9fba9c89f.tar.gz
SERVER-23114 Move functions involving dotted paths to separate library.
The ability to specify a dotted path (e.g. "a.b") to traverse through embedded objects and array elements isn't defined in the BSON specification and so it doesn't belong in our BSON library. The following functions have been defined within a 'dotted_path_support' namespace and accept an additional BSONObj as their first argument to replace the associated method on the BSONObj class. - extractElementAtPath() is functionally equivalent to BSONObj::getFieldDotted(). - extractElementAtPathOrArrayAlongPath() is functionally equivalent to BSONObj::getFieldDottedOrArray(). - extractAllElementsAlongPath() is functionally equivalent to BSONObj::getFieldsDotted(). - extractElementsBasedOnTemplate() is functionally equivalent to BSONObj::extractFields(). - compareObjectsAccordingToSort() is functionally equivalent to BSONObj::woSortOrder().
Diffstat (limited to 'src/mongo/db/query/planner_access.cpp')
-rw-r--r--src/mongo/db/query/planner_access.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/mongo/db/query/planner_access.cpp b/src/mongo/db/query/planner_access.cpp
index c3172d5387d..349a25b99f7 100644
--- a/src/mongo/db/query/planner_access.cpp
+++ b/src/mongo/db/query/planner_access.cpp
@@ -36,6 +36,7 @@
#include <vector>
#include "mongo/base/owned_pointer_vector.h"
+#include "mongo/db/bson/dotted_path_support.h"
#include "mongo/db/matcher/expression_array.h"
#include "mongo/db/matcher/expression_geo.h"
#include "mongo/db/matcher/expression_text.h"
@@ -52,6 +53,8 @@ namespace {
using namespace mongo;
+namespace dps = ::mongo::dotted_path_support;
+
/**
* Text node functors.
*/
@@ -125,7 +128,7 @@ QuerySolutionNode* QueryPlannerAccess::makeCollectionScan(const CanonicalQuery&
// If the hint is {$natural: +-1} this changes the direction of the collection scan.
if (!query.getParsed().getHint().isEmpty()) {
- BSONElement natural = query.getParsed().getHint().getFieldDotted("$natural");
+ BSONElement natural = dps::extractElementAtPath(query.getParsed().getHint(), "$natural");
if (!natural.eoo()) {
csn->direction = natural.numberInt() >= 0 ? 1 : -1;
}
@@ -135,7 +138,7 @@ QuerySolutionNode* QueryPlannerAccess::makeCollectionScan(const CanonicalQuery&
// direction if both are specified.
const BSONObj& sortObj = query.getParsed().getSort();
if (!sortObj.isEmpty()) {
- BSONElement natural = sortObj.getFieldDotted("$natural");
+ BSONElement natural = dps::extractElementAtPath(sortObj, "$natural");
if (!natural.eoo()) {
csn->direction = natural.numberInt() >= 0 ? 1 : -1;
}