Skip to content

Commit 4c1ae92

Browse files
authored
Skip validity dispatch for non-nullable arrays (#7748)
Two small optimizations: - Skip the `is_invalid` vtable dispatch when `dtype` is non-nullable - Demote the dtype-equality post-check to debug assertion. It's an encoding-correctness invariant, not runtime input validation Signed-off-by: Baris Palaska <barispalaska@gmail.com>
1 parent abb40ef commit 4c1ae92

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

vortex-array/src/array/erased.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,11 @@ impl ArrayRef {
224224
/// Execute the array to extract a scalar at the given index.
225225
pub fn execute_scalar(&self, index: usize, ctx: &mut ExecutionCtx) -> VortexResult<Scalar> {
226226
vortex_ensure!(index < self.len(), OutOfBounds: index, 0, self.len());
227-
if self.is_invalid(index, ctx)? {
227+
if self.dtype().is_nullable() && self.is_invalid(index, ctx)? {
228228
return Ok(Scalar::null(self.dtype().clone()));
229229
}
230230
let scalar = self.0.execute_scalar(self, index, ctx)?;
231-
vortex_ensure!(self.dtype() == scalar.dtype(), "Scalar dtype mismatch");
231+
debug_assert_eq!(self.dtype(), scalar.dtype(), "Scalar dtype mismatch");
232232
Ok(scalar)
233233
}
234234

0 commit comments

Comments
 (0)