summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document_source_facet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline/document_source_facet.cpp')
-rw-r--r--src/mongo/db/pipeline/document_source_facet.cpp47
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));
}