diff options
author | Benjamin Murphy <benjamin_murphy@me.com> | 2016-02-10 17:24:21 -0500 |
---|---|---|
committer | Benjamin Murphy <benjamin_murphy@me.com> | 2016-03-24 11:05:32 -0400 |
commit | f4bbde02bab191cdba4195ec9ad73c60d4aece41 (patch) | |
tree | ce812891454e6d5ed946813452685f7590b8efbf /src/mongo/db/pipeline/document_source.cpp | |
parent | f40294818ce8690f1a485ca32ea52e33e137b7ea (diff) | |
download | mongo-f4bbde02bab191cdba4195ec9ad73c60d4aece41.tar.gz |
SERVER-4507 Group stages now take advantage of sorted input sequences.
Diffstat (limited to 'src/mongo/db/pipeline/document_source.cpp')
-rw-r--r-- | src/mongo/db/pipeline/document_source.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/mongo/db/pipeline/document_source.cpp b/src/mongo/db/pipeline/document_source.cpp index da3ec5fb33c..41c22e1ecb8 100644 --- a/src/mongo/db/pipeline/document_source.cpp +++ b/src/mongo/db/pipeline/document_source.cpp @@ -99,4 +99,19 @@ void DocumentSource::serializeToArray(vector<Value>& array, bool explain) const array.push_back(entry); } } + +BSONObjSet DocumentSource::allPrefixes(BSONObj obj) { + BSONObjSet out; + + BSONObj last = {}; + for (auto&& field : obj) { + BSONObjBuilder builder(last.objsize() + field.size()); + builder.appendElements(last); + builder.append(field); + last = builder.obj(); + out.insert(last); + } + + return out; +} } |