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