Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

Commit 342f2fb

Browse files
authored
refactor(core): drop predicate binding interfaces (#236)
They are not used any more after the predicate refactor. Signed-off-by: Alex Chi <[email protected]>
1 parent b4061b1 commit 342f2fb

File tree

2 files changed

+0
-70
lines changed

2 files changed

+0
-70
lines changed

optd-core/src/cascades/memo.rs

-63
Original file line numberDiff line numberDiff line change
@@ -158,24 +158,6 @@ pub trait Memo<T: NodeType>: 'static + Send + Sync {
158158
) -> Result<ArcPlanNode<T>> {
159159
get_best_group_binding_inner(self, group_id, &mut post_process)
160160
}
161-
162-
/// Get all bindings of a predicate group. Will panic if the group contains more than one
163-
/// bindings. Note that we are currently in the refactor process of having predicates as a
164-
/// separate entity. If the representation stores predicates in the rel node children, the
165-
/// repr should use this function to get the predicate binding. Otherwise, use `ger_pred`
166-
/// for those predicates stored within the `predicates` field.
167-
///
168-
/// TODO: this can be removed after the predicate refactor, unless someone comes up with a
169-
/// plan representation that embeds predicates in the plan node.
170-
fn get_predicate_binding(&self, group_id: GroupId) -> Option<ArcPlanNode<T>> {
171-
get_predicate_binding_group_inner(self, group_id, true)
172-
}
173-
174-
/// Get all bindings of a predicate group. Returns None if the group contains zero or more than
175-
/// one bindings.
176-
fn try_get_predicate_binding(&self, group_id: GroupId) -> Option<ArcPlanNode<T>> {
177-
get_predicate_binding_group_inner(self, group_id, false)
178-
}
179161
}
180162

181163
fn get_best_group_binding_inner<M: Memo<T> + ?Sized, T: NodeType>(
@@ -204,51 +186,6 @@ fn get_best_group_binding_inner<M: Memo<T> + ?Sized, T: NodeType>(
204186
bail!("no best group binding for group {}", group_id)
205187
}
206188

207-
fn get_predicate_binding_expr_inner<M: Memo<T> + ?Sized, T: NodeType>(
208-
this: &M,
209-
expr_id: ExprId,
210-
panic_on_invalid_group: bool,
211-
) -> Option<ArcPlanNode<T>> {
212-
let expr = this.get_expr_memoed(expr_id);
213-
let mut children = Vec::with_capacity(expr.children.len());
214-
for child in expr.children.iter() {
215-
if let Some(child) = get_predicate_binding_group_inner(this, *child, panic_on_invalid_group)
216-
{
217-
children.push(PlanNodeOrGroup::PlanNode(child));
218-
} else {
219-
return None;
220-
}
221-
}
222-
Some(Arc::new(PlanNode {
223-
typ: expr.typ.clone(),
224-
children,
225-
predicates: expr.predicates.iter().map(|x| this.get_pred(*x)).collect(),
226-
}))
227-
}
228-
229-
fn get_predicate_binding_group_inner<M: Memo<T> + ?Sized, T: NodeType>(
230-
this: &M,
231-
group_id: GroupId,
232-
panic_on_invalid_group: bool,
233-
) -> Option<ArcPlanNode<T>> {
234-
let exprs = this.get_all_exprs_in_group(group_id);
235-
match exprs.len() {
236-
0 => None,
237-
1 => get_predicate_binding_expr_inner(
238-
this,
239-
exprs.first().copied().unwrap(),
240-
panic_on_invalid_group,
241-
),
242-
len => {
243-
if panic_on_invalid_group {
244-
panic!("group {group_id} has {len} expressions")
245-
} else {
246-
None
247-
}
248-
}
249-
}
250-
}
251-
252189
/// A naive, simple, and unoptimized memo table implementation.
253190
pub struct NaiveMemo<T: NodeType> {
254191
// Source of truth.

optd-core/src/cascades/optimizer.rs

-7
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,6 @@ impl<T: NodeType, M: Memo<T>> CascadesOptimizer<T, M> {
196196
group.properties[id].as_ref()
197197
)
198198
}
199-
if let Some(predicate_binding) = self.memo.try_get_predicate_binding(group_id) {
200-
println!(" predicate={}", predicate_binding);
201-
}
202199
let mut all_predicates = BTreeSet::new();
203200
for expr_id in self.memo.get_all_exprs_in_group(group_id) {
204201
let memo_node = self.memo.get_expr_memoed(expr_id);
@@ -348,10 +345,6 @@ impl<T: NodeType, M: Memo<T>> CascadesOptimizer<T, M> {
348345
self.memo.get_expr_memoed(expr_id)
349346
}
350347

351-
pub fn get_predicate_binding(&self, group_id: GroupId) -> Option<ArcPlanNode<T>> {
352-
self.memo.get_predicate_binding(group_id)
353-
}
354-
355348
pub fn get_pred(&self, pred_id: PredId) -> ArcPredNode<T> {
356349
self.memo.get_pred(pred_id)
357350
}

0 commit comments

Comments
 (0)