Package io.trino.sql.planner.iterative
Class Memo
- java.lang.Object
-
- io.trino.sql.planner.iterative.Memo
-
public class Memo extends Object
Stores a plan in a form that's efficient to mutate locally (i.e. without having to do full ancestor tree rewrites due to plan nodes being immutable).Each node in a plan is placed in a group, and it's children are replaced with symbolic references to the corresponding groups.
For example, a plan like:
A -> B -> C -> D \> E -> Fwould be stored as:root: G0 G0 : { A -> G1 } G1 : { B -> [G2, G3] } G2 : { C -> G4 } G3 : { E -> G5 } G4 : { D } G5 : { F }Groups are reference-counted, and groups that become unreachable from the root due to mutations in a subtree get garbage-collected.
-
-
Constructor Summary
Constructors Constructor Description Memo(PlanNodeIdAllocator idAllocator, PlanNode plan)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PlanNodeextract()Optional<PlanCostEstimate>getCost(int group)intgetGroupCount()PlanNodegetNode(int group)intgetRootGroup()Optional<PlanNodeStatsEstimate>getStats(int group)PlanNodereplace(int groupId, PlanNode node, String reason)PlanNoderesolve(GroupReference groupReference)voidstoreCost(int group, PlanCostEstimate cost)voidstoreStats(int groupId, PlanNodeStatsEstimate stats)
-
-
-
Constructor Detail
-
Memo
public Memo(PlanNodeIdAllocator idAllocator, PlanNode plan)
-
-
Method Detail
-
getRootGroup
public int getRootGroup()
-
getNode
public PlanNode getNode(int group)
-
resolve
public PlanNode resolve(GroupReference groupReference)
-
extract
public PlanNode extract()
-
getStats
public Optional<PlanNodeStatsEstimate> getStats(int group)
-
storeStats
public void storeStats(int groupId, PlanNodeStatsEstimate stats)
-
getCost
public Optional<PlanCostEstimate> getCost(int group)
-
storeCost
public void storeCost(int group, PlanCostEstimate cost)
-
getGroupCount
public int getGroupCount()
-
-