diff options
| author | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-11 15:07:35 -0300 |
|---|---|---|
| committer | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-11 15:07:35 -0300 |
| commit | 4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch) | |
| tree | 1682a647d4463397c119183369ae6f750d5fdcff /src/mongo/db/pipeline/document_source_facet.cpp | |
| parent | aa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff) | |
| parent | 8f0827553e09872941945a093b647a4211a9db7f (diff) | |
Update upstream source from tag 'upstream/6.0.0'master
Update to upstream version '6.0.0'
with Debian dir 5604a80ec1c96ca76f25f40d78e6ef855abec322
Diffstat (limited to 'src/mongo/db/pipeline/document_source_facet.cpp')
| -rw-r--r-- | src/mongo/db/pipeline/document_source_facet.cpp | 47 |
1 files changed, 16 insertions, 31 deletions
diff --git a/src/mongo/db/pipeline/document_source_facet.cpp b/src/mongo/db/pipeline/document_source_facet.cpp index 6dfe8fd0a68..a20d0a1eb0a 100644 --- a/src/mongo/db/pipeline/document_source_facet.cpp +++ b/src/mongo/db/pipeline/document_source_facet.cpp @@ -185,12 +185,11 @@ DocumentSource::GetNextResult DocumentSourceFacet::doGetNext() { return resultDoc.freeze(); } -Value DocumentSourceFacet::serialize(const SerializationOptions& opts) const { +Value DocumentSourceFacet::serialize(boost::optional<ExplainOptions::Verbosity> explain) const { MutableDocument serialized; for (auto&& facet : _facets) { - serialized[opts.serializeFieldPathFromString(facet.name)] = - Value(opts.verbosity ? facet.pipeline->writeExplainOps(opts) - : facet.pipeline->serialize(opts)); + serialized[facet.name] = Value(explain ? facet.pipeline->writeExplainOps(*explain) + : facet.pipeline->serialize()); } return Value(Document{{"$facet", serialized.freezeToValue()}}); } @@ -223,13 +222,6 @@ void DocumentSourceFacet::reattachToOperationContext(OperationContext* opCtx) { } } -bool DocumentSourceFacet::validateOperationContext(const OperationContext* opCtx) const { - return getContext()->opCtx == opCtx && - std::all_of(_facets.begin(), _facets.end(), [opCtx](const auto& f) { - return f.pipeline->validateOperationContext(opCtx); - }); -} - StageConstraints DocumentSourceFacet::constraints(Pipeline::SplitState) const { // Currently we don't split $facet to have a merger part and a shards part (see SERVER-24154). // This means that if any stage in any of the $facet pipelines needs to run on the primary shard @@ -290,8 +282,6 @@ DepsTracker::State DocumentSourceFacet::getDependencies(DepsTracker* deps) const deps->vars.insert(subDepsTracker.vars.begin(), subDepsTracker.vars.end()); deps->needWholeDocument = deps->needWholeDocument || subDepsTracker.needWholeDocument; - // If the subpipeline needs any metadata, the top level pipeline must know to generate it. - deps->metadataDeps() |= subDepsTracker.metadataDeps(); // The text score is the only type of metadata that could be needed by $facet. deps->setNeedsMetadata( @@ -337,25 +327,20 @@ intrusive_ptr<DocumentSource> DocumentSourceFacet::createFromBson( }); }); - // These checks potentially require that we check the catalog to determine where our data - // lives. In circumstances where we aren't actually running the query, we don't need to do - // this (and it can erroneously error - SERVER-83912). - if (expCtx->mongoProcessInterface->isExpectedToExecuteQueries()) { - // Validate that none of the facet pipelines have any conflicting HostTypeRequirements. - // This verifies both that all stages within each pipeline are consistent, and that the - // pipelines are consistent with one another. - if (!needsShard && pipeline->needsShard()) { - needsShard.emplace(facetName); - } - if (!needsMongoS && pipeline->needsMongosMerger()) { - needsMongoS.emplace(facetName); - } - uassert(ErrorCodes::IllegalOperation, - str::stream() << "$facet pipeline '" << *needsMongoS - << "' must run on mongoS, but '" << *needsShard - << "' requires a shard", - !(needsShard && needsMongoS)); + // Validate that none of the facet pipelines have any conflicting HostTypeRequirements. This + // verifies both that all stages within each pipeline are consistent, and that the pipelines + // are consistent with one another. + if (!needsShard && pipeline->needsShard()) { + needsShard.emplace(facetName); + } + if (!needsMongoS && pipeline->needsMongosMerger()) { + needsMongoS.emplace(facetName); } + uassert(ErrorCodes::IllegalOperation, + str::stream() << "$facet pipeline '" << *needsMongoS + << "' must run on mongoS, but '" << *needsShard + << "' requires a shard", + !(needsShard && needsMongoS)); facetPipelines.emplace_back(facetName, std::move(pipeline)); } |
