Skip to content

Commit

Permalink
Eliminate some typ() calls and an arity() call from MIR lowering
Browse files Browse the repository at this point in the history
  • Loading branch information
ggevay committed Jan 6, 2025
1 parent 0498dcc commit 7263f55
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/compute-types/src/plan/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -769,16 +769,20 @@ This is not expected to cause incorrect results, but could indicate a performanc
)
}
MirRelationExpr::Threshold { input } => {
let arity = input.arity();
let (plan, keys) = self.lower_mir_expr(input)?;
let arity = keys
.types
.as_ref()
.map(|types| types.len())
.unwrap_or_else(|| input.arity());
let (threshold_plan, required_arrangement) = ThresholdPlan::create_from(arity);
let mut types = keys.types.clone();
let plan = if !keys
.arranged
.iter()
.any(|(key, _, _)| key == &required_arrangement.0)
{
types = Some(input.typ().column_types);
types = Some(types.unwrap_or_else(|| input.typ().column_types));
self.arrange_by(
plan,
AvailableCollections::new_arranged(
Expand Down Expand Up @@ -837,10 +841,13 @@ This is not expected to cause incorrect results, but could indicate a performanc
)
}
MirRelationExpr::ArrangeBy { input, keys } => {
let arity = input.arity();
let types = Some(input.typ().column_types);
let input_mir = input;
let (input, mut input_keys) = self.lower_mir_expr(input)?;
input_keys.types = types;
// Fill the `types` in `input_keys` if not already present.
let input_types = input_keys
.types
.get_or_insert_with(|| input_mir.typ().column_types);
let arity = input_types.len();

// Determine keys that are not present in `input_keys`.
let new_keys = keys
Expand Down

0 comments on commit 7263f55

Please sign in to comment.