Skip to content

Commit 6ce6189

Browse files
committed
Move rules onto array vtable so we can optimize during construction without a session
Signed-off-by: Nicholas Gates <[email protected]>
1 parent 7c0b68f commit 6ce6189

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

vortex-array/src/optimizer/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ impl ArrayOptimizer for ArrayRef {
2828
Ok(self.clone().try_optimize()?.unwrap_or(self))
2929
}
3030

31+
#[expect(clippy::cognitive_complexity)]
3132
fn try_optimize(self) -> VortexResult<Option<ArrayRef>> {
3233
tracing::debug!(
3334
"Starting root-only array optimization\n{}",

vortex-array/src/optimizer/rules.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,10 @@ impl<V: VTable> ParentRuleSet<V> {
170170
) -> &'static dyn DynArrayParentReduceRule<V> {
171171
// Assert that self is zero-sized
172172
const {
173-
if size_of::<R>() != 0 {
174-
panic!("Rule must be zero-sized to be lifted")
175-
}
173+
assert!(
174+
!(size_of::<R>() != 0),
175+
"Rule must be zero-sized to be lifted"
176+
);
176177
}
177178
unsafe { &*(rule as *const R as *const ParentReduceRuleAdapter<V, R>) }
178179
}
@@ -185,10 +186,10 @@ impl<V: VTable> ParentRuleSet<V> {
185186
child_idx: usize,
186187
) -> VortexResult<Option<ArrayRef>> {
187188
for rule in self.rules.iter() {
188-
if let MatchKey::Array(id) = rule.parent_key() {
189-
if parent.encoding_id() != id {
190-
continue;
191-
}
189+
if let MatchKey::Array(id) = rule.parent_key()
190+
&& parent.encoding_id() != id
191+
{
192+
continue;
192193
}
193194
if let Some(reduced) = rule.reduce_parent(child, parent, child_idx)? {
194195
return Ok(Some(reduced));

0 commit comments

Comments
 (0)