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