Skip to content

Commit a1ad7c6

Browse files
gregorynomaMongoDB Bot
authored andcommitted
SERVER-99818 Perform rawData translation for count later (#31579)
GitOrigin-RevId: 71c8964
1 parent 816591d commit a1ad7c6

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

src/mongo/db/commands/query_cmd/count_cmd.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,18 +137,13 @@ class CmdCount : public CountCmdVersion1Gen<CmdCount> {
137137
Invocation(OperationContext* opCtx,
138138
const Command* command,
139139
const OpMsgRequest& opMsgRequest)
140-
: InvocationBaseGen(opCtx, command, opMsgRequest), _ns([&] {
141-
if (request().getRawData()) {
142-
return timeseries::isTimeseriesViewRequest(opCtx, request()).second;
143-
}
144-
145-
return request().getNamespaceOrUUID().isNamespaceString()
140+
: InvocationBaseGen(opCtx, command, opMsgRequest),
141+
_ns(request().getNamespaceOrUUID().isNamespaceString()
146142
? request().getNamespaceOrUUID().nss()
147143
: CollectionCatalog::get(opCtx)->resolveNamespaceStringFromDBNameAndUUID(
148144
opCtx,
149145
request().getNamespaceOrUUID().dbName(),
150-
request().getNamespaceOrUUID().uuid());
151-
}()) {
146+
request().getNamespaceOrUUID().uuid())) {
152147
uassert(ErrorCodes::InvalidNamespace,
153148
str::stream() << "Invalid namespace specified '" << _ns.toStringForErrorMsg()
154149
<< "'",
@@ -256,6 +251,18 @@ class CmdCount : public CountCmdVersion1Gen<CmdCount> {
256251
CurOpFailpointHelpers::waitWhileFailPointEnabled(
257252
&hangBeforeCollectionCount, opCtx, "hangBeforeCollectionCount", []() {}, _ns);
258253

254+
auto ns = [&] {
255+
if (request().getRawData()) {
256+
auto [isTimeseriesViewRequest, ns] =
257+
timeseries::isTimeseriesViewRequest(opCtx, request());
258+
if (isTimeseriesViewRequest) {
259+
ctx.emplace(opCtx, ns);
260+
return ns;
261+
}
262+
}
263+
return _ns;
264+
}();
265+
259266
// Start the query planning timer.
260267
auto curOp = CurOp::get(opCtx);
261268
curOp->beginQueryPlanningTimer();
@@ -270,13 +277,13 @@ class CmdCount : public CountCmdVersion1Gen<CmdCount> {
270277
auto expCtx =
271278
makeExpressionContextForGetExecutor(opCtx,
272279
request().getCollation().value_or(BSONObj()),
273-
_ns,
280+
ns,
274281
boost::none /* verbosity*/);
275282

276283
const auto& collection = ctx->getCollection();
277-
const auto extensionsCallback = getExtensionsCallback(collection, opCtx, _ns);
284+
const auto extensionsCallback = getExtensionsCallback(collection, opCtx, ns);
278285
auto parsedFind = uassertStatusOK(
279-
parsed_find_command::parseFromCount(expCtx, request(), *extensionsCallback, _ns));
286+
parsed_find_command::parseFromCount(expCtx, request(), *extensionsCallback, ns));
280287

281288
registerRequestForQueryStats(opCtx, expCtx, curOp, ctx, request(), *parsedFind);
282289

0 commit comments

Comments
 (0)