summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document_source_lookup.cpp
diff options
context:
space:
mode:
authorDianna Hohensee <dianna.hohensee@10gen.com>2016-05-18 09:36:43 -0400
committerDianna Hohensee <dianna.hohensee@10gen.com>2016-05-18 09:36:43 -0400
commit1290f33574da2e129bd3f5471dd06f2e761c74ee (patch)
treec19c78b55d5bbed58ecdba4823961ac9a5a62848 /src/mongo/db/pipeline/document_source_lookup.cpp
parent086c70118d9e98f67beac16b87db93888f6be452 (diff)
downloadmongo-1290f33574da2e129bd3f5471dd06f2e761c74ee.tar.gz
Revert "SERVER-23833 DocumentSourceLookup::getOutputSorts correctly truncates input sort set."
This reverts commit 44abb8db32a6fad705854793e397961dfc72d09e. Unit tests QueuedDataStageTest and SortStageTest are failing.
Diffstat (limited to 'src/mongo/db/pipeline/document_source_lookup.cpp')
-rw-r--r--src/mongo/db/pipeline/document_source_lookup.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/mongo/db/pipeline/document_source_lookup.cpp b/src/mongo/db/pipeline/document_source_lookup.cpp
index c4e6b72947a..a3e7f29ec77 100644
--- a/src/mongo/db/pipeline/document_source_lookup.cpp
+++ b/src/mongo/db/pipeline/document_source_lookup.cpp
@@ -326,6 +326,32 @@ BSONObj DocumentSourceLookUp::queryForInput(const Document& input,
return query.obj();
}
+BSONObjSet DocumentSourceLookUp::getOutputSorts() {
+ BSONObjSet out;
+
+ BSONObjSet inputSort = pSource->getOutputSorts();
+ std::string asPath = _as.getPath(false);
+
+ for (auto&& sortObj : inputSort) {
+ // Truncate each sortObj at the '_as' path.
+ BSONObjBuilder outputSort;
+
+ for (BSONElement fieldSort : sortObj) {
+ if (fieldSort.fieldNameStringData() == asPath) {
+ break;
+ }
+ outputSort.append(fieldSort);
+ }
+
+ BSONObj outSortObj = outputSort.obj();
+ if (!outSortObj.isEmpty()) {
+ out.insert(outSortObj);
+ }
+ }
+
+ return out;
+}
+
boost::optional<Document> DocumentSourceLookUp::unwindResult() {
const boost::optional<FieldPath> indexPath(_unwindSrc->indexPath());