This mapping has 1 multi-map group: several pairings are equally correct there. The code view shows one arbitrary valid pairing, not the only one.

This mapping has 19 all-to-all groups: every node on one side corresponds to every node on the other, and none is deleted or inserted. Each member carries an all N:M badge; selecting one highlights all of its counterparts, in the tree and in the code view alike.

Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

…lines 1–230 unchanged (230 lines)
231 }
232 ASSERT_TRUE(strategy.getMultiPlanner().has_value());
233 auto stats = strategy.getMultiPlanner()->getSpecificStats();
234 ASSERT_TRUE(stats->earlyExit);
235 ASSERT_EQ(stats->numResultsFound, 0);
236 ASSERT_EQ(stats->numCandidatePlans, 2);
237 ASSERT_EQ(stats->totalWorks, 10001);
238 ASSERT_EQ(status.getValue().needsWorksMeasuredForPlanCache, true);
239
240 ASSERT_TRUE(status.getValue().execState);
241 auto mp = dynamic_cast<MultiPlanStage*>(status.getValue().execState->root.get());
242 ASSERT_TRUE(mp);
243 ASSERT_EQ(mp->getStats()->children.size(), 2); // One winning and one rejected plan
244}
245
246TEST_F(CBRForNoMPResultsTest, CBRCannotDecideUsesMultiPlanner) {
247 createIndexOnEmptyCollection(operationContext(), BSON("a" << 1), "a_1");
248 createIndexOnEmptyCollection(operationContext(), BSON("b" << 1), "b_1");
249 createIndexOnEmptyCollection(operationContext(),
250 BSON("c" << 1),
251 "c_1",
252 BSON("partialFilterExpression" << BSON("b" << GTE << 0)));
253
254 // Insert documents into the collection
255 // Note that this makes b_1 the CBR loser
256 {
257 std::vector<BSONObj> docs;
258 for (int i = 0; i < 1000; i++) {
259 BSONObj obj = BSON("_id" << i << "b" << i);
260 docs.push_back(obj);
261 }
262 for (int i = 0; i < 10001; i++) {
263 BSONObj obj = BSON("_id" << i + 1000 << "a" << i << "b" << i << "c" << i);
264 docs.push_back(obj);
265 }
266 insertDocuments(docs);
267 }
268
269
270 auto colls = getCollsAccessor();
271
272 // The query matches no documents so none of the plans will advance
273 // during the initial MP run, so the strategy will fall back to CBR.
274 // It will cost a_1 and b_1, and a_1 will win (because of the sequential sample).
275 // a_1 and c_1 will be multiplanned. Both will exit with neither EOF nor documents
276 // after 10000 works.
277 auto [cq, plannerData] = createCQAndPlannerData(
278 colls, BSON("a" << GT << 0 << "b" << GT << 0 << "c" << GT << 0 << "d" << 0));
279
280 plannerData.plannerParams =
281 makePlannerParams({.indices = indices,
282 .collStats = std::make_unique<stats::CollectionStatisticsImpl>(
283 static_cast<double>(5001), kNss)});
284
285 CBRForNoMPResultsStrategySpy strategy;
286 auto status = planAndRank(strategy, plannerData);
287 ASSERT_OK(status.getStatus());
288 ASSERT_EQ(status.getValue().solutions.size(), 1);
289 auto& explainData = status.getValue().maybeExplainData.value();
290 ASSERT_EQ(explainData.rejectedPlansWithStages.size(),
291 5); // 2 from multiplanner + 3 from CBR (we mark all plans considered by CBR as
292 // rejected if it cannot decide)
293 // The winning plan must have made it all the way to the end of the collection
294 ASSERT_EQ(explainData.multiPlannerWinningPlanTrialStats->common.works, 10000);
295 ASSERT_EQ(explainData.multiPlannerWinningPlanTrialStats->common.advanced, 0);
296 // There must be two (ixscan + fetch) CBR estimates for the two costable plans.
297 ASSERT_EQ(explainData.estimates.size(), 4);
298
299 // CBR winner should make it into the second runTrials
300 ASSERT_EQ(explainData.rejectedPlansWithStages[0].planStage->getStats()->common.works, 10000);
301 ASSERT_EQ(explainData.rejectedPlansWithStages[0].planStage->getStats()->common.advanced, 0);
302 // CBR loser should get abandoned
303 ASSERT_EQ(explainData.rejectedPlansWithStages[1].planStage->getStats()->common.works, 3333);
304 ASSERT_EQ(explainData.rejectedPlansWithStages[1].planStage->getStats()->common.advanced, 0);
305 const std::string cbrLoserPlanString =
306 explainData.rejectedPlansWithStages[1].solution->toString();
307 // Make sure this candidate actually was the CBR loser
308 ASSERT_NE(cbrLoserPlanString.find("b_1"), std::string::npos);
309 // The rest should be CBR rejections
310 ASSERT(!explainData.rejectedPlansWithStages[2].planStage);
311 ASSERT(!explainData.rejectedPlansWithStages[3].planStage);
312 ASSERT(!explainData.rejectedPlansWithStages[4].planStage);
313
314 ASSERT_TRUE(strategy.getMultiPlanner().has_value());
315 auto stats = strategy.getMultiPlanner()->getSpecificStats();
316 ASSERT_FALSE(stats->earlyExit);
317 ASSERT_EQ(stats->numResultsFound, 0);
318 ASSERT_EQ(stats->numCandidatePlans, 3);
319 ASSERT_EQ(stats->totalWorks, 23333); // 10000 + 10000 + 3333
320
321 ASSERT_TRUE(status.getValue().execState);
322}
323
324TEST_F(CBRForNoMPResultsTest, MPPicksBlockingSortAndEOFs) {
325 createIndexOnEmptyCollection(operationContext(), BSON("a" << 1), "a_1");
…lines 326–357 unchanged (32 lines)

After

…lines 1–230 unchanged (230 lines)
231 }
232 ASSERT_TRUE(strategy.getMultiPlanner().has_value());
233 auto stats = strategy.getMultiPlanner()->getSpecificStats();
234 ASSERT_TRUE(stats->earlyExit);
235 ASSERT_EQ(stats->numResultsFound, 0);
236 ASSERT_EQ(stats->numCandidatePlans, 2);
237 ASSERT_EQ(stats->totalWorks, 10002);
238 ASSERT_EQ(status.getValue().needsWorksMeasuredForPlanCache, true);
239
240 ASSERT_TRUE(status.getValue().execState);
241 auto mp = dynamic_cast<MultiPlanStage*>(status.getValue().execState->root.get());
242 ASSERT_TRUE(mp);
243 ASSERT_EQ(mp->getStats()->children.size(), 2); // One winning and one rejected plan
244}
245
246TEST_F(CBRForNoMPResultsTest, CBRCannotDecideUsesMultiPlanner) {
247 createIndexOnEmptyCollection(operationContext(), BSON("a" << 1), "a_1");
248 createIndexOnEmptyCollection(operationContext(), BSON("b" << 1), "b_1");
249 insertNDocuments(10001);
250 auto colls = getCollsAccessor();
251
252 auto [cq, plannerData] =
253 createCQAndPlannerData(colls,
254 BSON("a" << GT << 0 << "b" << GT << 0 << "c" << -1),
255 [](FindCommandRequest& findCmd) { findCmd.setReturnKey(true); });
256
257 plannerData.plannerParams =
258 makePlannerParams({.indices = indices,
259 .collStats = std::make_unique<stats::CollectionStatisticsImpl>(
260 static_cast<double>(5001), kNss)});
261
262 CBRForNoMPResultsStrategySpy strategy;
263 auto status = planAndRank(strategy, plannerData);
264 ASSERT_OK(status.getStatus());
265 ASSERT_EQ(status.getValue().solutions.size(), 1);
266 auto& explainData = status.getValue().maybeExplainData.value();
267 ASSERT_EQ(explainData.rejectedPlansWithStages.size(), 3); // 1 from multiplanner + 2 from CBR
268 ASSERT_FALSE(explainData.rejectedPlansWithStages[0].solution == nullptr);
269 auto multiPlannerRejectedPlanStats =
270 explainData.rejectedPlansWithStages[0].planStage->getStats();
271 ASSERT_EQ(multiPlannerRejectedPlanStats->common.works, 10000);
272 ASSERT_EQ(multiPlannerRejectedPlanStats->common.advanced, 0);
273 ASSERT_EQ(explainData.estimates.size(),
274 0); // Empty estimates map as setReturnKey cannot be estimated
275 ASSERT_FALSE(explainData.rejectedPlansWithStages[1].solution == nullptr);
276 ASSERT_TRUE(explainData.rejectedPlansWithStages[1].planStage ==
277 nullptr); // No plan stage as CBR rejected
278 ASSERT_FALSE(explainData.rejectedPlansWithStages[2].solution == nullptr);
279 ASSERT_TRUE(explainData.rejectedPlansWithStages[2].planStage ==
280 nullptr); // No plan stage as CBR rejected
281 ASSERT_TRUE(strategy.getMultiPlanner().has_value());
282 auto stats = strategy.getMultiPlanner()->getSpecificStats();
283 ASSERT_FALSE(stats->earlyExit);
284 ASSERT_EQ(stats->numResultsFound, 0);
285 ASSERT_EQ(stats->numCandidatePlans, 2);
286 ASSERT_EQ(stats->totalWorks, 20000);
287
288 ASSERT_TRUE(status.getValue().execState);
289}
290
291TEST_F(CBRForNoMPResultsTest, MPPicksBlockingSortAndEOFs) {
292 createIndexOnEmptyCollection(operationContext(), BSON("a" << 1), "a_1");
293 createIndexOnEmptyCollection(operationContext(), BSON("b" << 1), "b_1");
…lines 294–324 unchanged (31 lines)

Before

translation_unit
comment "/**\n * Copyright (C) 2025-present MongoDB, Inc.\n *\n * "...
preproc_include
#include "#include"
string_literal
" "\""
string_content "mongo/db/query/plan_ranking/cbr_for_no_mp_results.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "mongo/db/query/compiler/stats/collection_statistics_impl.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "mongo/db/query/plan_ranking/plan_ranking_test_fixture.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "mongo/db/query/query_planner_params.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "mongo/unittest/framework.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "mongo/unittest/unittest.h"
" "\""
preproc_include
#include "#include"
system_lib_string "<boost/optional/optional.hpp>"
namespace_definition
namespace "namespace"
namespace_identifier "mongo"
declaration_list
{ "{"
namespace_definition
namespace "namespace"
declaration_list
{ "{"
declaration
type_qualifier
const "const"
type_identifier "NamespaceString"
init_declarator
identifier "kNss"
= "="
call_expression
qualified_identifier
namespace_identifier "NamespaceString"
:: "::"
identifier "createNamespaceString_forTest"
argument_list
( "("
string_literal
" "\""
string_content "test.collection"
" "\""
) ")"
; ";"
class_specifier (+45 nodes collapsed)
; ";"
class_specifier (+184 nodes collapsed)
; ";"
function_definition (+42 nodes collapsed)
function_definition (+240 nodes collapsed)
function_definition (+152 nodes collapsed)
function_definition (+524 nodes collapsed)
function_definition (+525 nodes collapsed)
function_definition (+514 nodes collapsed)
function_definition
function_declarator
identifier "TEST_F"
parameter_list
( "("
parameter_declaration
type_identifier "CBRForNoMPResultsTest"
, ","
parameter_declaration
type_identifier "NoResultsMultiPlannerUsesCBR"
) ")"
compound_statement
{ "{"
expression_statement (+30 nodes collapsed)
expression_statement (+30 nodes collapsed)
expression_statement
call_expression
identifier "insertNDocuments"
argument_list
( "("
number_literal "5001"
) ")"
; ";"
declaration
placeholder_type_specifier
auto "auto"
init_declarator
identifier "colls"
= "="
call_expression
identifier "getCollsAccessor"
argument_list
( "("
) ")"
; ";"
declaration (+55 nodes collapsed)
expression_statement (+59 nodes collapsed)
declaration
type_identifier "CBRForNoMPResultsStrategySpy"
identifier "strategy"
; ";"
declaration
placeholder_type_specifier
auto "auto"
init_declarator
identifier "status"
= "="
call_expression
identifier "planAndRank"
argument_list
( "("
identifier "strategy"
, ","
identifier "plannerData"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_OK"
argument_list
( "("
call_expression
field_expression
identifier "status"
. "."
field_identifier "getStatus"
argument_list
( "("
) ")"
) ")"
; ";"
expression_statement (+27 nodes collapsed)
declaration (+27 nodes collapsed)
comment "// The plan rejected from CBR is in rejectedPlansWithStages"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
call_expression
field_expression
field_expression
identifier "explainData"
. "."
field_identifier "rejectedPlansWithStages"
. "."
field_identifier "size"
argument_list
( "("
) ")"
, ","
number_literal "1"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
call_expression
field_expression
field_expression
identifier "explainData"
. "."
field_identifier "estimates"
. "."
field_identifier "size"
argument_list
( "("
) ")"
, ","
number_literal "4"
) ")"
; ";"
comment "// 2 x (IXSCAN + FETCH)"
for_range_loop (+49 nodes collapsed)
expression_statement (+22 nodes collapsed)
declaration (+22 nodes collapsed)
expression_statement
call_expression
identifier "ASSERT_TRUE"
argument_list
( "("
field_expression
identifier "stats"
-> "->"
field_identifier "earlyExit"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
field_expression
identifier "stats"
-> "->"
field_identifier "numResultsFound"
, ","
number_literal "0"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
field_expression
identifier "stats"
-> "->"
field_identifier "numCandidatePlans"
, ","
number_literal "2"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
field_expression
identifier "stats"
-> "->"
field_identifier "totalWorks"
, ","
number_literal "10001"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
field_expression
call_expression
field_expression
identifier "status"
. "."
field_identifier "getValue"
argument_list
( "("
) ")"
. "."
field_identifier "needsWorksMeasuredForPlanCache"
, ","
true "true"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_TRUE"
argument_list
( "("
field_expression
call_expression
field_expression
identifier "status"
. "."
field_identifier "getValue"
argument_list
( "("
) ")"
. "."
field_identifier "execState"
) ")"
; ";"
declaration (+41 nodes collapsed)
expression_statement
call_expression
identifier "ASSERT_TRUE"
argument_list
( "("
identifier "mp"
) ")"
; ";"
expression_statement (+27 nodes collapsed)
comment "// One winning and one rejected plan"
} "}"
function_definition
function_declarator
identifier "TEST_F"
parameter_list
( "("
parameter_declaration
type_identifier "CBRForNoMPResultsTest"
, ","
parameter_declaration
type_identifier "CBRCannotDecideUsesMultiPlanner"
) ")"
compound_statement
{ "{"
expression_statement (+30 nodes collapsed)
expression_statement (+30 nodes collapsed)
expression_statement
call_expression
identifier "createIndexOnEmptyCollection"
argument_list
( "("
call_expression
identifier "operationContext"
argument_list
( "("
) ")"
, ","
call_expression
identifier "BSON"
argument_list
( "("
binary_expression
string_literal
" "\""
string_content "c"
" "\""
<< "<<"
number_literal "1"
) ")"
, ","
string_literal
" "\""
string_content "c_1"
" "\""
, ","
call_expression
identifier "BSON"
argument_list
( "("
binary_expression
string_literal
" "\""
string_content "partialFilterExpression"
" "\""
<< "<<"
call_expression
identifier "BSON"
argument_list
( "("
binary_expression
binary_expression
string_literal
" "\""
string_content "b"
" "\""
<< "<<"
identifier "GTE"
<< "<<"
number_literal "0"
) ")"
) ")"
) ")"
; ";"
comment "// Insert documents into the collection"
comment "// Note that this makes b_1 the CBR loser"
compound_statement
{ "{"
declaration
qualified_identifier
namespace_identifier "std"
:: "::"
template_type
type_identifier "vector"
template_argument_list
< "<"
type_descriptor
type_identifier "BSONObj"
> ">"
identifier "docs"
; ";"
for_statement
for "for"
( "("
declaration
primitive_type "int"
init_declarator
identifier "i"
= "="
number_literal "0"
; ";"
binary_expression
identifier "i"
< "<"
number_literal "1000"
; ";"
update_expression
identifier "i"
++ "++"
) ")"
compound_statement
{ "{"
declaration
type_identifier "BSONObj"
init_declarator
identifier "obj"
= "="
call_expression
identifier "BSON"
argument_list
( "("
binary_expression
binary_expression
binary_expression
string_literal
" "\""
string_content "_id"
" "\""
<< "<<"
identifier "i"
<< "<<"
string_literal
" "\""
string_content "b"
" "\""
<< "<<"
identifier "i"
) ")"
; ";"
expression_statement
call_expression
field_expression
identifier "docs"
. "."
field_identifier "push_back"
argument_list
( "("
identifier "obj"
) ")"
; ";"
} "}"
for_statement
for "for"
( "("
declaration
primitive_type "int"
init_declarator
identifier "i"
= "="
number_literal "0"
; ";"
binary_expression
identifier "i"
< "<"
number_literal "10001"
; ";"
update_expression
identifier "i"
++ "++"
) ")"
compound_statement
{ "{"
declaration
type_identifier "BSONObj"
init_declarator
identifier "obj"
= "="
call_expression
identifier "BSON"
argument_list
( "("
binary_expression
binary_expression
binary_expression
binary_expression
binary_expression
binary_expression
binary_expression
string_literal
" "\""
string_content "_id"
" "\""
<< "<<"
binary_expression
identifier "i"
+ "+"
number_literal "1000"
<< "<<"
string_literal
" "\""
string_content "a"
" "\""
<< "<<"
identifier "i"
<< "<<"
string_literal
" "\""
string_content "b"
" "\""
<< "<<"
identifier "i"
<< "<<"
string_literal
" "\""
string_content "c"
" "\""
<< "<<"
identifier "i"
) ")"
; ";"
expression_statement
call_expression
field_expression
identifier "docs"
. "."
field_identifier "push_back"
argument_list
( "("
identifier "obj"
) ")"
; ";"
} "}"
expression_statement
call_expression
identifier "insertDocuments"
argument_list
( "("
identifier "docs"
) ")"
; ";"
} "}"
declaration
placeholder_type_specifier
auto "auto"
init_declarator
identifier "colls"
= "="
call_expression
identifier "getCollsAccessor"
argument_list
( "("
) ")"
; ";"
comment "// The query matches no documents so none of the plans will "...
comment "// during the initial MP run, so the strategy will fall back"...
comment "// It will cost a_1 and b_1, and a_1 will win (because of th"...
comment "// a_1 and c_1 will be multiplanned. Both will exit with nei"...
comment "// after 10000 works."
declaration
placeholder_type_specifier
auto "auto"
init_declarator
structured_binding_declarator
[ "["
identifier "cq"
, ","
identifier "plannerData"
] "]"
= "="
call_expression
identifier "createCQAndPlannerData"
argument_list
( "("
identifier "colls"
, ","
call_expression
identifier "BSON"
argument_list
( "("
binary_expression any 10:7
binary_expression any 10:7
binary_expression any 10:7
binary_expression any 10:7
binary_expression any 10:7
binary_expression any 10:7
binary_expression any 10:7
binary_expression any 10:7
binary_expression any 10:7
binary_expression any 10:7
string_literal
" "\""
string_content "a"
" "\""
<< "<<"
identifier "GT"
<< "<<"
number_literal "0"
<< "<<"
string_literal
" "\""
string_content "b"
" "\""
<< "<<"
identifier "GT"
<< "<<"
number_literal "0"
<< "<<"
string_literal
" "\""
string_content "c"
" "\""
<< "<<"
identifier "GT"
<< "<<"
number_literal "0"
<< "<<"
string_literal
" "\""
string_content "d"
" "\""
<< "<<"
number_literal "0"
) ")"
) ")"
; ";"
expression_statement (+59 nodes collapsed)
declaration
type_identifier "CBRForNoMPResultsStrategySpy"
identifier "strategy"
; ";"
declaration
placeholder_type_specifier
auto "auto"
init_declarator
identifier "status"
= "="
call_expression
identifier "planAndRank"
argument_list
( "("
identifier "strategy"
, ","
identifier "plannerData"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_OK"
argument_list
( "("
call_expression
field_expression
identifier "status"
. "."
field_identifier "getStatus"
argument_list
( "("
) ")"
) ")"
; ";"
expression_statement (+27 nodes collapsed)
declaration (+27 nodes collapsed)
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
call_expression
field_expression
field_expression
identifier "explainData"
. "."
field_identifier "rejectedPlansWithStages"
. "."
field_identifier "size"
argument_list
( "("
) ")"
, ","
number_literal "5"
) ")"
; ";"
comment "// 2 from multiplanner + 3 from CBR (we mark all plans consi"...
comment "// rejected if it cannot decide)"
comment "// The winning plan must have made it all the way to the end"...
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
field_expression
field_expression
field_expression
identifier "explainData"
. "."
field_identifier "multiPlannerWinningPlanTrialStats"
-> "->"
field_identifier "common"
. "."
field_identifier "works"
, ","
number_literal "10000"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
field_expression
field_expression
field_expression
identifier "explainData"
. "."
field_identifier "multiPlannerWinningPlanTrialStats"
-> "->"
field_identifier "common"
. "."
field_identifier "advanced"
, ","
number_literal "0"
) ")"
; ";"
comment "// There must be two (ixscan + fetch) CBR estimates for the "...
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
call_expression
field_expression
field_expression
identifier "explainData"
. "."
field_identifier "estimates"
. "."
field_identifier "size"
argument_list
( "("
) ")"
, ","
number_literal "4"
) ")"
; ";"
comment "// CBR winner should make it into the second runTrials"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
field_expression
field_expression
call_expression all 2:1
field_expression all 2:1
field_expression all 2:1
subscript_expression all 2:1
field_expression all 2:1
identifier "explainData" all 2:1
. "." all 2:1
field_identifier "rejectedPlansWithStages" all 2:1
subscript_argument_list all 2:1
[ "[" all 2:1
number_literal "0" all 2:1
] "]" all 2:1
. "." all 2:1
field_identifier "planStage" all 2:1
-> "->" all 2:1
field_identifier "getStats" all 2:1
argument_list all 2:1
( "(" all 2:1
) ")" all 2:1
-> "->"
field_identifier "common"
. "."
field_identifier "works"
, ","
number_literal "10000"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
field_expression
field_expression
call_expression all 2:1
field_expression all 2:1
field_expression all 2:1
subscript_expression all 2:1
field_expression all 2:1
identifier "explainData" all 2:1
. "." all 2:1
field_identifier "rejectedPlansWithStages" all 2:1
subscript_argument_list all 2:1
[ "[" all 2:1
number_literal "0" all 2:1
] "]" all 2:1
. "." all 2:1
field_identifier "planStage" all 2:1
-> "->" all 2:1
field_identifier "getStats" all 2:1
argument_list all 2:1
( "(" all 2:1
) ")" all 2:1
-> "->"
field_identifier "common"
. "."
field_identifier "advanced"
, ","
number_literal "0"
) ")"
; ";"
comment "// CBR loser should get abandoned"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
field_expression
field_expression
call_expression
field_expression
field_expression
subscript_expression
field_expression
identifier "explainData"
. "."
field_identifier "rejectedPlansWithStages"
subscript_argument_list
[ "["
number_literal "1"
] "]"
. "."
field_identifier "planStage"
-> "->"
field_identifier "getStats"
argument_list
( "("
) ")"
-> "->"
field_identifier "common"
. "."
field_identifier "works"
, ","
number_literal "3333"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
field_expression
field_expression
call_expression
field_expression
field_expression
subscript_expression
field_expression
identifier "explainData"
. "."
field_identifier "rejectedPlansWithStages"
subscript_argument_list
[ "["
number_literal "1"
] "]"
. "."
field_identifier "planStage"
-> "->"
field_identifier "getStats"
argument_list
( "("
) ")"
-> "->"
field_identifier "common"
. "."
field_identifier "advanced"
, ","
number_literal "0"
) ")"
; ";"
declaration
type_qualifier
const "const"
qualified_identifier
namespace_identifier "std"
:: "::"
type_identifier "string"
init_declarator
identifier "cbrLoserPlanString"
= "="
call_expression
field_expression
field_expression
subscript_expression
field_expression
identifier "explainData"
. "."
field_identifier "rejectedPlansWithStages"
subscript_argument_list
[ "["
number_literal "1"
] "]"
. "."
field_identifier "solution"
-> "->"
field_identifier "toString"
argument_list
( "("
) ")"
; ";"
comment "// Make sure this candidate actually was the CBR loser"
expression_statement
call_expression
identifier "ASSERT_NE"
argument_list
( "("
call_expression
field_expression
identifier "cbrLoserPlanString"
. "."
field_identifier "find"
argument_list
( "("
string_literal
" "\""
string_content "b_1"
" "\""
) ")"
, ","
qualified_identifier
namespace_identifier "std"
:: "::"
qualified_identifier
namespace_identifier "string"
:: "::"
identifier "npos"
) ")"
; ";"
comment "// The rest should be CBR rejections"
expression_statement
call_expression
identifier "ASSERT"
argument_list
( "("
unary_expression
! "!"
field_expression
subscript_expression
field_expression
identifier "explainData"
. "."
field_identifier "rejectedPlansWithStages"
subscript_argument_list
[ "["
number_literal "2"
] "]"
. "."
field_identifier "planStage"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT"
argument_list
( "("
unary_expression
! "!"
field_expression
subscript_expression
field_expression
identifier "explainData"
. "."
field_identifier "rejectedPlansWithStages"
subscript_argument_list
[ "["
number_literal "3"
] "]"
. "."
field_identifier "planStage"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT"
argument_list
( "("
unary_expression
! "!"
field_expression
subscript_expression
field_expression
identifier "explainData"
. "."
field_identifier "rejectedPlansWithStages"
subscript_argument_list
[ "["
number_literal "4"
] "]"
. "."
field_identifier "planStage"
) ")"
; ";"
expression_statement (+22 nodes collapsed)
declaration (+22 nodes collapsed)
expression_statement
call_expression
identifier "ASSERT_FALSE"
argument_list
( "("
field_expression
identifier "stats"
-> "->"
field_identifier "earlyExit"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
field_expression
identifier "stats"
-> "->"
field_identifier "numResultsFound"
, ","
number_literal "0"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
field_expression
identifier "stats"
-> "->"
field_identifier "numCandidatePlans"
, ","
number_literal "3"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
field_expression
identifier "stats"
-> "->"
field_identifier "totalWorks"
, ","
number_literal "23333"
) ")"
; ";"
comment "// 10000 + 10000 + 3333"
expression_statement
call_expression
identifier "ASSERT_TRUE"
argument_list
( "("
field_expression
call_expression
field_expression
identifier "status"
. "."
field_identifier "getValue"
argument_list
( "("
) ")"
. "."
field_identifier "execState"
) ")"
; ";"
} "}"
function_definition (+447 nodes collapsed)
} "}"
comment "// namespace"
} "}"
comment "// namespace mongo"

After

translation_unit
comment "/**\n * Copyright (C) 2025-present MongoDB, Inc.\n *\n * "...
preproc_include
#include "#include"
string_literal
" "\""
string_content "mongo/db/query/plan_ranking/cbr_for_no_mp_results.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "mongo/db/query/compiler/stats/collection_statistics_impl.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "mongo/db/query/plan_ranking/plan_ranking_test_fixture.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "mongo/db/query/query_planner_params.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "mongo/unittest/framework.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "mongo/unittest/unittest.h"
" "\""
preproc_include
#include "#include"
system_lib_string "<boost/optional/optional.hpp>"
namespace_definition
namespace "namespace"
namespace_identifier "mongo"
declaration_list
{ "{"
namespace_definition
namespace "namespace"
declaration_list
{ "{"
declaration
type_qualifier
const "const"
type_identifier "NamespaceString"
init_declarator
identifier "kNss"
= "="
call_expression
qualified_identifier
namespace_identifier "NamespaceString"
:: "::"
identifier "createNamespaceString_forTest"
argument_list
( "("
string_literal
" "\""
string_content "test.collection"
" "\""
) ")"
; ";"
class_specifier (+45 nodes collapsed)
; ";"
class_specifier (+184 nodes collapsed)
; ";"
function_definition (+42 nodes collapsed)
function_definition (+240 nodes collapsed)
function_definition (+152 nodes collapsed)
function_definition (+524 nodes collapsed)
function_definition (+525 nodes collapsed)
function_definition (+514 nodes collapsed)
function_definition
function_declarator
identifier "TEST_F"
parameter_list
( "("
parameter_declaration
type_identifier "CBRForNoMPResultsTest"
, ","
parameter_declaration
type_identifier "NoResultsMultiPlannerUsesCBR"
) ")"
compound_statement
{ "{"
expression_statement (+30 nodes collapsed)
expression_statement (+30 nodes collapsed)
expression_statement
call_expression
identifier "insertNDocuments"
argument_list
( "("
number_literal "5001"
) ")"
; ";"
declaration
placeholder_type_specifier
auto "auto"
init_declarator
identifier "colls"
= "="
call_expression
identifier "getCollsAccessor"
argument_list
( "("
) ")"
; ";"
declaration (+55 nodes collapsed)
expression_statement (+59 nodes collapsed)
declaration
type_identifier "CBRForNoMPResultsStrategySpy"
identifier "strategy"
; ";"
declaration
placeholder_type_specifier
auto "auto"
init_declarator
identifier "status"
= "="
call_expression
identifier "planAndRank"
argument_list
( "("
identifier "strategy"
, ","
identifier "plannerData"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_OK"
argument_list
( "("
call_expression
field_expression
identifier "status"
. "."
field_identifier "getStatus"
argument_list
( "("
) ")"
) ")"
; ";"
expression_statement (+27 nodes collapsed)
declaration (+27 nodes collapsed)
comment "// The plan rejected from CBR is in rejectedPlansWithStages"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
call_expression
field_expression
field_expression
identifier "explainData"
. "."
field_identifier "rejectedPlansWithStages"
. "."
field_identifier "size"
argument_list
( "("
) ")"
, ","
number_literal "1"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
call_expression
field_expression
field_expression
identifier "explainData"
. "."
field_identifier "estimates"
. "."
field_identifier "size"
argument_list
( "("
) ")"
, ","
number_literal "4"
) ")"
; ";"
comment "// 2 x (IXSCAN + FETCH)"
for_range_loop (+49 nodes collapsed)
expression_statement (+22 nodes collapsed)
declaration (+22 nodes collapsed)
expression_statement
call_expression
identifier "ASSERT_TRUE"
argument_list
( "("
field_expression
identifier "stats"
-> "->"
field_identifier "earlyExit"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
field_expression
identifier "stats"
-> "->"
field_identifier "numResultsFound"
, ","
number_literal "0"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
field_expression
identifier "stats"
-> "->"
field_identifier "numCandidatePlans"
, ","
number_literal "2"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
field_expression
identifier "stats"
-> "->"
field_identifier "totalWorks"
, ","
number_literal "10002"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
field_expression
call_expression
field_expression
identifier "status"
. "."
field_identifier "getValue"
argument_list
( "("
) ")"
. "."
field_identifier "needsWorksMeasuredForPlanCache"
, ","
true "true"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_TRUE"
argument_list
( "("
field_expression
call_expression
field_expression
identifier "status"
. "."
field_identifier "getValue"
argument_list
( "("
) ")"
. "."
field_identifier "execState"
) ")"
; ";"
declaration (+41 nodes collapsed)
expression_statement
call_expression
identifier "ASSERT_TRUE"
argument_list
( "("
identifier "mp"
) ")"
; ";"
expression_statement (+27 nodes collapsed)
comment "// One winning and one rejected plan"
} "}"
function_definition
function_declarator
identifier "TEST_F"
parameter_list
( "("
parameter_declaration
type_identifier "CBRForNoMPResultsTest"
, ","
parameter_declaration
type_identifier "CBRCannotDecideUsesMultiPlanner"
) ")"
compound_statement
{ "{"
expression_statement (+30 nodes collapsed)
expression_statement (+30 nodes collapsed)
expression_statement
call_expression
identifier "insertNDocuments"
argument_list
( "("
number_literal "10001"
) ")"
; ";"
declaration
placeholder_type_specifier
auto "auto"
init_declarator
identifier "colls"
= "="
call_expression
identifier "getCollsAccessor"
argument_list
( "("
) ")"
; ";"
declaration
placeholder_type_specifier
auto "auto"
init_declarator
structured_binding_declarator
[ "["
identifier "cq"
, ","
identifier "plannerData"
] "]"
= "="
call_expression
identifier "createCQAndPlannerData"
argument_list
( "("
identifier "colls"
, ","
call_expression
identifier "BSON"
argument_list
( "("
binary_expression any 10:7
binary_expression any 10:7
binary_expression any 10:7
binary_expression any 10:7
binary_expression any 10:7
binary_expression any 10:7
binary_expression any 10:7
string_literal
" "\""
string_content "a"
" "\""
<< "<<"
identifier "GT"
<< "<<"
number_literal "0"
<< "<<"
string_literal
" "\""
string_content "b"
" "\""
<< "<<"
identifier "GT"
<< "<<"
number_literal "0"
<< "<<"
string_literal
" "\""
string_content "c"
" "\""
<< "<<"
number_literal "-1"
) ")"
, ","
lambda_expression
lambda_capture_specifier
[ "["
] "]"
abstract_function_declarator
parameter_list
( "("
parameter_declaration
type_identifier "FindCommandRequest"
reference_declarator
& "&"
identifier "findCmd"
) ")"
compound_statement
{ "{"
expression_statement
call_expression
field_expression
identifier "findCmd"
. "."
field_identifier "setReturnKey"
argument_list
( "("
true "true"
) ")"
; ";"
} "}"
) ")"
; ";"
expression_statement (+59 nodes collapsed)
declaration
type_identifier "CBRForNoMPResultsStrategySpy"
identifier "strategy"
; ";"
declaration
placeholder_type_specifier
auto "auto"
init_declarator
identifier "status"
= "="
call_expression
identifier "planAndRank"
argument_list
( "("
identifier "strategy"
, ","
identifier "plannerData"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_OK"
argument_list
( "("
call_expression
field_expression
identifier "status"
. "."
field_identifier "getStatus"
argument_list
( "("
) ")"
) ")"
; ";"
expression_statement (+27 nodes collapsed)
declaration (+27 nodes collapsed)
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
call_expression
field_expression
field_expression
identifier "explainData"
. "."
field_identifier "rejectedPlansWithStages"
. "."
field_identifier "size"
argument_list
( "("
) ")"
, ","
number_literal "3"
) ")"
; ";"
comment "// 1 from multiplanner + 2 from CBR"
expression_statement
call_expression
identifier "ASSERT_FALSE"
argument_list
( "("
binary_expression
field_expression
subscript_expression
field_expression
identifier "explainData"
. "."
field_identifier "rejectedPlansWithStages"
subscript_argument_list
[ "["
number_literal "0"
] "]"
. "."
field_identifier "solution"
== "=="
null
nullptr "nullptr"
) ")"
; ";"
declaration
placeholder_type_specifier
auto "auto"
init_declarator
identifier "multiPlannerRejectedPlanStats"
= "="
call_expression all 2:1
field_expression all 2:1
field_expression all 2:1
subscript_expression all 2:1
field_expression all 2:1
identifier "explainData" all 2:1
. "." all 2:1
field_identifier "rejectedPlansWithStages" all 2:1
subscript_argument_list all 2:1
[ "[" all 2:1
number_literal "0" all 2:1
] "]" all 2:1
. "." all 2:1
field_identifier "planStage" all 2:1
-> "->" all 2:1
field_identifier "getStats" all 2:1
argument_list all 2:1
( "(" all 2:1
) ")" all 2:1
; ";"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
field_expression
field_expression
identifier "multiPlannerRejectedPlanStats"
-> "->"
field_identifier "common"
. "."
field_identifier "works"
, ","
number_literal "10000"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
field_expression
field_expression
identifier "multiPlannerRejectedPlanStats"
-> "->"
field_identifier "common"
. "."
field_identifier "advanced"
, ","
number_literal "0"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
call_expression
field_expression
field_expression
identifier "explainData"
. "."
field_identifier "estimates"
. "."
field_identifier "size"
argument_list
( "("
) ")"
, ","
number_literal "0"
) ")"
; ";"
comment "// Empty estimates map as setReturnKey cannot be estimated"
expression_statement
call_expression
identifier "ASSERT_FALSE"
argument_list
( "("
binary_expression
field_expression
subscript_expression
field_expression
identifier "explainData"
. "."
field_identifier "rejectedPlansWithStages"
subscript_argument_list
[ "["
number_literal "1"
] "]"
. "."
field_identifier "solution"
== "=="
null
nullptr "nullptr"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_TRUE"
argument_list
( "("
binary_expression
field_expression
subscript_expression
field_expression
identifier "explainData"
. "."
field_identifier "rejectedPlansWithStages"
subscript_argument_list
[ "["
number_literal "1"
] "]"
. "."
field_identifier "planStage"
== "=="
null
nullptr "nullptr"
) ")"
; ";"
comment "// No plan stage as CBR rejected"
expression_statement
call_expression
identifier "ASSERT_FALSE"
argument_list
( "("
binary_expression
field_expression
subscript_expression
field_expression
identifier "explainData"
. "."
field_identifier "rejectedPlansWithStages"
subscript_argument_list
[ "["
number_literal "2"
] "]"
. "."
field_identifier "solution"
== "=="
null
nullptr "nullptr"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_TRUE"
argument_list
( "("
binary_expression
field_expression
subscript_expression
field_expression
identifier "explainData"
. "."
field_identifier "rejectedPlansWithStages"
subscript_argument_list
[ "["
number_literal "2"
] "]"
. "."
field_identifier "planStage"
== "=="
null
nullptr "nullptr"
) ")"
; ";"
comment "// No plan stage as CBR rejected"
expression_statement (+22 nodes collapsed)
declaration (+22 nodes collapsed)
expression_statement
call_expression
identifier "ASSERT_FALSE"
argument_list
( "("
field_expression
identifier "stats"
-> "->"
field_identifier "earlyExit"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
field_expression
identifier "stats"
-> "->"
field_identifier "numResultsFound"
, ","
number_literal "0"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
field_expression
identifier "stats"
-> "->"
field_identifier "numCandidatePlans"
, ","
number_literal "2"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_EQ"
argument_list
( "("
field_expression
identifier "stats"
-> "->"
field_identifier "totalWorks"
, ","
number_literal "20000"
) ")"
; ";"
expression_statement
call_expression
identifier "ASSERT_TRUE"
argument_list
( "("
field_expression
call_expression
field_expression
identifier "status"
. "."
field_identifier "getValue"
argument_list
( "("
) ")"
. "."
field_identifier "execState"
) ")"
; ";"
} "}"
function_definition (+447 nodes collapsed)
} "}"
comment "// namespace"
} "}"
comment "// namespace mongo"