diff options
author | Charlie Swanson <cswanson310@gmail.com> | 2016-08-29 10:06:41 -0400 |
---|---|---|
committer | Charlie Swanson <cswanson310@gmail.com> | 2016-09-01 14:08:25 -0400 |
commit | b1014fe1b40a69cd90b27cb336a170317eecc6b7 (patch) | |
tree | c189d2d931cdfbdec83359f08cbb1639c1d5e254 /src/mongo/db/pipeline/document_source_redact.cpp | |
parent | d289e240b653e70a7d90be885a3ad6de21b7c6cb (diff) | |
download | mongo-b1014fe1b40a69cd90b27cb336a170317eecc6b7.tar.gz |
SERVER-24153 Allow pipelines within $facet stage to process in batches.
This approach removes the need to buffer all documents in memory, thus
removing concerns about spilling intermediate results to disk.
Diffstat (limited to 'src/mongo/db/pipeline/document_source_redact.cpp')
-rw-r--r-- | src/mongo/db/pipeline/document_source_redact.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/mongo/db/pipeline/document_source_redact.cpp b/src/mongo/db/pipeline/document_source_redact.cpp index 3155037aa20..4bd685a8382 100644 --- a/src/mongo/db/pipeline/document_source_redact.cpp +++ b/src/mongo/db/pipeline/document_source_redact.cpp @@ -56,16 +56,17 @@ static const Value descendVal = Value("descend"); static const Value pruneVal = Value("prune"); static const Value keepVal = Value("keep"); -boost::optional<Document> DocumentSourceRedact::getNext() { - while (boost::optional<Document> in = pSource->getNext()) { - _variables->setRoot(*in); - _variables->setValue(_currentId, Value(*in)); +DocumentSource::GetNextResult DocumentSourceRedact::getNext() { + auto nextInput = pSource->getNext(); + for (; nextInput.isAdvanced(); nextInput = pSource->getNext()) { + _variables->setRoot(nextInput.getDocument()); + _variables->setValue(_currentId, Value(nextInput.releaseDocument())); if (boost::optional<Document> result = redactObject()) { - return result; + return std::move(*result); } } - return boost::none; + return nextInput; } Pipeline::SourceContainer::iterator DocumentSourceRedact::optimizeAt( |