Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ derive_partial_eq_without_eq = "deny"
equatable_if_let = "deny"
exit = "deny"
expect_fun_call = "deny"
expect_used = "deny"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per my other comment, this should stay

fallible_impl_from = "deny"
get_unwrap = "deny"
host_endian_bytes = "deny"
Expand All @@ -342,7 +341,6 @@ same_name_method = "deny"
tests_outside_test_module = "deny"
# todo = "deny"
# unimplemented = "deny"
unwrap_in_result = "deny"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't sneak by here, it's orthogonal to the pr

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't allow calling expect in functions that return a result

unwrap_used = "deny"
use_debug = "deny"

Expand Down
1 change: 0 additions & 1 deletion STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
- `vortex_panic!` for handling invariant violations
- Add context to errors using `.with_context()`
- Include backtraces for better debugging
- Use `VortexExpect` trait when unwrapping is appropriate with proper error context.

## Code Structure

Expand Down
5 changes: 2 additions & 3 deletions benchmarks/duckdb-bench/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use std::time::Instant;

use anyhow::Result;
use tracing::trace;
use vortex::error::VortexExpect;
use vortex_bench::Benchmark;
use vortex_bench::Format;
use vortex_bench::IdempotentPath;
Expand Down Expand Up @@ -66,7 +65,7 @@ impl DuckClient {
path: Option<PathBuf>,
threads: Option<usize>,
) -> Result<(Database, Connection)> {
let mut config = Config::new().vortex_expect("failed to create duckdb config");
let mut config = Config::new().expect("failed to create duckdb config");

// Set DuckDB thread count if specified
if let Some(thread_count) = threads {
Expand Down Expand Up @@ -140,7 +139,7 @@ impl DuckClient {
let result = self.connection.query(query)?;
let query_time = time_instant.elapsed();

let row_count = usize::try_from(result.row_count()).vortex_expect("row count overflow");
let row_count = usize::try_from(result.row_count()).expect("row count overflow");

// TODO: Extract DuckDB's internal timing from profiling info if available
Ok((row_count, Some(query_time)))
Expand Down
16 changes: 11 additions & 5 deletions encodings/alp/src/alp/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ use vortex_array::vtable::ValidityVTableFromChild;
use vortex_array::vtable::VisitorVTable;
use vortex_dtype::DType;
use vortex_dtype::PType;
use vortex_error::VortexExpect;
use vortex_error::VortexResult;
use vortex_error::vortex_bail;
use vortex_error::vortex_ensure;
Expand Down Expand Up @@ -109,7 +108,14 @@ impl VTable for ALPVTable {
let values = children.get(2, dtype, p.len()?)?;
let chunk_offsets = p
.chunk_offsets_dtype()?
.map(|dtype| children.get(3, &dtype, usize::try_from(p.chunk_offsets_len())?))
.map(|dtype| {
children.get(
3,
&dtype,
usize::try_from(p.chunk_offsets_len())
.expect("offsets length must fit in usize"),
)
})
.transpose()?;

Patches::new(len, p.offset()?, indices, values, chunk_offsets)
Expand All @@ -119,8 +125,8 @@ impl VTable for ALPVTable {
ALPArray::try_new(
encoded,
Exponents {
e: u8::try_from(metadata.exp_e)?,
f: u8::try_from(metadata.exp_f)?,
e: u8::try_from(metadata.exp_e).expect("e exponent must fit in u8"),
f: u8::try_from(metadata.exp_f).expect("f exponent must fit in u8"),
},
patches,
)
Expand Down Expand Up @@ -298,7 +304,7 @@ impl ALPArray {
/// See [`ALPArray::try_new`] for reference on preconditions that must pass before
/// calling this method.
pub fn new(encoded: ArrayRef, exponents: Exponents, patches: Option<Patches>) -> Self {
Self::try_new(encoded, exponents, patches).vortex_expect("ALPArray new")
Self::try_new(encoded, exponents, patches).expect("ALPArray new")
}

/// Build a new `ALPArray` from components:
Expand Down
3 changes: 1 addition & 2 deletions encodings/alp/src/alp/compute/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ mod tests {
use vortex_dtype::DType;
use vortex_dtype::Nullability;
use vortex_dtype::PType;
use vortex_error::VortexExpect;
use vortex_error::VortexResult;

use crate::alp_encode;
Expand Down Expand Up @@ -146,7 +145,7 @@ mod tests {
#[case(buffer![42.42f64].into_array())]
#[case(buffer![0.0f32, -1.5, 2.5, -3.5, 4.5].into_array())]
fn test_cast_alp_conformance(#[case] array: vortex_array::ArrayRef) -> VortexResult<()> {
let alp = alp_encode(&array.to_primitive(), None).vortex_expect("cannot fail");
let alp = alp_encode(&array.to_primitive(), None).expect("cannot fail");
test_cast_conformance(alp.as_ref());

Ok(())
Expand Down
3 changes: 1 addition & 2 deletions encodings/alp/src/alp/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

use vortex_array::scalar::Scalar;
use vortex_array::vtable::OperationsVTable;
use vortex_error::VortexExpect;
use vortex_error::VortexResult;

use crate::ALPArray;
Expand All @@ -23,7 +22,7 @@ impl OperationsVTable<ALPVTable> for ALPVTable {

Ok(match_each_alp_float_ptype!(array.ptype(), |T| {
let encoded_val: <T as ALPFloat>::ALPInt =
(&encoded_val).try_into().vortex_expect("invalid ALPInt");
(&encoded_val).try_into().expect("invalid ALPInt");
Scalar::primitive(
<T as ALPFloat>::decode_single(encoded_val, array.exponents()),
array.dtype().nullability(),
Expand Down
3 changes: 1 addition & 2 deletions encodings/alp/src/alp_rd/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use vortex_buffer::Buffer;
use vortex_dtype::DType;
use vortex_dtype::Nullability;
use vortex_dtype::PType;
use vortex_error::VortexExpect;
use vortex_error::VortexResult;
use vortex_error::vortex_bail;
use vortex_error::vortex_ensure;
Expand Down Expand Up @@ -90,7 +89,7 @@ impl VTable for ALPRDVTable {
dict_len: array.left_parts_dictionary().len() as u32,
dict,
left_parts_ptype: PType::try_from(array.left_parts().dtype())
.vortex_expect("Must be a valid PType") as i32,
.expect("Must be a valid PType") as i32,
patches: array
.left_parts_patches()
.map(|p| p.to_metadata(array.len(), array.left_parts().dtype()))
Expand Down
13 changes: 5 additions & 8 deletions encodings/alp/src/alp_rd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ use vortex_buffer::BufferMut;
use vortex_dtype::DType;
use vortex_dtype::NativePType;
use vortex_dtype::match_each_integer_ptype;
use vortex_error::VortexExpect;
use vortex_error::VortexResult;
use vortex_error::vortex_panic;
use vortex_utils::aliases::hash_map::HashMap;
Expand Down Expand Up @@ -233,15 +232,15 @@ impl RDEncoder {
// SAFETY: by construction, all values in left_parts can be packed to left_bit_width.
let packed_left = unsafe {
bitpack_encode_unchecked(primitive_left, left_bit_width as _)
.vortex_expect("bitpack_encode_unchecked should succeed for left parts")
.expect("bitpack_encode_unchecked should succeed for left parts")
.into_array()
};

let primitive_right = PrimitiveArray::new(right_parts, Validity::NonNullable);
// SAFETY: by construction, all values in right_parts are right_bit_width + leading zeros.
let packed_right = unsafe {
bitpack_encode_unchecked(primitive_right, self.right_bit_width as _)
.vortex_expect("bitpack_encode_unchecked should succeed for right parts")
.expect("bitpack_encode_unchecked should succeed for right parts")
.into_array()
};

Expand All @@ -256,9 +255,7 @@ impl RDEncoder {
// SAFETY: We calculate bw such that it is wide enough to hold the largest position index.
let packed_pos = unsafe {
bitpack_encode_unchecked(exc_pos_array, bw)
.vortex_expect(
"bitpack_encode_unchecked should succeed for exception positions",
)
.expect("bitpack_encode_unchecked should succeed for exception positions")
.into_array()
};

Expand All @@ -270,7 +267,7 @@ impl RDEncoder {
// TODO(0ax1): handle chunk offsets
None,
)
.vortex_expect("Patches construction in encode")
.expect("Patches construction in encode")
});

ALPRDArray::try_new(
Expand All @@ -281,7 +278,7 @@ impl RDEncoder {
self.right_bit_width,
exceptions,
)
.vortex_expect("ALPRDArray construction in encode")
.expect("ALPRDArray construction in encode")
}
}

Expand Down
9 changes: 4 additions & 5 deletions encodings/alp/src/alp_rd/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use vortex_array::Array;
use vortex_array::scalar::Scalar;
use vortex_array::vtable::OperationsVTable;
use vortex_error::VortexExpect;
use vortex_error::VortexResult;

use crate::ALPRDArray;
Expand All @@ -22,14 +21,14 @@ impl OperationsVTable<ALPRDVTable> for ALPRDVTable {
Some(patched_value) => patched_value
.as_primitive()
.as_::<u16>()
.vortex_expect("patched values must be non-null"),
.expect("patched values must be non-null"),
_ => {
let left_code: u16 = array
.left_parts()
.scalar_at(index)?
.as_primitive()
.as_::<u16>()
.vortex_expect("left_code must be non-null");
.expect("left_code must be non-null");
array.left_parts_dictionary()[left_code as usize]
}
};
Expand All @@ -41,7 +40,7 @@ impl OperationsVTable<ALPRDVTable> for ALPRDVTable {
.scalar_at(index)?
.as_primitive()
.as_::<u32>()
.vortex_expect("non-null");
.expect("non-null");
let packed = f32::from_bits((left as u32) << array.right_bit_width() | right);
Scalar::primitive(packed, array.dtype().nullability())
} else {
Expand All @@ -50,7 +49,7 @@ impl OperationsVTable<ALPRDVTable> for ALPRDVTable {
.scalar_at(index)?
.as_primitive()
.as_::<u64>()
.vortex_expect("non-null");
.expect("non-null");
let packed = f64::from_bits(((left as u64) << array.right_bit_width()) | right);
Scalar::primitive(packed, array.dtype().nullability())
})
Expand Down
3 changes: 1 addition & 2 deletions encodings/bytebool/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ use vortex_array::vtable::validity_nchildren;
use vortex_buffer::BitBuffer;
use vortex_buffer::ByteBuffer;
use vortex_dtype::DType;
use vortex_error::VortexExpect as _;
use vortex_error::VortexResult;
use vortex_error::vortex_bail;
use vortex_error::vortex_ensure;
Expand Down Expand Up @@ -109,7 +108,7 @@ impl VTable for ByteBoolVTable {
array.validity = if children.is_empty() {
Validity::from(array.dtype.nullability())
} else {
Validity::Array(children.into_iter().next().vortex_expect("checked"))
Validity::Array(children.into_iter().next().expect("checked"))
};

Ok(())
Expand Down
7 changes: 3 additions & 4 deletions encodings/datetime-parts/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use vortex_array::vtable::VisitorVTable;
use vortex_dtype::DType;
use vortex_dtype::Nullability;
use vortex_dtype::PType;
use vortex_error::VortexExpect;
use vortex_error::VortexResult;
use vortex_error::vortex_bail;
use vortex_error::vortex_ensure;
Expand Down Expand Up @@ -152,9 +151,9 @@ impl VTable for DateTimePartsVTable {
);

let mut children_iter = children.into_iter();
array.days = children_iter.next().vortex_expect("checked");
array.seconds = children_iter.next().vortex_expect("checked");
array.subseconds = children_iter.next().vortex_expect("checked");
array.days = children_iter.next().expect("checked");
array.seconds = children_iter.next().expect("checked");
array.subseconds = children_iter.next().expect("checked");

Ok(())
}
Expand Down
10 changes: 3 additions & 7 deletions encodings/datetime-parts/src/canonical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use vortex_dtype::PType;
use vortex_dtype::datetime::TimeUnit;
use vortex_dtype::datetime::Timestamp;
use vortex_dtype::match_each_integer_ptype;
use vortex_error::VortexExpect as _;
use vortex_error::VortexResult;
use vortex_error::vortex_panic;

Expand Down Expand Up @@ -46,7 +45,7 @@ pub fn decode_to_temporal(
let days_buf = array
.days()
.cast(DType::Primitive(PType::I64, array.dtype().nullability()))
.vortex_expect("must be able to cast days to i64")
.expect("must be able to cast days to i64")
.execute::<PrimitiveArray>(ctx)?;

// We start with the days component, which is always present.
Expand All @@ -58,10 +57,7 @@ pub fn decode_to_temporal(
.map_each_in_place(|d| d * 86_400 * divisor);

if let Some(seconds) = array.seconds().as_constant() {
let seconds = seconds
.as_primitive()
.as_::<i64>()
.vortex_expect("non-nullable");
let seconds = seconds.as_primitive().as_::<i64>().expect("non-nullable");
let seconds = seconds * divisor;
for v in values.iter_mut() {
*v += seconds;
Expand All @@ -80,7 +76,7 @@ pub fn decode_to_temporal(
let subseconds = subseconds
.as_primitive()
.as_::<i64>()
.vortex_expect("non-nullable");
.expect("non-nullable");
for v in values.iter_mut() {
*v += subseconds;
}
Expand Down
5 changes: 2 additions & 3 deletions encodings/datetime-parts/src/compute/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use vortex_array::optimizer::rules::ArrayParentReduceRule;
use vortex_array::optimizer::rules::ParentRuleSet;
use vortex_dtype::DType;
use vortex_dtype::datetime::Timestamp;
use vortex_error::VortexExpect;
use vortex_error::VortexResult;

use crate::DateTimePartsArray;
Expand Down Expand Up @@ -62,12 +61,12 @@ impl ArrayParentReduceRule<DateTimePartsVTable> for DTPFilterPushDownRule {
child.dtype().clone(),
child.days().clone().filter(parent.filter_mask().clone())?,
ConstantArray::new(
child.seconds().as_constant().vortex_expect("constant"),
child.seconds().as_constant().expect("constant"),
parent.filter_mask().true_count(),
)
.into_array(),
ConstantArray::new(
child.subseconds().as_constant().vortex_expect("constant"),
child.subseconds().as_constant().expect("constant"),
parent.filter_mask().true_count(),
)
.into_array(),
Expand Down
7 changes: 3 additions & 4 deletions encodings/datetime-parts/src/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use vortex_array::scalar::Scalar;
use vortex_array::vtable::OperationsVTable;
use vortex_dtype::DType;
use vortex_dtype::datetime::Timestamp;
use vortex_error::VortexExpect;
use vortex_error::VortexResult;
use vortex_error::vortex_panic;

Expand Down Expand Up @@ -37,19 +36,19 @@ impl OperationsVTable<DateTimePartsVTable> for DateTimePartsVTable {
.scalar_at(index)?
.as_primitive()
.as_::<i64>()
.vortex_expect("days fits in i64");
.expect("days fits in i64");
let seconds: i64 = array
.seconds()
.scalar_at(index)?
.as_primitive()
.as_::<i64>()
.vortex_expect("seconds fits in i64");
.expect("seconds fits in i64");
let subseconds: i64 = array
.subseconds()
.scalar_at(index)?
.as_primitive()
.as_::<i64>()
.vortex_expect("subseconds fits in i64");
.expect("subseconds fits in i64");

let ts = timestamp::combine(
TimestampParts {
Expand Down
Loading
Loading