Skip to content

Commit 58e62ef

Browse files
committed
fix
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
1 parent f3d11f9 commit 58e62ef

1 file changed

Lines changed: 24 additions & 33 deletions

File tree

encodings/sparse/src/canonical.rs

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,13 @@ fn sparse_array_for_validity(patches: &Patches, fill_value: &Scalar, len: usize)
7070
.vortex_expect("rebuilding SparseArray for validity")
7171
}
7272

73-
pub(super) fn execute_sparse(
74-
parts: SparseParts,
75-
ctx: &mut ExecutionCtx,
76-
) -> VortexResult<ArrayRef> {
77-
let SparseParts { patches, fill_value, dtype, len } = parts;
73+
pub(super) fn execute_sparse(parts: SparseParts, ctx: &mut ExecutionCtx) -> VortexResult<ArrayRef> {
74+
let SparseParts {
75+
patches,
76+
fill_value,
77+
dtype,
78+
len,
79+
} = parts;
7880

7981
if patches.num_patches() == 0 {
8082
return Ok(ConstantArray::new(fill_value, len).into_array());
@@ -86,20 +88,18 @@ pub(super) fn execute_sparse(
8688
assert!(fill_value.is_null());
8789
NullArray::new(len).into_array()
8890
}
89-
DType::Bool(..) => {
90-
execute_sparse_bools(&patches, &fill_value, ctx)?
91-
}
91+
DType::Bool(..) => execute_sparse_bools(&patches, &fill_value, ctx)?,
9292
DType::Primitive(ptype, ..) => {
9393
match_each_native_ptype!(ptype, |P| {
9494
execute_sparse_primitives::<P>(&patches, &fill_value, ctx)?
9595
})
9696
}
9797
DType::Struct(struct_fields, ..) => execute_sparse_struct(
9898
struct_fields,
99-
array.fill_scalar().as_struct(),
100-
array.dtype().nullability(),
101-
array.patches(),
102-
array.len(),
99+
fill_value.as_struct(),
100+
dtype.nullability(),
101+
&patches,
102+
len,
103103
ctx,
104104
)?,
105105
DType::Decimal(decimal_dtype, nullability) => {
@@ -131,15 +131,17 @@ pub(super) fn execute_sparse(
131131
DType::List(values_dtype, nullability) => {
132132
let validity_arr = sparse_array_for_validity(&patches, &fill_value, len);
133133
execute_sparse_lists(
134-
&patches, &validity_arr, &fill_value,
135-
Arc::clone(values_dtype), *nullability, ctx,
134+
&patches,
135+
&validity_arr,
136+
&fill_value,
137+
Arc::clone(values_dtype),
138+
*nullability,
139+
ctx,
136140
)?
137141
}
138142
DType::FixedSizeList(.., nullability) => {
139143
let validity_arr = sparse_array_for_validity(&patches, &fill_value, len);
140-
execute_sparse_fixed_size_list(
141-
&patches, &validity_arr, &fill_value, *nullability, ctx,
142-
)?
144+
execute_sparse_fixed_size_list(&patches, &validity_arr, &fill_value, *nullability, ctx)?
143145
}
144146
DType::Extension(_ext_dtype) => todo!(),
145147
DType::Variant(_) => vortex_bail!("Sparse canonicalization does not support Variant"),
@@ -158,23 +160,16 @@ fn execute_sparse_lists(
158160
nullability: Nullability,
159161
ctx: &mut ExecutionCtx,
160162
) -> VortexResult<ArrayRef> {
161-
let indices = resolved
162-
.indices()
163-
.clone()
164-
.execute::<PrimitiveArray>(ctx)?;
165-
let values = resolved
166-
.values()
167-
.clone()
168-
.execute::<ListViewArray>(ctx)?;
163+
let indices = resolved.indices().clone().execute::<PrimitiveArray>(ctx)?;
164+
let values = resolved.values().clone().execute::<ListViewArray>(ctx)?;
169165
let fill_list = fill_value.as_list();
170166

171167
let len = validity_array.len();
172168
let n_filled = len - resolved.num_patches();
173169
let total_canonical_values = values.elements().len() + fill_list.len() * n_filled;
174170

175171
let arr = validity_array.as_ref();
176-
let validity =
177-
Validity::from_mask(arr.validity()?.execute_mask(arr.len(), ctx)?, nullability);
172+
let validity = Validity::from_mask(arr.validity()?.execute_mask(arr.len(), ctx)?, nullability);
178173

179174
Ok(match_each_integer_ptype!(indices.ptype(), |I| {
180175
match_smallest_offset_type!(total_canonical_values, |O| {
@@ -253,10 +248,7 @@ fn execute_sparse_fixed_size_list(
253248
nullability: Nullability,
254249
ctx: &mut ExecutionCtx,
255250
) -> VortexResult<ArrayRef> {
256-
let indices = resolved
257-
.indices()
258-
.clone()
259-
.execute::<PrimitiveArray>(ctx)?;
251+
let indices = resolved.indices().clone().execute::<PrimitiveArray>(ctx)?;
260252
let values = resolved
261253
.values()
262254
.clone()
@@ -265,8 +257,7 @@ fn execute_sparse_fixed_size_list(
265257
let len = validity_array.len();
266258

267259
let arr = validity_array.as_ref();
268-
let validity =
269-
Validity::from_mask(arr.validity()?.execute_mask(arr.len(), ctx)?, nullability);
260+
let validity = Validity::from_mask(arr.validity()?.execute_mask(arr.len(), ctx)?, nullability);
270261

271262
Ok(match_each_integer_ptype!(indices.ptype(), |I| {
272263
execute_sparse_fixed_size_list_inner::<I>(

0 commit comments

Comments
 (0)