We plan to make the current PlanCache more generic so that it can be used to implement both the existing plan cache for the classic engine, as well as the SBE plan cache. We will have a PlanCacheBase<KeyType, CachedPlanType> base class which has template parameters for the type of the plan cache key as well as the type of cached plan. The SBE/classic plan classes will each instantiate this template class.
As a first step, we need to do a bit of surgery to the current PlanCache in order to turn it into a template class. We should try to do this as mechanically as possible to keep this first patch relatively simple. A few notes:
- There will be a lot of code motion here. We need to move most of the code in plan_cache.cpp into the header file in order to templatize the necessary types.
- Right now you can't use logv2 from a header file. We'll have to deal with this. We handled this elsewhere by making the templated code call simple helper functions to do the logging. Example here.
- You'll need to turn not only PlanCache but also CachedSolution and PlanCacheEntry into template classes.
- This patch won't actually interact at all with the SBE plan cache just yet. We will have template instantiations only for the classic engine. This is just prep work.