summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document_source_sequential_document_cache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline/document_source_sequential_document_cache.cpp')
-rw-r--r--src/mongo/db/pipeline/document_source_sequential_document_cache.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/mongo/db/pipeline/document_source_sequential_document_cache.cpp b/src/mongo/db/pipeline/document_source_sequential_document_cache.cpp
index 535c3f5d2be..33c32f096b3 100644
--- a/src/mongo/db/pipeline/document_source_sequential_document_cache.cpp
+++ b/src/mongo/db/pipeline/document_source_sequential_document_cache.cpp
@@ -41,6 +41,7 @@ DocumentSourceSequentialDocumentCache::DocumentSourceSequentialDocumentCache(
const boost::intrusive_ptr<ExpressionContext>& expCtx, SequentialDocumentCache* cache)
: DocumentSource(kStageName, expCtx), _cache(cache) {
invariant(_cache);
+ invariant(!_cache->isAbandoned());
if (_cache->isServing()) {
_cache->restartIteration();
@@ -80,10 +81,9 @@ DocumentSource::GetNextResult DocumentSourceSequentialDocumentCache::doGetNext()
Pipeline::SourceContainer::iterator DocumentSourceSequentialDocumentCache::doOptimizeAt(
Pipeline::SourceContainer::iterator itr, Pipeline::SourceContainer* container) {
- // The DocumentSourceSequentialDocumentCache relies on all other stages in the pipeline being at
- // the final positions which they would have occupied if no cache stage was present. This should
- // be the case when we reach this function. The cache should always be the last stage in the
- // pipeline pre-optimizing.
+ // The DocumentSourceSequentialDocumentCache should always be the last stage in the pipeline
+ // pre-optimization. By the time optimization reaches this point, all preceding stages are in
+ // the final positions which they would have occupied if no cache stage was present.
invariant(_hasOptimizedPos || std::next(itr) == container->end());
invariant((*itr).get() == this);
@@ -96,7 +96,7 @@ Pipeline::SourceContainer::iterator DocumentSourceSequentialDocumentCache::doOpt
_hasOptimizedPos = true;
// If the cache is the only stage in the pipeline, return immediately.
- if (itr == container->begin() && std::next(itr) == container->end()) {
+ if (itr == container->begin()) {
return container->end();
}
@@ -153,12 +153,12 @@ Pipeline::SourceContainer::iterator DocumentSourceSequentialDocumentCache::doOpt
return container->end();
}
-Value DocumentSourceSequentialDocumentCache::serialize(const SerializationOptions& opts) const {
- if (opts.verbosity) {
+Value DocumentSourceSequentialDocumentCache::serialize(
+ boost::optional<ExplainOptions::Verbosity> explain) const {
+ if (explain) {
return Value(Document{
{kStageName,
- Document{{"maxSizeBytes"_sd,
- opts.serializeLiteral(static_cast<long long>(_cache->maxSizeBytes()))},
+ Document{{"maxSizeBytes"_sd, Value(static_cast<long long>(_cache->maxSizeBytes()))},
{"status"_sd,
_cache->isBuilding()
? "kBuilding"_sd