From f8a29806a8f3d16c0d8d2b31bdc00241ce12b303 Mon Sep 17 00:00:00 2001 From: Nicholas Gates Date: Tue, 10 Dec 2024 12:34:33 +0000 Subject: [PATCH] Some small fixes (#1631) --- vortex-array/src/array/chunked/mod.rs | 5 +++-- vortex-scalar/src/primitive.rs | 8 +------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/vortex-array/src/array/chunked/mod.rs b/vortex-array/src/array/chunked/mod.rs index 9614d80917..fdbc8c6883 100644 --- a/vortex-array/src/array/chunked/mod.rs +++ b/vortex-array/src/array/chunked/mod.rs @@ -96,8 +96,9 @@ impl ChunkedArray { vortex_bail!("chunk index {} > num chunks ({})", idx, self.nchunks()); } - let chunk_start = usize::try_from(&scalar_at(self.chunk_offsets(), idx)?)?; - let chunk_end = usize::try_from(&scalar_at(self.chunk_offsets(), idx + 1)?)?; + let chunk_offsets = self.chunk_offsets(); + let chunk_start = usize::try_from(&scalar_at(&chunk_offsets, idx)?)?; + let chunk_end = usize::try_from(&scalar_at(&chunk_offsets, idx + 1)?)?; // Offset the index since chunk_ends is child 0. self.as_ref() diff --git a/vortex-scalar/src/primitive.rs b/vortex-scalar/src/primitive.rs index 5c30fb70c2..3042a88209 100644 --- a/vortex-scalar/src/primitive.rs +++ b/vortex-scalar/src/primitive.rs @@ -3,9 +3,7 @@ use std::any::type_name; use num_traits::{FromPrimitive, NumCast}; use vortex_dtype::half::f16; use vortex_dtype::{match_each_native_ptype, DType, NativePType, Nullability, PType}; -use vortex_error::{ - vortex_bail, vortex_err, vortex_panic, VortexError, VortexResult, VortexUnwrap, -}; +use vortex_error::{vortex_err, vortex_panic, VortexError, VortexResult, VortexUnwrap}; use crate::pvalue::PValue; use crate::value::ScalarValue; @@ -20,10 +18,6 @@ pub struct PrimitiveScalar<'a> { impl<'a> PrimitiveScalar<'a> { pub fn try_new(dtype: &'a DType, value: &ScalarValue) -> VortexResult { - if !matches!(dtype, DType::Primitive(..)) { - vortex_bail!("Expected primitive scalar, found {}", dtype) - } - let ptype = PType::try_from(dtype)?; // Read the serialized value into the correct PValue.