Skip to content
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -157,41 +157,53 @@ missing_crate_level_docs = "warn"
as_ptr_cast_mut = "warn"
assigning_clones = "warn"
bool_to_int_with_if = "warn"
branches_sharing_code = "warn"
checked_conversions = "warn"
clear_with_drain = "warn"
cloned_instead_of_copied = "warn"
coerce_container_to_any = "warn"
comparison_chain = "warn"
dbg_macro = "warn"
debug_assert_with_mut_call = "warn"
decimal_bitwise_operands = "warn"
default_union_representation = "warn"
disallowed_script_idents = "warn"
doc_broken_link = "warn"
doc_comment_double_space_linebreaks = "warn"
doc_include_without_cfg = "warn"
doc_link_with_quotes = "warn"
duration_suboptimal_units = "warn"
empty_enum_variants_with_brackets = "warn"
empty_enums = "warn"
equatable_if_let = "warn"
exit = "warn"
expl_impl_clone_on_copy = "warn"
explicit_deref_methods = "warn"
explicit_into_iter_loop = "warn"
explicit_iter_loop = "warn"
filter_map_next = "warn"
flat_map_option = "warn"
float_cmp_const = "warn"
fn_params_excessive_bools = "warn"
fn_to_numeric_cast_any = "warn"
format_push_string = "warn"
ignored_unit_patterns = "warn"
implicit_clone = "warn"
imprecise_flops = "warn"
inconsistent_struct_constructor = "warn"
index_refutable_slice = "warn"
inefficient_to_string = "warn"
infinite_loop = "warn"
into_iter_without_iter = "warn"
invalid_upcast_comparisons = "warn"
ip_constant = "warn"
iter_filter_is_ok = "warn"
iter_filter_is_some = "warn"
iter_not_returning_iterator = "warn"
iter_on_empty_collections = "warn"
iter_on_single_items = "warn"
iter_with_drain = "warn"
iter_without_into_iter = "warn"
large_digit_groups = "warn"
large_futures = "warn"
large_include_file = "warn"
Expand All @@ -202,33 +214,44 @@ linkedlist = "warn"
literal_string_with_formatting_args = "warn"
lossy_float_literal = "warn"
macro_use_imports = "warn"
manual_ilog2 = "warn"
manual_instant_elapsed = "warn"
manual_is_power_of_two = "warn"
manual_is_variant_and = "warn"
manual_midpoint = "warn"
manual_string_new = "warn"
match_wild_err_arm = "warn"
match_wildcard_for_single_variants = "warn"
mismatching_type_param_order = "warn"
mut_mut = "warn"
mutex_integer = "warn"
needless_continue = "warn"
needless_pass_by_ref_mut = "warn"
needless_raw_string_hashes = "warn"
needless_type_cast = "warn"
negative_feature_names = "warn"
non_zero_suggestions = "warn"
nonstandard_macro_braces = "warn"
option_as_ref_cloned = "warn"
option_option = "warn"
or_fun_call = "warn"
path_buf_push_overwrite = "warn"
pathbuf_init_then_push = "warn"
precedence_bits = "warn"
ptr_as_ptr = "warn"
ptr_cast_constness = "warn"
ptr_offset_by_literal = "warn"
pub_without_shorthand = "warn"
rc_mutex = "warn"
redundant_type_annotations = "warn"
ref_as_ptr = "warn"
ref_binding_to_reference = "warn"
ref_option = "warn"
ref_option_ref = "warn"
rest_pat_in_fully_bound_structs = "warn"
same_functions_in_if_condition = "warn"
same_length_and_capacity = "warn"
self_only_used_in_recursion = "warn"
set_contains_or_insert = "warn"
should_panic_without_expect = "warn"
single_char_pattern = "warn"
Expand All @@ -243,12 +266,14 @@ trailing_empty_array = "warn"
trait_duplication_in_bounds = "warn"
transmute_ptr_to_ptr = "warn"
tuple_array_conversions = "warn"
unchecked_time_subtraction = "warn"
uninhabited_references = "warn"
unnecessary_box_returns = "warn"
unnecessary_literal_bound = "warn"
unnecessary_safety_doc = "warn"
unnecessary_self_imports = "warn"
unnecessary_struct_initialization = "warn"
unnecessary_trailing_comma = "warn"
unnested_or_patterns = "warn"
unused_async = "warn"
unused_peekable = "warn"
Expand Down
9 changes: 7 additions & 2 deletions arrow-array/src/array/byte_view_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,12 @@ impl<T: ByteViewType + ?Sized> GenericByteViewArray<T> {
pub unsafe fn inline_value(view: &u128, len: usize) -> &[u8] {
debug_assert!(len <= MAX_INLINE_VIEW_LEN as usize);
unsafe {
std::slice::from_raw_parts((view as *const u128 as *const u8).wrapping_add(4), len)
std::slice::from_raw_parts(
std::ptr::from_ref::<u128>(view)
.cast::<u8>()
.wrapping_add(4),
len,
)
}
}

Expand Down Expand Up @@ -1513,7 +1518,7 @@ mod tests {
} else {
// random length between 0 and twice the inline limit
let len = rng.random_range(0..(MAX_INLINE_VIEW_LEN * 2));
let s: String = "A".repeat(len as usize);
let s = "A".repeat(len as usize);
builder.append_option(Some(&s));
original.push(Some(s));
}
Expand Down
2 changes: 1 addition & 1 deletion arrow-array/src/array/dictionary_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,7 @@ mod tests {
#[should_panic(expected = "Invalid dictionary key -100 at index 0, expected 0 <= key < 2")]
fn test_try_new_index_too_small() {
let values: StringArray = [Some("foo"), Some("bar")].into_iter().collect();
let keys: Int32Array = [Some(-100)].into_iter().collect();
let keys: Int32Array = std::iter::once(Some(-100)).collect();
DictionaryArray::new(keys, Arc::new(values));
}

Expand Down
9 changes: 9 additions & 0 deletions arrow-array/src/array/fixed_size_list_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,15 @@ impl FixedSizeListArray {
}
}

impl<'a> IntoIterator for &'a FixedSizeListArray {
type Item = Option<ArrayRef>;
type IntoIter = FixedSizeListIter<'a>;

fn into_iter(self) -> Self::IntoIter {
FixedSizeListIter::new(self)
}
}

impl From<ArrayData> for FixedSizeListArray {
fn from(data: ArrayData) -> Self {
let (data_type, len, nulls, offset, _buffers, child_data) = data.into_parts();
Expand Down
9 changes: 9 additions & 0 deletions arrow-array/src/array/list_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,15 @@ impl<OffsetSize: OffsetSizeTrait> super::ListLikeArray for GenericListArray<Offs
}
}

impl<'a, OffsetSize: OffsetSizeTrait> IntoIterator for &'a GenericListArray<OffsetSize> {
type Item = Option<ArrayRef>;
type IntoIter = GenericListArrayIter<'a, OffsetSize>;

fn into_iter(self) -> Self::IntoIter {
GenericListArrayIter::<'a, OffsetSize>::new(self)
}
}

impl<OffsetSize: OffsetSizeTrait> ArrayAccessor for &GenericListArray<OffsetSize> {
type Item = ArrayRef;

Expand Down
9 changes: 9 additions & 0 deletions arrow-array/src/array/list_view_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,15 @@ impl<OffsetSize: OffsetSizeTrait> GenericListViewArray<OffsetSize> {
}
}

impl<'a, OffsetSize: OffsetSizeTrait> IntoIterator for &'a GenericListViewArray<OffsetSize> {
type Item = Option<ArrayRef>;
type IntoIter = GenericListViewArrayIter<'a, OffsetSize>;

fn into_iter(self) -> Self::IntoIter {
GenericListViewArrayIter::<'a, OffsetSize>::new(self)
}
}

impl<OffsetSize: OffsetSizeTrait> ArrayAccessor for &GenericListViewArray<OffsetSize> {
type Item = ArrayRef;

Expand Down
9 changes: 9 additions & 0 deletions arrow-array/src/array/map_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,15 @@ impl MapArray {
}
}

impl<'a> IntoIterator for &'a MapArray {
type Item = Option<StructArray>;
type IntoIter = MapArrayIter<'a>;

fn into_iter(self) -> Self::IntoIter {
MapArrayIter::new(self)
}
}

impl From<ArrayData> for MapArray {
fn from(data: ArrayData) -> Self {
Self::try_new_from_array_data(data)
Expand Down
2 changes: 1 addition & 1 deletion arrow-array/src/array/struct_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ mod tests {

#[test]
fn test_struct_array_fmt_debug() {
let arr: StructArray = StructArray::new(
let arr = StructArray::new(
vec![Arc::new(Field::new("c", DataType::Int32, true))].into(),
vec![Arc::new(Int32Array::from((0..30).collect::<Vec<_>>())) as ArrayRef],
Some(NullBuffer::new(BooleanBuffer::from(
Expand Down
6 changes: 3 additions & 3 deletions arrow-array/src/builder/fixed_size_binary_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ mod tests {
builder.append_value(b"arrow").unwrap();
builder.append_nulls(2);
builder.append_value(b"world").unwrap();
let array: FixedSizeBinaryArray = builder.finish();
let array = builder.finish();

assert_eq!(&DataType::FixedSizeBinary(5), array.data_type());
assert_eq!(6, array.len());
Expand All @@ -225,7 +225,7 @@ mod tests {
builder.append_value(b"hello").unwrap();
builder.append_null();
builder.append_value(b"arrow").unwrap();
let mut array: FixedSizeBinaryArray = builder.finish_cloned();
let mut array = builder.finish_cloned();

assert_eq!(&DataType::FixedSizeBinary(5), array.data_type());
assert_eq!(3, array.len());
Expand Down Expand Up @@ -256,7 +256,7 @@ mod tests {
builder.append_value(b"").unwrap();
assert!(!builder.is_empty());

let array: FixedSizeBinaryArray = builder.finish();
let array = builder.finish();
assert_eq!(&DataType::FixedSizeBinary(0), array.data_type());
assert_eq!(3, array.len());
assert_eq!(1, array.null_count());
Expand Down
9 changes: 3 additions & 6 deletions arrow-array/src/builder/fixed_size_list_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,17 +289,14 @@ mod tests {
builder.append(true);
}

builder.values().append_value(3);
if include_null_in_values {
builder.values().append_value(3);
builder.values().append_null();
builder.values().append_value(5);
builder.append(true);
} else {
builder.values().append_value(3);
builder.values().append_value(4);
builder.values().append_value(5);
builder.append(true);
}
builder.values().append_value(5);
builder.append(true);

builder
}
Expand Down
2 changes: 1 addition & 1 deletion arrow-array/src/builder/generic_bytes_view_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ mod tests {

// All views should be identical
let first_view = array.views()[0];
for view in array.views().iter() {
for view in array.views() {
assert_eq!(*view, first_view);
}
}
Expand Down
8 changes: 4 additions & 4 deletions arrow-array/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ impl ImportedArrowArray<'_> {
// first buffer is the null buffer => add(1)
// we assume that pointer is aligned for `i32`, as Utf8 uses `i32` offsets.
#[expect(clippy::cast_ptr_alignment)]
let offset_buffer = self.array.buffer(1) as *const i32;
let offset_buffer = self.array.buffer(1).cast::<i32>();
// get last offset
(unsafe { *offset_buffer.add(len / size_of::<i32>() - 1) }) as usize
}
Expand All @@ -495,7 +495,7 @@ impl ImportedArrowArray<'_> {
// first buffer is the null buffer => add(1)
// we assume that pointer is aligned for `i64`, as Large uses `i64` offsets.
#[expect(clippy::cast_ptr_alignment)]
let offset_buffer = self.array.buffer(1) as *const i64;
let offset_buffer = self.array.buffer(1).cast::<i64>();
// get last offset
(unsafe { *offset_buffer.add(len / size_of::<i64>() - 1) }) as usize
}
Expand Down Expand Up @@ -589,8 +589,8 @@ mod tests_to_then_from_ffi {
let schema = Box::new(ManuallyDrop::new(schema));
let array = Box::new(ManuallyDrop::new(array));

let schema_ptr = &**schema as *const _;
let array_ptr = &**array as *const _;
let schema_ptr = std::ptr::from_ref(&**schema);
let array_ptr = std::ptr::from_ref(&**array);

// We can read them back to memory
// SAFETY:
Expand Down
6 changes: 3 additions & 3 deletions arrow-array/src/ffi_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ unsafe extern "C" fn release_stream(stream: *mut FFI_ArrowArrayStream) {
stream.get_next = None;
stream.get_last_error = None;

let private_data = unsafe { Box::from_raw(stream.private_data as *mut StreamPrivateData) };
let private_data = unsafe { Box::from_raw(stream.private_data.cast::<StreamPrivateData>()) };
drop(private_data);

stream.release = None;
Expand Down Expand Up @@ -183,7 +183,7 @@ impl FFI_ArrowArrayStream {
get_next: Some(get_next),
get_last_error: Some(get_last_error),
release: Some(release_stream),
private_data: Box::into_raw(private_data) as *mut c_void,
private_data: Box::into_raw(private_data).cast::<c_void>(),
}
}

Expand Down Expand Up @@ -260,7 +260,7 @@ struct ExportedArrayStream {

impl ExportedArrayStream {
fn get_private_data(&mut self) -> &mut StreamPrivateData {
unsafe { &mut *((*self.stream).private_data as *mut StreamPrivateData) }
unsafe { &mut *(*self.stream).private_data.cast::<StreamPrivateData>() }
}

pub fn get_schema(&mut self, out: *mut FFI_ArrowSchema) -> i32 {
Expand Down
2 changes: 1 addition & 1 deletion arrow-array/src/trusted_len.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ where
let mut buffer = MutableBuffer::new(len);

let dst_null = null.as_mut_ptr();
let mut dst = buffer.as_mut_ptr() as *mut T;
let mut dst = buffer.as_mut_ptr().cast::<T>();
for (i, item) in iterator.enumerate() {
let item = item.borrow();
if let Some(item) = item {
Expand Down
12 changes: 6 additions & 6 deletions arrow-array/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ impl Date32Type {
#[deprecated(since = "58.0.0", note = "Use to_naive_date_opt instead.")]
pub fn to_naive_date(i: <Date32Type as ArrowPrimitiveType>::Native) -> NaiveDate {
Self::to_naive_date_opt(i)
.unwrap_or_else(|| panic!("Date32Type::to_naive_date overflowed for date: {i}",))
.unwrap_or_else(|| panic!("Date32Type::to_naive_date overflowed for date: {i}"))
}

/// Converts an arrow Date32Type into a chrono::NaiveDate
Expand Down Expand Up @@ -996,7 +996,7 @@ impl Date32Type {
delta: <IntervalYearMonthType as ArrowPrimitiveType>::Native,
) -> <Date32Type as ArrowPrimitiveType>::Native {
Self::add_year_months_opt(date, delta).unwrap_or_else(|| {
panic!("Date32Type::add_year_months overflowed for date: {date}, delta: {delta}",)
panic!("Date32Type::add_year_months overflowed for date: {date}, delta: {delta}")
})
}

Expand Down Expand Up @@ -1037,7 +1037,7 @@ impl Date32Type {
delta: <IntervalDayTimeType as ArrowPrimitiveType>::Native,
) -> <Date32Type as ArrowPrimitiveType>::Native {
Self::add_day_time_opt(date, delta).unwrap_or_else(|| {
panic!("Date32Type::add_day_time overflowed for date: {date}, delta: {delta:?}",)
panic!("Date32Type::add_day_time overflowed for date: {date}, delta: {delta:?}")
})
}

Expand Down Expand Up @@ -1079,7 +1079,7 @@ impl Date32Type {
delta: <IntervalMonthDayNanoType as ArrowPrimitiveType>::Native,
) -> <Date32Type as ArrowPrimitiveType>::Native {
Self::add_month_day_nano_opt(date, delta).unwrap_or_else(|| {
panic!("Date32Type::add_month_day_nano overflowed for date: {date}, delta: {delta:?}",)
panic!("Date32Type::add_month_day_nano overflowed for date: {date}, delta: {delta:?}")
})
}

Expand Down Expand Up @@ -1122,7 +1122,7 @@ impl Date32Type {
delta: <IntervalYearMonthType as ArrowPrimitiveType>::Native,
) -> <Date32Type as ArrowPrimitiveType>::Native {
Self::subtract_year_months_opt(date, delta).unwrap_or_else(|| {
panic!("Date32Type::subtract_year_months overflowed for date: {date}, delta: {delta}",)
panic!("Date32Type::subtract_year_months overflowed for date: {date}, delta: {delta}")
})
}

Expand Down Expand Up @@ -1163,7 +1163,7 @@ impl Date32Type {
delta: <IntervalDayTimeType as ArrowPrimitiveType>::Native,
) -> <Date32Type as ArrowPrimitiveType>::Native {
Self::subtract_day_time_opt(date, delta).unwrap_or_else(|| {
panic!("Date32Type::subtract_day_time overflowed for date: {date}, delta: {delta:?}",)
panic!("Date32Type::subtract_day_time overflowed for date: {date}, delta: {delta:?}")
})
}

Expand Down
Loading
Loading