summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/planner_access.cpp
diff options
context:
space:
mode:
authorHari Khalsa <hkhalsa@10gen.com>2013-12-03 14:56:44 -0500
committerHari Khalsa <hkhalsa@10gen.com>2013-12-04 10:38:21 -0500
commitf24b3bb577003137f7fd40f0699e144df998bd58 (patch)
treef86aaef57a7685c9f63a3edf4c5887c1436dff3b /src/mongo/db/query/planner_access.cpp
parent19ebc49d3fb30492378fe67aeba4efbb259c45a0 (diff)
downloadmongo-f24b3bb577003137f7fd40f0699e144df998bd58.tar.gz
SERVER-10026 support max/min in new sys
Diffstat (limited to 'src/mongo/db/query/planner_access.cpp')
-rw-r--r--src/mongo/db/query/planner_access.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/mongo/db/query/planner_access.cpp b/src/mongo/db/query/planner_access.cpp
index 132afb7de64..badf67ad48a 100644
--- a/src/mongo/db/query/planner_access.cpp
+++ b/src/mongo/db/query/planner_access.cpp
@@ -867,6 +867,7 @@ namespace mongo {
}
// static
+
void QueryPlannerAccess::_addFilterToSolutionNode(QuerySolutionNode* node,
MatchExpression* match,
MatchExpression::MatchType type) {
@@ -900,4 +901,42 @@ namespace mongo {
}
}
+ QuerySolutionNode* QueryPlannerAccess::makeIndexScan(const IndexEntry& index,
+ const CanonicalQuery& query,
+ const QueryPlannerParams& params,
+ const BSONObj& startKey,
+ const BSONObj& endKey) {
+ QuerySolutionNode* solnRoot = NULL;
+
+ // Build an ixscan over the id index, use it, and return it.
+ IndexScanNode* isn = new IndexScanNode();
+ isn->indexKeyPattern = index.keyPattern;
+ isn->indexIsMultiKey = index.multikey;
+ isn->direction = 1;
+ isn->maxScan = query.getParsed().getMaxScan();
+ isn->bounds.isSimpleRange = true;
+ isn->bounds.startKey = startKey;
+ isn->bounds.endKey = endKey;
+ isn->bounds.endKeyInclusive = false;
+
+ MatchExpression* filter = query.root()->shallowClone();
+
+ // If it's find({}) remove the no-op root.
+ if (MatchExpression::AND == filter->matchType() && (0 == filter->numChildren())) {
+ // XXX wasteful fix
+ delete filter;
+ solnRoot = isn;
+ }
+ else {
+ // TODO: We may not need to do the fetch if the predicates in root are covered. But
+ // for now it's safe (though *maybe* slower).
+ FetchNode* fetch = new FetchNode();
+ fetch->filter.reset(filter);
+ fetch->children.push_back(isn);
+ solnRoot = fetch;
+ }
+
+ return solnRoot;
+ }
+
} // namespace mongo