From 13b9eb87ee8c7b54799ffb1271c6616b54757ffa Mon Sep 17 00:00:00 2001 From: Adam Gutglick Date: Tue, 10 Sep 2024 10:52:06 +0100 Subject: [PATCH 1/4] . --- vortex-array/src/array/struct_/compute.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/vortex-array/src/array/struct_/compute.rs b/vortex-array/src/array/struct_/compute.rs index e7fbcf5fb1e..d9a654d9ad1 100644 --- a/vortex-array/src/array/struct_/compute.rs +++ b/vortex-array/src/array/struct_/compute.rs @@ -79,20 +79,19 @@ impl SliceFn for StructArray { impl FilterFn for StructArray { fn filter(&self, predicate: &Array) -> VortexResult { - let fields = self + let fields: Vec = self .children() .map(|field| filter(&field, predicate)) .try_collect()?; - let predicate_true_count = predicate - .statistics() - .compute_true_count() - .ok_or_else(|| vortex_err!("Predicate should always be a boolean array"))?; + let length = fields.iter().next().map(|a| a.len()).unwrap_or_default(); + + // let len = fields.iter(); Self::try_new( self.names().clone(), fields, - predicate_true_count, + length, self.validity().filter(predicate)?, ) .map(|a| a.into_array()) From 9ed468916337d84c8394a28152943f4f9b42a335 Mon Sep 17 00:00:00 2001 From: Adam Gutglick Date: Tue, 10 Sep 2024 10:52:52 +0100 Subject: [PATCH 2/4] . --- vortex-array/src/array/struct_/compute.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/vortex-array/src/array/struct_/compute.rs b/vortex-array/src/array/struct_/compute.rs index d9a654d9ad1..d1710a34504 100644 --- a/vortex-array/src/array/struct_/compute.rs +++ b/vortex-array/src/array/struct_/compute.rs @@ -1,11 +1,10 @@ use itertools::Itertools; -use vortex_error::{vortex_err, VortexResult}; +use vortex_error::VortexResult; use vortex_scalar::Scalar; use crate::array::struct_::StructArray; use crate::compute::unary::{scalar_at, scalar_at_unchecked, ScalarAtFn}; use crate::compute::{filter, slice, take, ArrayCompute, FilterFn, SliceFn, TakeFn}; -use crate::stats::ArrayStatistics; use crate::variants::StructArrayTrait; use crate::{Array, ArrayDType, IntoArray}; @@ -83,10 +82,7 @@ impl FilterFn for StructArray { .children() .map(|field| filter(&field, predicate)) .try_collect()?; - - let length = fields.iter().next().map(|a| a.len()).unwrap_or_default(); - - // let len = fields.iter(); + let length = fields.first().map(|a| a.len()).unwrap_or_default(); Self::try_new( self.names().clone(), From 6bf9d5a27f5319e4f4e9d93aca2ffcba77a217f0 Mon Sep 17 00:00:00 2001 From: Adam Gutglick Date: Tue, 10 Sep 2024 11:08:53 +0100 Subject: [PATCH 3/4] . --- vortex-array/src/array/struct_/compute.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vortex-array/src/array/struct_/compute.rs b/vortex-array/src/array/struct_/compute.rs index d1710a34504..dd2cfc81c12 100644 --- a/vortex-array/src/array/struct_/compute.rs +++ b/vortex-array/src/array/struct_/compute.rs @@ -1,5 +1,5 @@ use itertools::Itertools; -use vortex_error::VortexResult; +use vortex_error::{vortex_err, VortexResult}; use vortex_scalar::Scalar; use crate::array::struct_::StructArray; @@ -82,7 +82,10 @@ impl FilterFn for StructArray { .children() .map(|field| filter(&field, predicate)) .try_collect()?; - let length = fields.first().map(|a| a.len()).unwrap_or_default(); + let length = fields + .first() + .map(|a| a.len()) + .ok_or(vortex_err!("Struct arrays should have at least one field"))?; Self::try_new( self.names().clone(), From 306f13f366fcd40f8bc09c8de68ce9eea4b59e3b Mon Sep 17 00:00:00 2001 From: Adam Gutglick Date: Tue, 10 Sep 2024 11:12:12 +0100 Subject: [PATCH 4/4] . --- vortex-array/src/array/struct_/compute.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vortex-array/src/array/struct_/compute.rs b/vortex-array/src/array/struct_/compute.rs index dd2cfc81c12..765cd7d09b7 100644 --- a/vortex-array/src/array/struct_/compute.rs +++ b/vortex-array/src/array/struct_/compute.rs @@ -85,7 +85,7 @@ impl FilterFn for StructArray { let length = fields .first() .map(|a| a.len()) - .ok_or(vortex_err!("Struct arrays should have at least one field"))?; + .ok_or_else(|| vortex_err!("Struct arrays should have at least one field"))?; Self::try_new( self.names().clone(),