mirror of https://github.com/mongodb/mongo
SERVER-113442: Add PathArrayness to ExpCtx in find_cmd for main collection (#43741)
GitOrigin-RevId: 65ff07f82713f35638925be185ce4847b9e3603b
This commit is contained in:
parent
b74a970571
commit
1044486adf
|
|
@ -73,6 +73,7 @@
|
|||
#include "mongo/db/query/client_cursor/cursor_response.h"
|
||||
#include "mongo/db/query/collation/collator_factory_interface.h"
|
||||
#include "mongo/db/query/collation/collator_interface.h"
|
||||
#include "mongo/db/query/collection_query_info.h"
|
||||
#include "mongo/db/query/compiler/parsers/matcher/expression_parser.h"
|
||||
#include "mongo/db/query/explain.h"
|
||||
#include "mongo/db/query/explain_diagnostic_printer.h"
|
||||
|
|
@ -188,9 +189,12 @@ std::unique_ptr<CanonicalQuery> parseQueryAndBeginOperation(
|
|||
|
||||
const auto& collection = collOrViewAcquisition.getCollectionPtr();
|
||||
const auto* collator = collection ? collection->getDefaultCollator() : nullptr;
|
||||
auto expCtx = ExpressionContextBuilder{}
|
||||
auto expCtx =
|
||||
ExpressionContextBuilder{}
|
||||
.fromRequest(opCtx, *findCommand, collator, allowDiskUseByDefault.load())
|
||||
.tmpDir(boost::filesystem::path(storageGlobalParams.dbpath) / "_tmp")
|
||||
.mainCollPathArrayness(
|
||||
collection ? CollectionQueryInfo::get(collection).getPathArrayness() : nullptr)
|
||||
.build();
|
||||
expCtx->startExpressionCounters();
|
||||
auto parsedRequest = uassertStatusOK(parsed_find_command::parse(
|
||||
|
|
@ -521,6 +525,9 @@ public:
|
|||
.fromRequest(opCtx, *_cmdRequest, collator, allowDiskUseByDefault.load())
|
||||
.explain(verbosity)
|
||||
.tmpDir(boost::filesystem::path(storageGlobalParams.dbpath) / "_tmp")
|
||||
.mainCollPathArrayness(
|
||||
collectionPtr ? CollectionQueryInfo::get(collectionPtr).getPathArrayness()
|
||||
: nullptr)
|
||||
.build();
|
||||
expCtx->startExpressionCounters();
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@
|
|||
#include "mongo/db/pipeline/variables.h"
|
||||
#include "mongo/db/query/collation/collation_spec.h"
|
||||
#include "mongo/db/query/collation/collator_interface.h"
|
||||
#include "mongo/db/query/compiler/metadata/path_arrayness.h"
|
||||
#include "mongo/db/query/datetime/date_time_support.h"
|
||||
#include "mongo/db/query/explain_options.h"
|
||||
#include "mongo/db/query/query_feature_flags_gen.h"
|
||||
|
|
@ -1019,6 +1020,17 @@ public:
|
|||
return _featureFlagMqlJsEngineGap.get(VersionContext::getDecoration(getOperationContext()));
|
||||
}
|
||||
|
||||
const PathArrayness& getMainCollPathArrayness() const {
|
||||
// mainCollPathArrayness will be unset in cases where we do not do a collection acquisition,
|
||||
// e.g. if running on a 'mongos'. In this case, we return an empty instance of
|
||||
// 'PathArrayness' that denotes all paths as arrays.
|
||||
if (!_params.mainCollPathArrayness) {
|
||||
static const auto kEmptyPathArrayness = PathArrayness();
|
||||
return kEmptyPathArrayness;
|
||||
}
|
||||
return *_params.mainCollPathArrayness;
|
||||
}
|
||||
|
||||
protected:
|
||||
struct ExpressionContextParams {
|
||||
OperationContext* opCtx = nullptr;
|
||||
|
|
@ -1160,6 +1172,10 @@ protected:
|
|||
|
||||
// Indicates that the query is replanned after being rate-limited.
|
||||
bool wasRateLimited = false;
|
||||
|
||||
// The PathArrayness information for the main collection. This may remain unset if a
|
||||
// collection acquisition is not possible, e.g. when running on mongos.
|
||||
std::shared_ptr<const PathArrayness> mainCollPathArrayness = nullptr;
|
||||
};
|
||||
|
||||
ExpressionContextParams _params;
|
||||
|
|
|
|||
|
|
@ -392,6 +392,12 @@ ExpressionContextBuilder& ExpressionContextBuilder::tailableMode(TailableModeEnu
|
|||
return *this;
|
||||
}
|
||||
|
||||
ExpressionContextBuilder& ExpressionContextBuilder::mainCollPathArrayness(
|
||||
std::shared_ptr<const PathArrayness> mainCollPathArrayness) {
|
||||
params.mainCollPathArrayness = mainCollPathArrayness;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ExpressionContextBuilder& ExpressionContextBuilder::fromRequest(
|
||||
OperationContext* operationContext,
|
||||
const FindCommandRequest& request,
|
||||
|
|
|
|||
|
|
@ -105,6 +105,8 @@ public:
|
|||
boost::optional<std::pair<NamespaceString, std::vector<BSONObj>>>);
|
||||
ExpressionContextBuilder& originalNs(NamespaceString);
|
||||
ExpressionContextBuilder& isHybridSearch(bool);
|
||||
ExpressionContextBuilder& mainCollPathArrayness(
|
||||
std::shared_ptr<const PathArrayness> mainCollPathArrayness);
|
||||
|
||||
/**
|
||||
* Add kSessionTransactionsTableNamespace, and kRsOplogNamespace
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@
|
|||
|
||||
#include "mongo/db/query/compiler/metadata/path_arrayness.h"
|
||||
|
||||
#include "mongo/logv2/log.h"
|
||||
|
||||
#include <stack>
|
||||
|
||||
using namespace mongo::multikey_paths;
|
||||
|
|
@ -126,10 +128,4 @@ void PathArrayness::TrieNode::insertPath(const FieldPath& path,
|
|||
// Recursively invoke the remaining path.
|
||||
_children.at(fieldNameToInsert).insertPath(path, multikeyPath, ++depth);
|
||||
}
|
||||
|
||||
PathArrayness build(std::vector<IndexEntry> entries) {
|
||||
PathArrayness root;
|
||||
return root;
|
||||
}
|
||||
|
||||
} // namespace mongo
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "mongo/db/index/multikey_paths.h"
|
||||
#include "mongo/db/pipeline/field_path.h"
|
||||
#include "mongo/db/query/compiler/metadata/index_entry.h"
|
||||
#include "mongo/util/modules.h"
|
||||
|
||||
namespace mongo {
|
||||
|
|
@ -140,10 +140,4 @@ private:
|
|||
*/
|
||||
TrieNode _root;
|
||||
};
|
||||
|
||||
/**
|
||||
* Build an arrayness trie from a given vector of index entries.
|
||||
*/
|
||||
PathArrayness build(std::vector<IndexEntry> entries);
|
||||
|
||||
} // namespace mongo
|
||||
|
|
|
|||
Loading…
Reference in New Issue