• Query Integration
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Overview

      Implement DocumentSourceDocumentResultsAndMetadata::lowerToExecutable() and wire it into run_agg.cpp's prepareExecutorsForPipeline.

      Background

      \$_documentResultsAndMetadata is a transport container. During prepareExecutorsForPipeline in run_agg.cpp, if the pipeline begins with this stage it must be popped and replaced with directly executable stages before the pipeline runs.

      Scope of Work

      Implement DocumentSourceDocumentResultsAndMetadata::lowerToExecutable(Pipeline&):

      • Pop the container from the pipeline front
      • If _metadata == boost::none (elided): prepend _source directly — no Exchange needed
      • Otherwise: construct an exec::agg::Exchange (policy kKeyRange on _streamType, two consumers) wrapping _source; create two DocumentSourceExchange consumers sharing the exchange via intrusive_ptr; append {{\$replaceRoot( {newRoot: "\$payload"}

        )}} after each consumer to unwrap user BSON from the {\$_streamType, payload} envelope

      • For returnCursor = false (standalone): wrap consumer-1 and its \$replaceRoot in DocumentSourceSetVariableFromSubPipeline targeting Variables::kSearchMetaId; prepend consumer-0, \$replaceRoot, then \$setVar to the outer pipeline

      Wire the call in run_agg.cpp:

      if (auto* c = dynamic_cast(pipeline->peekFront()))
          c->lowerToExecutable(*pipeline);
      

      Acceptance Criteria

      • Metadata elided path: _source prepended with no Exchange overhead
      • Standalone path: Exchange + $replaceRoot + $setVar wired correctly
      • $$SEARCH_META is set before any downstream stage reads it
      • Unit tests cover elided and non-elided paths

            Assignee:
            Daniel Segel
            Reporter:
            Daniel Segel
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: