summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests
diff options
context:
space:
mode:
authorRuoxin Xu <ruoxin.xu@mongodb.com>2021-10-11 13:40:09 +0100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-10-14 18:14:26 +0000
commite4c27a5c36dfe4c510809c8d1feb824a545b8b58 (patch)
tree770cfdef2cedf2894f7b5f1bd25a4d765769c666 /src/mongo/dbtests
parent257cf738d1d0fa3ec73446133dae8f6b5510b2c4 (diff)
downloadmongo-e4c27a5c36dfe4c510809c8d1feb824a545b8b58.tar.gz
SERVER-60338 Refine SBE query shape and implement plan cache key encoding
Diffstat (limited to 'src/mongo/dbtests')
-rw-r--r--src/mongo/dbtests/plan_ranking.cpp3
-rw-r--r--src/mongo/dbtests/query_stage_cached_plan.cpp24
-rw-r--r--src/mongo/dbtests/query_stage_multiplan.cpp6
3 files changed, 13 insertions, 20 deletions
diff --git a/src/mongo/dbtests/plan_ranking.cpp b/src/mongo/dbtests/plan_ranking.cpp
index 71fcee970c6..1972cd204be 100644
--- a/src/mongo/dbtests/plan_ranking.cpp
+++ b/src/mongo/dbtests/plan_ranking.cpp
@@ -250,8 +250,7 @@ public:
StatusWith<std::unique_ptr<PlanCacheEntry>> planCacheEntryWithStatus =
CollectionQueryInfo::get(collection.getCollection())
.getPlanCache()
- ->getEntry(
- plan_cache_key_factory::make<PlanCacheKey>(*cq, collection.getCollection()));
+ ->getEntry(plan_cache_key_factory::make(*cq, collection.getCollection()));
ASSERT_OK(planCacheEntryWithStatus.getStatus());
auto debugInfo = planCacheEntryWithStatus.getValue()->debugInfo;
ASSERT(debugInfo);
diff --git a/src/mongo/dbtests/query_stage_cached_plan.cpp b/src/mongo/dbtests/query_stage_cached_plan.cpp
index d3cf8bd8a63..edc47390edd 100644
--- a/src/mongo/dbtests/query_stage_cached_plan.cpp
+++ b/src/mongo/dbtests/query_stage_cached_plan.cpp
@@ -193,7 +193,7 @@ TEST_F(QueryStageCachedPlan, QueryStageCachedPlanFailureMemoryLimitExceeded) {
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand));
ASSERT_OK(statusWithCQ.getStatus());
const std::unique_ptr<CanonicalQuery> cq = std::move(statusWithCQ.getValue());
- auto key = plan_cache_key_factory::make<PlanCacheKey>(*cq, collection.getCollection());
+ auto key = plan_cache_key_factory::make(*cq, collection.getCollection());
// We shouldn't have anything in the plan cache for this shape yet.
PlanCache* cache = CollectionQueryInfo::get(collection.getCollection()).getPlanCache();
@@ -244,7 +244,7 @@ TEST_F(QueryStageCachedPlan, QueryStageCachedPlanHitMaxWorks) {
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand));
ASSERT_OK(statusWithCQ.getStatus());
const std::unique_ptr<CanonicalQuery> cq = std::move(statusWithCQ.getValue());
- auto key = plan_cache_key_factory::make<PlanCacheKey>(*cq, collection.getCollection());
+ auto key = plan_cache_key_factory::make(*cq, collection.getCollection());
// We shouldn't have anything in the plan cache for this shape yet.
PlanCache* cache = CollectionQueryInfo::get(collection.getCollection()).getPlanCache();
@@ -295,8 +295,7 @@ TEST_F(QueryStageCachedPlan, QueryStageCachedPlanAddsActiveCacheEntries) {
// CanonicalQueries created in this test will have this shape.
const auto shapeCq =
canonicalQueryFromFilterObj(opCtx(), nss, fromjson("{a: {$gte: 123}, b: {$gte: 123}}"));
- auto planCacheKey =
- plan_cache_key_factory::make<PlanCacheKey>(*shapeCq, collection.getCollection());
+ auto planCacheKey = plan_cache_key_factory::make(*shapeCq, collection.getCollection());
// Query can be answered by either index on "a" or index on "b".
const auto noResultsCq =
@@ -355,8 +354,7 @@ TEST_F(QueryStageCachedPlan, DeactivatesEntriesOnReplan) {
// CanonicalQueries created in this test will have this shape.
const auto shapeCq =
canonicalQueryFromFilterObj(opCtx(), nss, fromjson("{a: {$gte: 123}, b: {$gte: 123}}"));
- auto planCacheKey =
- plan_cache_key_factory::make<PlanCacheKey>(*shapeCq, collection.getCollection());
+ auto planCacheKey = plan_cache_key_factory::make(*shapeCq, collection.getCollection());
// Query can be answered by either index on "a" or index on "b".
const auto noResultsCq =
@@ -378,11 +376,9 @@ TEST_F(QueryStageCachedPlan, DeactivatesEntriesOnReplan) {
forceReplanning(collection.getCollection(), noResultsCq.get());
// The works should be 1 for the entry since the query we ran should not have any results.
- ASSERT_EQ(cache
- ->get(plan_cache_key_factory::make<PlanCacheKey>(*noResultsCq,
- collection.getCollection()))
- .state,
- PlanCache::CacheEntryState::kPresentActive);
+ ASSERT_EQ(
+ cache->get(plan_cache_key_factory::make(*noResultsCq, collection.getCollection())).state,
+ PlanCache::CacheEntryState::kPresentActive);
auto entry = assertGet(cache->getEntry(planCacheKey));
size_t works = 1U;
ASSERT_EQ(entry->works, works);
@@ -419,14 +415,12 @@ TEST_F(QueryStageCachedPlan, EntriesAreNotDeactivatedWhenInactiveEntriesDisabled
// CanonicalQueries created in this test will have this shape.
const auto shapeCq =
canonicalQueryFromFilterObj(opCtx(), nss, fromjson("{a: {$gte: 123}, b: {$gte: 123}}"));
- auto planCacheKey =
- plan_cache_key_factory::make<PlanCacheKey>(*shapeCq, collection.getCollection());
+ auto planCacheKey = plan_cache_key_factory::make(*shapeCq, collection.getCollection());
// Query can be answered by either index on "a" or index on "b".
const auto noResultsCq =
canonicalQueryFromFilterObj(opCtx(), nss, fromjson("{a: {$gte: 11}, b: {$gte: 11}}"));
- auto noResultKey =
- plan_cache_key_factory::make<PlanCacheKey>(*noResultsCq, collection.getCollection());
+ auto noResultKey = plan_cache_key_factory::make(*noResultsCq, collection.getCollection());
// We shouldn't have anything in the plan cache for this shape yet.
PlanCache* cache = CollectionQueryInfo::get(collection.getCollection()).getPlanCache();
diff --git a/src/mongo/dbtests/query_stage_multiplan.cpp b/src/mongo/dbtests/query_stage_multiplan.cpp
index eaf04add3f1..ec44604b6b5 100644
--- a/src/mongo/dbtests/query_stage_multiplan.cpp
+++ b/src/mongo/dbtests/query_stage_multiplan.cpp
@@ -299,7 +299,7 @@ TEST_F(QueryStageMultiPlanTest, MPSDoesNotCreateActiveCacheEntryImmediately) {
const CollectionPtr& coll = ctx.getCollection();
const auto cq = makeCanonicalQuery(_opCtx.get(), nss, BSON("foo" << 7));
- auto key = plan_cache_key_factory::make<PlanCacheKey>(*cq, coll);
+ auto key = plan_cache_key_factory::make(*cq, coll);
// Run an index scan and collection scan, searching for {foo: 7}.
auto mps = runMultiPlanner(_expCtx.get(), nss, coll, 7);
@@ -355,7 +355,7 @@ TEST_F(QueryStageMultiPlanTest, MPSDoesCreatesActiveEntryWhenInactiveEntriesDisa
const CollectionPtr& coll = ctx.getCollection();
const auto cq = makeCanonicalQuery(_opCtx.get(), nss, BSON("foo" << 7));
- auto key = plan_cache_key_factory::make<PlanCacheKey>(*cq, coll);
+ auto key = plan_cache_key_factory::make(*cq, coll);
// Run an index scan and collection scan, searching for {foo: 7}.
auto mps = runMultiPlanner(_expCtx.get(), nss, coll, 7);
@@ -390,7 +390,7 @@ TEST_F(QueryStageMultiPlanTest, MPSBackupPlan) {
verify(statusWithCQ.isOK());
unique_ptr<CanonicalQuery> cq = std::move(statusWithCQ.getValue());
ASSERT(nullptr != cq.get());
- auto key = plan_cache_key_factory::make<PlanCacheKey>(*cq, collection.getCollection());
+ auto key = plan_cache_key_factory::make(*cq, collection.getCollection());
// Force index intersection.
bool forceIxisectOldValue = internalQueryForceIntersectionPlans.load();