hawdb_plan_cypher/physical/
plan_node.rs1use super::{PhysicalPlan, PhysicalPlanClass, PhysicalPlanKind, PhysicalPlanNode, PlanChildren};
16
17pub type PhysicalPlanChildren<'a> = PlanChildren<'a, PhysicalPlan>;
18
19impl PhysicalPlan {
20 pub fn kind(&self) -> PhysicalPlanKind {
21 match self {
22 PhysicalPlan::CreateNodeLabel { .. } => PhysicalPlanKind::CreateNodeLabel,
23 PhysicalPlan::CreateRelationshipType { .. } => PhysicalPlanKind::CreateRelationshipType,
24 PhysicalPlan::CreateNodeTable { .. } => PhysicalPlanKind::CreateNodeTable,
25 PhysicalPlan::CreateRelationshipTable { .. } => {
26 PhysicalPlanKind::CreateRelationshipTable
27 }
28 PhysicalPlan::CreateProperty { .. } => PhysicalPlanKind::CreateProperty,
29 PhysicalPlan::AlterTableState { .. } => PhysicalPlanKind::AlterTableState,
30 PhysicalPlan::AlterPropertyState { .. } => PhysicalPlanKind::AlterPropertyState,
31 PhysicalPlan::CreateIndex { .. } => PhysicalPlanKind::CreateIndex,
32 PhysicalPlan::CreateCompositeIndex { .. } => PhysicalPlanKind::CreateCompositeIndex,
33 PhysicalPlan::CreateRangeIndex { .. } => PhysicalPlanKind::CreateRangeIndex,
34 PhysicalPlan::CreateFullTextIndex { .. } => PhysicalPlanKind::CreateFullTextIndex,
35 PhysicalPlan::CreateUniqueConstraint { .. } => PhysicalPlanKind::CreateUniqueConstraint,
36 PhysicalPlan::CreateNodePropertyExistsConstraint { .. } => {
37 PhysicalPlanKind::CreateNodePropertyExistsConstraint
38 }
39 PhysicalPlan::CreateRelationshipUniqueConstraint { .. } => {
40 PhysicalPlanKind::CreateRelationshipUniqueConstraint
41 }
42 PhysicalPlan::CreateRelationshipPropertyExistsConstraint { .. } => {
43 PhysicalPlanKind::CreateRelationshipPropertyExistsConstraint
44 }
45 PhysicalPlan::ProjectGraph { .. } => PhysicalPlanKind::ProjectGraph,
46 PhysicalPlan::GraphAlgorithm { .. } => PhysicalPlanKind::GraphAlgorithm,
47 PhysicalPlan::VectorSeedScan { .. } => PhysicalPlanKind::VectorSeedScan,
48 PhysicalPlan::CreateNode { .. } => PhysicalPlanKind::CreateNode,
49 PhysicalPlan::UnwindMutation { .. } => PhysicalPlanKind::UnwindMutationExec,
50 PhysicalPlan::MergeNode { .. } => PhysicalPlanKind::MergeNode,
51 PhysicalPlan::MergeRelationship { .. } => PhysicalPlanKind::MergeRelationship,
52 PhysicalPlan::MergeMatchedRelationship { .. } => {
53 PhysicalPlanKind::MergeMatchedRelationship
54 }
55 PhysicalPlan::MergeRelationshipFromMatchedRelationship { .. } => {
56 PhysicalPlanKind::MergeRelationshipFromMatchedRelationship
57 }
58 PhysicalPlan::MergeRelationshipToMatchedTarget { .. } => {
59 PhysicalPlanKind::MergeRelationshipToMatchedTarget
60 }
61 PhysicalPlan::MergeRelationshipFromMatchedTarget { .. } => {
62 PhysicalPlanKind::MergeRelationshipFromMatchedTarget
63 }
64 PhysicalPlan::CreateMatchedRelationship { .. } => {
65 PhysicalPlanKind::CreateMatchedRelationship
66 }
67 PhysicalPlan::SetNodeProperty { .. } => PhysicalPlanKind::SetNodeProperty,
68 PhysicalPlan::SetNodeProperties { .. } => PhysicalPlanKind::SetNodeProperties,
69 PhysicalPlan::SetNodePropertiesReturn { .. } => {
70 PhysicalPlanKind::SetNodePropertiesReturn
71 }
72 PhysicalPlan::SetRelationshipProperty { .. } => {
73 PhysicalPlanKind::SetRelationshipProperty
74 }
75 PhysicalPlan::SetRelationshipProperties { .. } => {
76 PhysicalPlanKind::SetRelationshipProperties
77 }
78 PhysicalPlan::DeleteNode { .. } => PhysicalPlanKind::DeleteNode,
79 PhysicalPlan::DeleteRelationship { .. } => PhysicalPlanKind::DeleteRelationship,
80 PhysicalPlan::DeleteRelationshipTargetNodes { .. } => {
81 PhysicalPlanKind::DeleteRelationshipTargetNodes
82 }
83 PhysicalPlan::CreateRelationship { .. } => PhysicalPlanKind::CreateRelationship,
84 PhysicalPlan::GraphMatchExec { .. } => PhysicalPlanKind::GraphMatchExec,
85 PhysicalPlan::EmptyExec => PhysicalPlanKind::EmptyExec,
86 PhysicalPlan::SeqNodeScan { .. } => PhysicalPlanKind::SeqNodeScan,
87 PhysicalPlan::NodeProjectionScanExec { .. } => PhysicalPlanKind::NodeProjectionScanExec,
88 PhysicalPlan::SourceSegmentScan { .. } => PhysicalPlanKind::SourceSegmentScan,
89 PhysicalPlan::HashJoinExec { .. } => PhysicalPlanKind::HashJoinExec,
90 PhysicalPlan::NodeCartesianProductExec { .. } => {
91 PhysicalPlanKind::NodeCartesianProductExec
92 }
93 PhysicalPlan::NodeColumnLookupExec { .. } => PhysicalPlanKind::NodeColumnLookupExec,
94 PhysicalPlan::IndexNodeSeek { .. } => PhysicalPlanKind::IndexNodeSeek,
95 PhysicalPlan::IndexNodeMultiSeek { .. } => PhysicalPlanKind::IndexNodeMultiSeek,
96 PhysicalPlan::IndexNodeUnionSeek { .. } => PhysicalPlanKind::IndexNodeUnionSeek,
97 PhysicalPlan::IndexNodeCompositeSeek { .. } => PhysicalPlanKind::IndexNodeCompositeSeek,
98 PhysicalPlan::IndexNodeCompositeRangeSeek { .. } => {
99 PhysicalPlanKind::IndexNodeCompositeRangeSeek
100 }
101 PhysicalPlan::IndexNodeRangeSeek { .. } => PhysicalPlanKind::IndexNodeRangeSeek,
102 PhysicalPlan::IndexNodeTextSeek { .. } => PhysicalPlanKind::IndexNodeTextSeek,
103 PhysicalPlan::AdjacencyExpandExec { .. } => PhysicalPlanKind::AdjacencyExpandExec,
104 PhysicalPlan::AdjacencyExistsExec { .. } => PhysicalPlanKind::AdjacencyExistsExec,
105 PhysicalPlan::OptionalDegreeExec { .. } => PhysicalPlanKind::OptionalDegreeExec,
106 PhysicalPlan::OptionalRelationshipCountSumExec { .. } => {
107 PhysicalPlanKind::OptionalRelationshipCountSumExec
108 }
109 PhysicalPlan::NodeCountExec { .. } => PhysicalPlanKind::NodeCountExec,
110 PhysicalPlan::RelationshipCountExec { .. } => PhysicalPlanKind::RelationshipCountExec,
111 PhysicalPlan::ThreadRepairStatsExec { .. } => PhysicalPlanKind::ThreadRepairStatsExec,
112 PhysicalPlan::ShortestPathExec { .. } => PhysicalPlanKind::ShortestPathExec,
113 PhysicalPlan::FilterExec { .. } => PhysicalPlanKind::FilterExec,
114 PhysicalPlan::ProjectExec { .. } => PhysicalPlanKind::ProjectExec,
115 PhysicalPlan::AggregateExec { .. } => PhysicalPlanKind::AggregateExec,
116 PhysicalPlan::DistinctExec { .. } => PhysicalPlanKind::DistinctExec,
117 PhysicalPlan::SortExec { .. } => PhysicalPlanKind::SortExec,
118 PhysicalPlan::TopNExec { .. } => PhysicalPlanKind::TopNExec,
119 PhysicalPlan::LimitExec { .. } => PhysicalPlanKind::LimitExec,
120 PhysicalPlan::ScoringRerankExec { .. } => PhysicalPlanKind::ScoringRerankExec,
121 }
122 }
123
124 pub fn class(&self) -> PhysicalPlanClass {
125 self.kind().class()
126 }
127
128 pub fn children(&self) -> PhysicalPlanChildren<'_> {
129 match self {
130 PhysicalPlan::GraphMatchExec { input, .. } => input
131 .as_deref()
132 .map_or(PlanChildren::None, PlanChildren::Unary),
133 PhysicalPlan::NodeCartesianProductExec { left, right }
134 | PhysicalPlan::HashJoinExec { left, right, .. } => PlanChildren::Binary(left, right),
135 PhysicalPlan::NodeColumnLookupExec { input, .. }
136 | PhysicalPlan::AdjacencyExpandExec { input, .. }
137 | PhysicalPlan::AdjacencyExistsExec { input, .. }
138 | PhysicalPlan::OptionalDegreeExec { input, .. }
139 | PhysicalPlan::FilterExec { input, .. }
140 | PhysicalPlan::ProjectExec { input, .. }
141 | PhysicalPlan::AggregateExec { input, .. }
142 | PhysicalPlan::DistinctExec { input }
143 | PhysicalPlan::SortExec { input, .. }
144 | PhysicalPlan::TopNExec { input, .. }
145 | PhysicalPlan::LimitExec { input, .. }
146 | PhysicalPlan::ScoringRerankExec { input, .. } => PlanChildren::Unary(input),
147 PhysicalPlan::CreateNodeLabel { .. }
148 | PhysicalPlan::CreateRelationshipType { .. }
149 | PhysicalPlan::CreateNodeTable { .. }
150 | PhysicalPlan::CreateRelationshipTable { .. }
151 | PhysicalPlan::CreateProperty { .. }
152 | PhysicalPlan::AlterTableState { .. }
153 | PhysicalPlan::AlterPropertyState { .. }
154 | PhysicalPlan::CreateIndex { .. }
155 | PhysicalPlan::CreateCompositeIndex { .. }
156 | PhysicalPlan::CreateRangeIndex { .. }
157 | PhysicalPlan::CreateFullTextIndex { .. }
158 | PhysicalPlan::CreateUniqueConstraint { .. }
159 | PhysicalPlan::CreateNodePropertyExistsConstraint { .. }
160 | PhysicalPlan::CreateRelationshipUniqueConstraint { .. }
161 | PhysicalPlan::CreateRelationshipPropertyExistsConstraint { .. }
162 | PhysicalPlan::ProjectGraph { .. }
163 | PhysicalPlan::GraphAlgorithm { .. }
164 | PhysicalPlan::VectorSeedScan { .. }
165 | PhysicalPlan::CreateNode { .. }
166 | PhysicalPlan::UnwindMutation { .. }
167 | PhysicalPlan::MergeNode { .. }
168 | PhysicalPlan::MergeRelationship { .. }
169 | PhysicalPlan::MergeMatchedRelationship { .. }
170 | PhysicalPlan::MergeRelationshipFromMatchedRelationship { .. }
171 | PhysicalPlan::MergeRelationshipToMatchedTarget { .. }
172 | PhysicalPlan::MergeRelationshipFromMatchedTarget { .. }
173 | PhysicalPlan::CreateMatchedRelationship { .. }
174 | PhysicalPlan::SetNodeProperty { .. }
175 | PhysicalPlan::SetNodeProperties { .. }
176 | PhysicalPlan::SetNodePropertiesReturn { .. }
177 | PhysicalPlan::SetRelationshipProperty { .. }
178 | PhysicalPlan::SetRelationshipProperties { .. }
179 | PhysicalPlan::DeleteNode { .. }
180 | PhysicalPlan::DeleteRelationship { .. }
181 | PhysicalPlan::DeleteRelationshipTargetNodes { .. }
182 | PhysicalPlan::CreateRelationship { .. }
183 | PhysicalPlan::EmptyExec
184 | PhysicalPlan::SeqNodeScan { .. }
185 | PhysicalPlan::NodeProjectionScanExec { .. }
186 | PhysicalPlan::SourceSegmentScan { .. }
187 | PhysicalPlan::IndexNodeSeek { .. }
188 | PhysicalPlan::IndexNodeMultiSeek { .. }
189 | PhysicalPlan::IndexNodeUnionSeek { .. }
190 | PhysicalPlan::IndexNodeCompositeSeek { .. }
191 | PhysicalPlan::IndexNodeCompositeRangeSeek { .. }
192 | PhysicalPlan::IndexNodeRangeSeek { .. }
193 | PhysicalPlan::IndexNodeTextSeek { .. }
194 | PhysicalPlan::OptionalRelationshipCountSumExec { .. }
195 | PhysicalPlan::NodeCountExec { .. }
196 | PhysicalPlan::RelationshipCountExec { .. }
197 | PhysicalPlan::ThreadRepairStatsExec { .. }
198 | PhysicalPlan::ShortestPathExec { .. } => PlanChildren::None,
199 }
200 }
201}
202
203impl PhysicalPlanNode for PhysicalPlan {
204 fn kind(&self) -> PhysicalPlanKind {
205 PhysicalPlan::kind(self)
206 }
207
208 fn children(&self) -> PhysicalPlanChildren<'_> {
209 PhysicalPlan::children(self)
210 }
211}