Skip to content

Commit 81eaec2

Browse files
committed
wip
Signed-off-by: Joe Isaacs <[email protected]>
1 parent 7fae39a commit 81eaec2

File tree

1 file changed

+14
-35
lines changed

1 file changed

+14
-35
lines changed

encodings/alp/src/alp/compute/expr_pushdown.rs

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
use vortex_array::arrays::{ConstantArray, ExprArray, ExprVTable};
55
use vortex_array::compute::Operator;
6-
use vortex_array::expr::{Binary, Literal, Root, VTableExt, lit, root};
6+
use vortex_array::expr::{lit, root, Binary, Literal, Root, VTableExt};
77
use vortex_array::transform::{ArrayParentReduceRule, ArrayRuleContext};
88
use vortex_array::{ArrayRef, IntoArray};
9-
use vortex_error::{VortexExpect, VortexResult};
10-
use vortex_scalar::{PrimitiveScalar, Scalar};
9+
use vortex_error::VortexResult;
10+
use vortex_scalar::Scalar;
1111

12-
use super::compare_common::{EncodedComparison, encode_for_comparison};
13-
use crate::{ALPArray, ALPFloat, ALPVTable, match_each_alp_float_ptype};
12+
use super::compare_common::{encode_for_comparison, EncodedComparison};
13+
use crate::{match_each_alp_float_ptype, ALPArray, ALPFloat, ALPVTable};
1414

1515
/// Rule to push down comparison operations into the ALP compressed domain.
1616
///
@@ -39,6 +39,7 @@ use crate::{ALPArray, ALPFloat, ALPVTable, match_each_alp_float_ptype};
3939
/// Note: The operator may change (e.g., `>` becomes `>=`) when the scalar doesn't
4040
/// encode exactly in the ALP domain. This follows the exact same logic as
4141
/// `alp_scalar_compare` in `compare.rs`.
42+
#[derive(Debug)]
4243
pub struct ALPExprPushdownRule;
4344

4445
impl ArrayParentReduceRule<ALPVTable, ExprVTable> for ALPExprPushdownRule {
@@ -129,12 +130,12 @@ where
129130

130131
#[cfg(test)]
131132
mod tests {
132-
use vortex_array::arrays::PrimitiveArray;
133-
use vortex_array::compute::{Operator as ComputeOp, compare};
133+
use vortex_array::arrays::{ConstantVTable, PrimitiveArray};
134+
use vortex_array::compute::{compare, Operator as ComputeOp};
134135
use vortex_array::expr::session::ExprSession;
135136
use vortex_array::expr::transform::ExprOptimizer;
136-
use vortex_array::expr::{Binary, Literal, Root, gt, lit, root};
137-
use vortex_array::{Array, ArraySession, IntoArray, ToCanonical, assert_arrays_eq};
137+
use vortex_array::expr::{gt, lit, root, Binary, Literal, Root};
138+
use vortex_array::{assert_arrays_eq, Array, ArraySession, IntoArray, ToCanonical};
138139

139140
use super::*;
140141
use crate::alp_encode;
@@ -283,13 +284,13 @@ mod tests {
283284
// For unencodable Eq comparison, pushdown returns ConstantArray (not ExprArray)
284285
// This is the optimization: we know the result without any computation
285286
assert!(
286-
optimized.is::<vortex_array::arrays::ConstantVTable>(),
287+
optimized.is::<ConstantVTable>(),
287288
"Pushdown should have returned ConstantArray for unencodable Eq, got {:?}",
288289
optimized.encoding().id()
289290
);
290291

291292
// Downcast to ConstantArray and verify structure
292-
let constant_array = optimized.as_::<vortex_array::arrays::ConstantVTable>();
293+
let constant_array = optimized.as_::<ConstantVTable>();
293294
assert_eq!(constant_array.len(), 100);
294295
let false_scalar: Scalar = false.into();
295296
assert_eq!(*constant_array.scalar(), false_scalar);
@@ -402,11 +403,6 @@ mod tests {
402403
.child()
403404
.is::<vortex_array::arrays::PrimitiveVTable>()
404405
{
405-
println!(
406-
"✓ Operator {:?}: Pushed down to PrimitiveArray with expr {:?}",
407-
compute_op,
408-
opt_expr.expr()
409-
);
410406
pushdown_count += 1;
411407

412408
// Verify the expression structure for ExprArray optimizations
@@ -421,30 +417,13 @@ mod tests {
421417
"Right side should be a literal for operator {:?}",
422418
compute_op
423419
);
424-
} else {
425-
println!(
426-
"✗ Operator {:?}: Still ExprArray but child is {:?}",
427-
compute_op,
428-
opt_expr.child().encoding().id()
429-
);
430420
}
431-
} else if optimized.is::<vortex_array::arrays::ConstantVTable>() {
432-
println!(
433-
"✓ Operator {:?}: Optimized to {:?} (constant result)",
434-
compute_op,
435-
optimized.encoding().id()
436-
);
421+
} else if optimized.is::<ConstantVTable>() {
437422
pushdown_count += 1;
438423

439424
// Verify ConstantArray structure
440-
let constant_array = optimized.as_::<vortex_array::arrays::ConstantVTable>();
425+
let constant_array = optimized.as_::<ConstantVTable>();
441426
assert_eq!(constant_array.len(), 10);
442-
} else {
443-
println!(
444-
"✗ Operator {:?}: Optimized to unexpected type {:?}",
445-
compute_op,
446-
optimized.encoding().id()
447-
);
448427
}
449428

450429
// Verify correctness matches the eager comparison kernel

0 commit comments

Comments
 (0)