SERVER-78558: Establish mongot cursor before SBE builder
This commit is contained in:
parent
5d697ccb91
commit
2e20f7615c
@ -139,6 +139,24 @@ public:
|
||||
virtual bool isSearchMetaStage(DocumentSource* stage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the information for the search QSN from DocumentSourceSearch.
|
||||
* The results are returned as a tuple of the format:
|
||||
* <limit, mongotDocsRequested, searchQuery, taskExecutor, intermediateResultsProtocolVersion>
|
||||
*/
|
||||
virtual std::unique_ptr<SearchNode> getSearchNode(DocumentSource* stage) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the initial $search query to get the cursor id and first batch for building the
|
||||
* $search SBE plan.
|
||||
*/
|
||||
virtual std::pair<CursorResponse, CursorResponse> establishSearchQueryCursors(
|
||||
const boost::intrusive_ptr<ExpressionContext>& expCtx, const SearchNode* searchNode) {
|
||||
return {CursorResponse(), CursorResponse()};
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -556,8 +556,11 @@ StatusWith<std::unique_ptr<QuerySolution>> tryToBuildSearchQuerySolution(
|
||||
"Pushing down $search into SBE but featureFlagSearchInSbe is disabled.",
|
||||
feature_flags::gFeatureFlagSearchInSbe.isEnabledAndIgnoreFCVUnsafe());
|
||||
|
||||
auto searchNode =
|
||||
getSearchHelpers(query.getOpCtx()->getServiceContext())->getSearchNode(stage);
|
||||
|
||||
auto querySoln = std::make_unique<QuerySolution>();
|
||||
querySoln->setRoot(std::make_unique<SearchNode>(isSearchMeta));
|
||||
querySoln->setRoot(std::move(searchNode));
|
||||
return std::move(querySoln);
|
||||
}
|
||||
|
||||
|
||||
@ -1819,7 +1819,8 @@ void SentinelNode::appendToString(str::stream* ss, int indent) const {
|
||||
}
|
||||
|
||||
std::unique_ptr<QuerySolutionNode> SearchNode::clone() const {
|
||||
return std::make_unique<SearchNode>(isSearchMeta);
|
||||
return std::make_unique<SearchNode>(
|
||||
isSearchMeta, searchQuery, limit, intermediateResultsProtocolVersion);
|
||||
}
|
||||
|
||||
void SearchNode::appendToString(str::stream* ss, int indent) const {
|
||||
@ -1827,6 +1828,12 @@ void SearchNode::appendToString(str::stream* ss, int indent) const {
|
||||
*ss << "SEARCH\n";
|
||||
addIndent(ss, indent + 1);
|
||||
*ss << "isSearchMeta = " << isSearchMeta << '\n';
|
||||
addIndent(ss, indent + 1);
|
||||
*ss << "searchQuery = " << searchQuery << '\n';
|
||||
if (limit) {
|
||||
addIndent(ss, indent + 1);
|
||||
*ss << "limit = " << limit << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1733,7 +1733,16 @@ struct SentinelNode : public QuerySolutionNode {
|
||||
};
|
||||
|
||||
struct SearchNode : public QuerySolutionNode {
|
||||
explicit SearchNode(bool isSearchMeta) : isSearchMeta(isSearchMeta) {
|
||||
SearchNode() = default;
|
||||
|
||||
SearchNode(bool isSearchMeta,
|
||||
BSONObj searchQuery,
|
||||
boost::optional<long long> limit,
|
||||
boost::optional<int> intermediateResultsProtocolVersion)
|
||||
: isSearchMeta(isSearchMeta),
|
||||
searchQuery(searchQuery),
|
||||
limit(limit),
|
||||
intermediateResultsProtocolVersion(intermediateResultsProtocolVersion) {
|
||||
// TODO SERVER-78565: Support $search in SBE plan cache
|
||||
eligibleForPlanCache = false;
|
||||
}
|
||||
@ -1766,6 +1775,22 @@ struct SearchNode : public QuerySolutionNode {
|
||||
* True for $searchMeta, False for $search query.
|
||||
*/
|
||||
bool isSearchMeta;
|
||||
|
||||
const BSONObj searchQuery;
|
||||
|
||||
/**
|
||||
* This will populate the docsRequested field of the cursorOptions document sent as part of the
|
||||
* command to mongot in the case where the query has an extractable limit that can guide the
|
||||
* number of documents that mongot returns to mongod.
|
||||
*/
|
||||
boost::optional<long long> limit;
|
||||
|
||||
/**
|
||||
* Protocol version if it must be communicated via the search request.
|
||||
* If we are in a sharded environment but are targeting unsharded collection we may have a
|
||||
* protocol version even though it should not be sent to mongot.
|
||||
*/
|
||||
boost::optional<int> intermediateResultsProtocolVersion;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user