diff options
author | Jason Rassi <rassi@10gen.com> | 2014-09-19 16:12:05 -0400 |
---|---|---|
committer | Jason Rassi <rassi@10gen.com> | 2014-09-22 13:38:51 -0400 |
commit | ad1dafb013342faae7e998586a0c35b70ba75636 (patch) | |
tree | e73b3d1d5ce3941d2d2484c026a6f6dcf7990911 /src/mongo/db/query/query_solution.cpp | |
parent | 5376c8ad356acc9e43e0b5e1c6cda995ea209ddf (diff) | |
download | mongo-ad1dafb013342faae7e998586a0c35b70ba75636.tar.gz |
SERVER-15287 Can't use index key pattern plugin fields to provide sort
Diffstat (limited to 'src/mongo/db/query/query_solution.cpp')
-rw-r--r-- | src/mongo/db/query/query_solution.cpp | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/src/mongo/db/query/query_solution.cpp b/src/mongo/db/query/query_solution.cpp index 3e042cb2b7c..34a98a46d9c 100644 --- a/src/mongo/db/query/query_solution.cpp +++ b/src/mongo/db/query/query_solution.cpp @@ -26,10 +26,12 @@ * it in the license file. */ -#include "mongo/db/index_names.h" #include "mongo/db/query/query_solution.h" -#include "mongo/db/query/lite_parsed_query.h" + +#include "mongo/db/index_names.h" #include "mongo/db/matcher/expression_geo.h" +#include "mongo/db/query/planner_analysis.h" +#include "mongo/db/query/query_planner_common.h" namespace mongo { @@ -454,23 +456,11 @@ namespace mongo { void IndexScanNode::computeProperties() { _sorts.clear(); - BSONObj sortPattern; - { - BSONObjBuilder sortBob; - BSONObj normalizedIndexKeyPattern(LiteParsedQuery::normalizeSortOrder(indexKeyPattern)); - BSONObjIterator it(normalizedIndexKeyPattern); - while (it.more()) { - BSONElement elt = it.next(); - // Zero is returned if elt is not a number. This happens when elt is hashed or - // 2dsphere, our two projection indices. We want to drop those from the sort - // pattern. - int val = elt.numberInt() * direction; - if (0 != val) { - sortBob.append(elt.fieldName(), val); - } - } - sortPattern = sortBob.obj(); + BSONObj sortPattern = QueryPlannerAnalysis::getSortPattern(indexKeyPattern); + if (direction == -1) { + sortPattern = QueryPlannerCommon::reverseSortObj(sortPattern); } + _sorts.insert(sortPattern); const int nFields = sortPattern.nFields(); |