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 { .. } | PhysicalPlan::GraphAlgorithmOutput(_) => {
47 PhysicalPlanKind::GraphAlgorithm
48 }
49 PhysicalPlan::VectorSeedScan { .. } => PhysicalPlanKind::VectorSeedScan,
50 PhysicalPlan::GraphSeedScan { .. } => PhysicalPlanKind::GraphSeedScan,
51 PhysicalPlan::VectorIndexScan(_) => PhysicalPlanKind::VectorIndexScan,
52 PhysicalPlan::TextSeedScan { .. } => PhysicalPlanKind::TextSeedScan,
53 PhysicalPlan::CreateNode { .. } => PhysicalPlanKind::CreateNode,
54 PhysicalPlan::UnwindExec { .. } => PhysicalPlanKind::UnwindExec,
55 PhysicalPlan::UnwindRowsExec { .. } => PhysicalPlanKind::UnwindRowsExec,
56 PhysicalPlan::UnwindMutation { .. } => PhysicalPlanKind::UnwindMutationExec,
57 PhysicalPlan::LoadCsvMutation { .. } => PhysicalPlanKind::LoadCsvMutationExec,
58 PhysicalPlan::MergeNode { .. } => PhysicalPlanKind::MergeNode,
59 PhysicalPlan::MergeRelationship { .. } => PhysicalPlanKind::MergeRelationship,
60 PhysicalPlan::MergeMatchedRelationship { .. } => {
61 PhysicalPlanKind::MergeMatchedRelationship
62 }
63 PhysicalPlan::MergeRelationshipFromMatchedRelationship { .. } => {
64 PhysicalPlanKind::MergeRelationshipFromMatchedRelationship
65 }
66 PhysicalPlan::MergeRelationshipToMatchedTarget { .. } => {
67 PhysicalPlanKind::MergeRelationshipToMatchedTarget
68 }
69 PhysicalPlan::MergeRelationshipFromMatchedTarget { .. } => {
70 PhysicalPlanKind::MergeRelationshipFromMatchedTarget
71 }
72 PhysicalPlan::CreateMatchedRelationship { .. } => {
73 PhysicalPlanKind::CreateMatchedRelationship
74 }
75 PhysicalPlan::SetNodeProperty { .. } => PhysicalPlanKind::SetNodeProperty,
76 PhysicalPlan::SetNodeProperties { .. } => PhysicalPlanKind::SetNodeProperties,
77 PhysicalPlan::SetNodePropertiesReturn { .. } => {
78 PhysicalPlanKind::SetNodePropertiesReturn
79 }
80 PhysicalPlan::SetRelationshipProperty { .. } => {
81 PhysicalPlanKind::SetRelationshipProperty
82 }
83 PhysicalPlan::SetRelationshipProperties { .. } => {
84 PhysicalPlanKind::SetRelationshipProperties
85 }
86 PhysicalPlan::DeleteNode { .. } => PhysicalPlanKind::DeleteNode,
87 PhysicalPlan::DeleteRelationship { .. } => PhysicalPlanKind::DeleteRelationship,
88 PhysicalPlan::DeleteRelationshipTargetNodes { .. } => {
89 PhysicalPlanKind::DeleteRelationshipTargetNodes
90 }
91 PhysicalPlan::CreateRelationship { .. } => PhysicalPlanKind::CreateRelationship,
92 PhysicalPlan::GraphMatchExec { .. } => PhysicalPlanKind::GraphMatchExec,
93 PhysicalPlan::EmptyExec => PhysicalPlanKind::EmptyExec,
94 PhysicalPlan::LoadCsvExec { .. } => PhysicalPlanKind::LoadCsvExec,
95 PhysicalPlan::SeqNodeScan { .. } => PhysicalPlanKind::SeqNodeScan,
96 PhysicalPlan::NodeProjectionScanExec { .. } => PhysicalPlanKind::NodeProjectionScanExec,
97 PhysicalPlan::SourceSegmentScan { .. } => PhysicalPlanKind::SourceSegmentScan,
98 PhysicalPlan::HashJoinExec { .. } => PhysicalPlanKind::HashJoinExec,
99 PhysicalPlan::NodeCartesianProductExec { .. } => {
100 PhysicalPlanKind::NodeCartesianProductExec
101 }
102 PhysicalPlan::NodeColumnLookupExec { .. } => PhysicalPlanKind::NodeColumnLookupExec,
103 PhysicalPlan::IndexNodeSeek { .. } => PhysicalPlanKind::IndexNodeSeek,
104 PhysicalPlan::IndexNodeMultiSeek { .. } => PhysicalPlanKind::IndexNodeMultiSeek,
105 PhysicalPlan::IndexNodeUnionSeek { .. } => PhysicalPlanKind::IndexNodeUnionSeek,
106 PhysicalPlan::IndexNodeCompositeSeek { .. } => PhysicalPlanKind::IndexNodeCompositeSeek,
107 PhysicalPlan::IndexNodeCompositeRangeSeek { .. } => {
108 PhysicalPlanKind::IndexNodeCompositeRangeSeek
109 }
110 PhysicalPlan::IndexNodeRangeSeek { .. } => PhysicalPlanKind::IndexNodeRangeSeek,
111 PhysicalPlan::IndexNodeTextSeek { .. } => PhysicalPlanKind::IndexNodeTextSeek,
112 PhysicalPlan::AdjacencyExpandExec { .. } => PhysicalPlanKind::AdjacencyExpandExec,
113 PhysicalPlan::AdjacencyExistsExec { .. } => PhysicalPlanKind::AdjacencyExistsExec,
114 PhysicalPlan::OptionalDegreeExec { .. } => PhysicalPlanKind::OptionalDegreeExec,
115 PhysicalPlan::OptionalRelationshipCountSumExec { .. } => {
116 PhysicalPlanKind::OptionalRelationshipCountSumExec
117 }
118 PhysicalPlan::NodeCountExec { .. } => PhysicalPlanKind::NodeCountExec,
119 PhysicalPlan::RelationshipCountExec { .. } => PhysicalPlanKind::RelationshipCountExec,
120 PhysicalPlan::ThreadRepairStatsExec { .. } => PhysicalPlanKind::ThreadRepairStatsExec,
121 PhysicalPlan::ShortestPathExec { .. } => PhysicalPlanKind::ShortestPathExec,
122 PhysicalPlan::FilterExec { .. } => PhysicalPlanKind::FilterExec,
123 PhysicalPlan::ProjectExec { .. } => PhysicalPlanKind::ProjectExec,
124 PhysicalPlan::AggregateExec { .. } => PhysicalPlanKind::AggregateExec,
125 PhysicalPlan::DistinctExec { .. } => PhysicalPlanKind::DistinctExec,
126 PhysicalPlan::SortExec { .. } => PhysicalPlanKind::SortExec,
127 PhysicalPlan::TopNExec { .. } => PhysicalPlanKind::TopNExec,
128 PhysicalPlan::LimitExec { .. } => PhysicalPlanKind::LimitExec,
129 PhysicalPlan::ScoringRerankExec { .. } => PhysicalPlanKind::ScoringRerankExec,
130 PhysicalPlan::ScoringProgramExec { .. } => PhysicalPlanKind::ScoringProgramExec,
131 PhysicalPlan::HostScoringExec { .. } => PhysicalPlanKind::HostScoringExec,
132 }
133 }
134
135 pub fn class(&self) -> PhysicalPlanClass {
136 self.kind().class()
137 }
138
139 pub fn children(&self) -> PhysicalPlanChildren<'_> {
140 match self {
141 PhysicalPlan::VectorIndexScan(scan) => scan
142 .input
143 .as_deref()
144 .map_or(PlanChildren::None, PlanChildren::Unary),
145 PhysicalPlan::GraphMatchExec { input, .. } => input
146 .as_deref()
147 .map_or(PlanChildren::None, PlanChildren::Unary),
148 PhysicalPlan::NodeCartesianProductExec { left, right }
149 | PhysicalPlan::HashJoinExec { left, right, .. } => PlanChildren::Binary(left, right),
150 PhysicalPlan::NodeColumnLookupExec { input, .. }
151 | PhysicalPlan::UnwindRowsExec { input, .. }
152 | PhysicalPlan::AdjacencyExpandExec { input, .. }
153 | PhysicalPlan::AdjacencyExistsExec { input, .. }
154 | PhysicalPlan::OptionalDegreeExec { input, .. }
155 | PhysicalPlan::FilterExec { input, .. }
156 | PhysicalPlan::ProjectExec { input, .. }
157 | PhysicalPlan::AggregateExec { input, .. }
158 | PhysicalPlan::DistinctExec { input }
159 | PhysicalPlan::SortExec { input, .. }
160 | PhysicalPlan::TopNExec { input, .. }
161 | PhysicalPlan::LimitExec { input, .. }
162 | PhysicalPlan::ScoringRerankExec { input, .. }
163 | PhysicalPlan::ScoringProgramExec { input, .. }
164 | PhysicalPlan::HostScoringExec { input, .. } => PlanChildren::Unary(input),
165 PhysicalPlan::CreateNodeLabel { .. }
166 | PhysicalPlan::CreateRelationshipType { .. }
167 | PhysicalPlan::CreateNodeTable { .. }
168 | PhysicalPlan::CreateRelationshipTable { .. }
169 | PhysicalPlan::CreateProperty { .. }
170 | PhysicalPlan::AlterTableState { .. }
171 | PhysicalPlan::AlterPropertyState { .. }
172 | PhysicalPlan::CreateIndex { .. }
173 | PhysicalPlan::CreateCompositeIndex { .. }
174 | PhysicalPlan::CreateRangeIndex { .. }
175 | PhysicalPlan::CreateFullTextIndex { .. }
176 | PhysicalPlan::CreateUniqueConstraint { .. }
177 | PhysicalPlan::CreateNodePropertyExistsConstraint { .. }
178 | PhysicalPlan::CreateRelationshipUniqueConstraint { .. }
179 | PhysicalPlan::CreateRelationshipPropertyExistsConstraint { .. }
180 | PhysicalPlan::ProjectGraph { .. }
181 | PhysicalPlan::GraphAlgorithm { .. }
182 | PhysicalPlan::GraphAlgorithmOutput(_)
183 | PhysicalPlan::VectorSeedScan { .. }
184 | PhysicalPlan::GraphSeedScan { .. }
185 | PhysicalPlan::TextSeedScan { .. }
186 | PhysicalPlan::CreateNode { .. }
187 | PhysicalPlan::UnwindMutation { .. }
188 | PhysicalPlan::LoadCsvMutation { .. }
189 | PhysicalPlan::MergeNode { .. }
190 | PhysicalPlan::MergeRelationship { .. }
191 | PhysicalPlan::MergeMatchedRelationship { .. }
192 | PhysicalPlan::MergeRelationshipFromMatchedRelationship { .. }
193 | PhysicalPlan::MergeRelationshipToMatchedTarget { .. }
194 | PhysicalPlan::MergeRelationshipFromMatchedTarget { .. }
195 | PhysicalPlan::CreateMatchedRelationship { .. }
196 | PhysicalPlan::SetNodeProperty { .. }
197 | PhysicalPlan::SetNodeProperties { .. }
198 | PhysicalPlan::SetNodePropertiesReturn { .. }
199 | PhysicalPlan::SetRelationshipProperty { .. }
200 | PhysicalPlan::SetRelationshipProperties { .. }
201 | PhysicalPlan::DeleteNode { .. }
202 | PhysicalPlan::DeleteRelationship { .. }
203 | PhysicalPlan::DeleteRelationshipTargetNodes { .. }
204 | PhysicalPlan::CreateRelationship { .. }
205 | PhysicalPlan::UnwindExec { .. }
206 | PhysicalPlan::EmptyExec
207 | PhysicalPlan::LoadCsvExec { .. }
208 | PhysicalPlan::SeqNodeScan { .. }
209 | PhysicalPlan::NodeProjectionScanExec { .. }
210 | PhysicalPlan::SourceSegmentScan { .. }
211 | PhysicalPlan::IndexNodeSeek { .. }
212 | PhysicalPlan::IndexNodeMultiSeek { .. }
213 | PhysicalPlan::IndexNodeUnionSeek { .. }
214 | PhysicalPlan::IndexNodeCompositeSeek { .. }
215 | PhysicalPlan::IndexNodeCompositeRangeSeek { .. }
216 | PhysicalPlan::IndexNodeRangeSeek { .. }
217 | PhysicalPlan::IndexNodeTextSeek { .. }
218 | PhysicalPlan::OptionalRelationshipCountSumExec { .. }
219 | PhysicalPlan::NodeCountExec { .. }
220 | PhysicalPlan::RelationshipCountExec { .. }
221 | PhysicalPlan::ThreadRepairStatsExec { .. }
222 | PhysicalPlan::ShortestPathExec { .. } => PlanChildren::None,
223 }
224 }
225}
226
227impl PhysicalPlanNode for PhysicalPlan {
228 fn kind(&self) -> PhysicalPlanKind {
229 PhysicalPlan::kind(self)
230 }
231
232 fn children(&self) -> PhysicalPlanChildren<'_> {
233 PhysicalPlan::children(self)
234 }
235}