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
9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,20 @@ default_union_representation = "warn"
disallowed_script_idents = "warn"
doc_comment_double_space_linebreaks = "warn"
doc_include_without_cfg = "warn"
doc_link_with_quotes = "warn"
empty_enum_variants_with_brackets = "warn"
equatable_if_let = "warn"
exit = "warn"
expl_impl_clone_on_copy = "warn"
explicit_deref_methods = "warn"
explicit_into_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"
imprecise_flops = "warn"
inconsistent_struct_constructor = "warn"
index_refutable_slice = "warn"
Expand All @@ -200,18 +204,22 @@ lossy_float_literal = "warn"
macro_use_imports = "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"
mismatching_type_param_order = "warn"
mut_mut = "warn"
mutex_integer = "warn"
needless_raw_string_hashes = "warn"
negative_feature_names = "warn"
non_zero_suggestions = "warn"
nonstandard_macro_braces = "warn"
option_as_ref_cloned = "warn"
option_option = "warn"
path_buf_push_overwrite = "warn"
pathbuf_init_then_push = "warn"
precedence_bits = "warn"
ptr_cast_constness = "warn"
ptr_offset_by_literal = "warn"
pub_without_shorthand = "warn"
Expand Down Expand Up @@ -241,6 +249,7 @@ unnecessary_literal_bound = "warn"
unnecessary_safety_doc = "warn"
unnecessary_self_imports = "warn"
unnecessary_struct_initialization = "warn"
unnested_or_patterns = "warn"
unused_async = "warn"
unused_peekable = "warn"
unused_rounding = "warn"
Expand Down
2 changes: 1 addition & 1 deletion arrow-arith/src/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2005,7 +2005,7 @@ mod tests {
ItemType: Clone + Into<Option<V::Native>> + 'static,
{
let mut builder = arrow_array::builder::PrimitiveRunBuilder::<I, V>::new();
for v in values.into_iter() {
for v in values {
builder.append_option((*v).clone().into());
}
builder.finish()
Expand Down
3 changes: 1 addition & 2 deletions arrow-array/src/array/fixed_size_list_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,7 @@ impl FixedSizeListArray {
let nulls_valid = field.is_nullable()
|| nulls
.as_ref()
.map(|n| n.expand(size as _).contains(&a))
.unwrap_or_default()
.is_some_and(|n| n.expand(size as _).contains(&a))
|| (nulls.is_none() && a.null_count() == 0);

if !nulls_valid {
Expand Down
2 changes: 1 addition & 1 deletion arrow-array/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ pub unsafe trait Array: std::fmt::Debug + Send + Sync {
/// assert_eq!(array.is_null(0), false);
/// ```
fn is_null(&self, index: usize) -> bool {
self.nulls().map(|n| n.is_null(index)).unwrap_or_default()
self.nulls().is_some_and(|n| n.is_null(index))
}

/// Returns whether the element at `index` is *not* null, the
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 @@ -168,7 +168,7 @@ impl StructArray {

if !f.is_nullable()
&& let Some(a) = a.logical_nulls()
&& !nulls.as_ref().map(|n| n.contains(&a)).unwrap_or_default()
&& nulls.as_ref().is_none_or(|n| !n.contains(&a))
&& a.null_count() > 0
{
return Err(ArrowError::InvalidArgumentError(format!(
Expand Down
65 changes: 29 additions & 36 deletions arrow-array/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,51 +144,46 @@ fn bit_width(data_type: &DataType, i: usize) -> Result<usize> {
let child_bit_width = bit_width(f.data_type(), 1)?;
child_bit_width * (*num_elems as usize)
}
(DataType::FixedSizeBinary(_), _) | (DataType::FixedSizeList(_, _), _) => {
(DataType::FixedSizeBinary(_) | DataType::FixedSizeList(_, _), _) => {
return Err(ArrowError::CDataInterface(format!(
"The datatype \"{data_type}\" expects 2 buffers, but requested {i}. Please verify that the C data interface is correctly implemented."
)));
}
// Variable-size list and map have one i32 buffer.
// Variable-sized binaries: have two buffers.
// "small": first buffer is i32, second is in bytes
(DataType::Utf8, 1)
| (DataType::Binary, 1)
| (DataType::List(_), 1)
| (DataType::Map(_, _), 1) => i32::BITS as _,
(DataType::Utf8, 2) | (DataType::Binary, 2) => u8::BITS as _,
(DataType::Utf8 | DataType::Binary | DataType::List(_) | DataType::Map(_, _), 1) => {
i32::BITS as _
}
(DataType::Utf8 | DataType::Binary, 2) => u8::BITS as _,
// List views have two i32 buffers, offsets and sizes
(DataType::ListView(_), 1) | (DataType::ListView(_), 2) => i32::BITS as _,
(DataType::ListView(_), 1 | 2) => i32::BITS as _,
// Large list views have two i64 buffers, offsets and sizes
(DataType::LargeListView(_), 1) | (DataType::LargeListView(_), 2) => i64::BITS as _,
(DataType::List(_), _) | (DataType::Map(_, _), _) => {
(DataType::LargeListView(_), 1 | 2) => i64::BITS as _,
(DataType::List(_) | DataType::Map(_, _), _) => {
return Err(ArrowError::CDataInterface(format!(
"The datatype \"{data_type}\" expects 2 buffers, but requested {i}. Please verify that the C data interface is correctly implemented."
)));
}
(DataType::Utf8, _) | (DataType::Binary, _) => {
(DataType::Utf8 | DataType::Binary, _) => {
return Err(ArrowError::CDataInterface(format!(
"The datatype \"{data_type}\" expects 3 buffers, but requested {i}. Please verify that the C data interface is correctly implemented."
)));
}
// Variable-sized binaries: have two buffers.
// LargeUtf8: first buffer is i64, second is in bytes
(DataType::LargeUtf8, 1) | (DataType::LargeBinary, 1) | (DataType::LargeList(_), 1) => {
i64::BITS as _
}
(DataType::LargeUtf8, 2) | (DataType::LargeBinary, 2) | (DataType::LargeList(_), 2) => {
u8::BITS as _
}
(DataType::LargeUtf8, _) | (DataType::LargeBinary, _) | (DataType::LargeList(_), _) => {
(DataType::LargeUtf8 | DataType::LargeBinary | DataType::LargeList(_), 1) => i64::BITS as _,
(DataType::LargeUtf8 | DataType::LargeBinary | DataType::LargeList(_), 2) => u8::BITS as _,
(DataType::LargeUtf8 | DataType::LargeBinary | DataType::LargeList(_), _) => {
return Err(ArrowError::CDataInterface(format!(
"The datatype \"{data_type}\" expects 3 buffers, but requested {i}. Please verify that the C data interface is correctly implemented."
)));
}
// Variable-sized views: have 3 or more buffers.
// Buffer 1 are the u128 views
// Buffers 2...N-1 are u8 byte buffers
(DataType::Utf8View, 1) | (DataType::BinaryView, 1) => u128::BITS as _,
(DataType::Utf8View, _) | (DataType::BinaryView, _) => u8::BITS as _,
(DataType::Utf8View | DataType::BinaryView, 1) => u128::BITS as _,
(DataType::Utf8View | DataType::BinaryView, _) => u8::BITS as _,
// type ids. UnionArray doesn't have null bitmap so buffer index begins with 0.
(DataType::Union(_, _), 0) => i8::BITS as _,
// Only DenseUnion has 2nd buffer
Expand Down Expand Up @@ -456,27 +451,27 @@ impl ImportedArrowArray<'_> {

// Inner type is not important for buffer length.
Ok(match (&data_type, i) {
(DataType::Utf8, 1)
| (DataType::LargeUtf8, 1)
| (DataType::Binary, 1)
| (DataType::LargeBinary, 1)
| (DataType::List(_), 1)
| (DataType::LargeList(_), 1)
| (DataType::Map(_, _), 1) => {
(
DataType::Utf8
| DataType::LargeUtf8
| DataType::Binary
| DataType::LargeBinary
| DataType::List(_)
| DataType::LargeList(_)
| DataType::Map(_, _),
1,
) => {
// the len of the offset buffer (buffer 1) equals length + 1
let bits = bit_width(data_type, i)?;
debug_assert_eq!(bits % 8, 0);
(length + 1) * (bits / 8)
}
(DataType::ListView(_), 1)
| (DataType::ListView(_), 2)
| (DataType::LargeListView(_), 1)
| (DataType::LargeListView(_), 2) => {
(DataType::ListView(_) | DataType::LargeListView(_), 1 | 2) => {
let bits = bit_width(data_type, i)?;
debug_assert_eq!(bits % 8, 0);
length * (bits / 8)
}
(DataType::Utf8, 2) | (DataType::Binary, 2) => {
(DataType::Utf8 | DataType::Binary, 2) => {
if self.array.is_empty() {
return Ok(0);
}
Expand All @@ -490,7 +485,7 @@ impl ImportedArrowArray<'_> {
// get last offset
(unsafe { *offset_buffer.add(len / size_of::<i32>() - 1) }) as usize
}
(DataType::LargeUtf8, 2) | (DataType::LargeBinary, 2) => {
(DataType::LargeUtf8 | DataType::LargeBinary, 2) => {
if self.array.is_empty() {
return Ok(0);
}
Expand All @@ -508,10 +503,8 @@ impl ImportedArrowArray<'_> {
// Buffer 1 is the views buffer, which stores 1 u128 per length of the array.
// Buffers 2..N-1 are the buffers holding the byte data. Their lengths are variable.
// Buffer N is of length (N - 2) and stores i64 containing the lengths of buffers 2..N-1
(DataType::Utf8View, 1) | (DataType::BinaryView, 1) => {
std::mem::size_of::<u128>() * length
}
(DataType::Utf8View, i) | (DataType::BinaryView, i) => {
(DataType::Utf8View | DataType::BinaryView, 1) => std::mem::size_of::<u128>() * length,
(DataType::Utf8View | DataType::BinaryView, i) => {
variadic_buffer_lengths[i - 2] as usize
}
// buffer len of primitive types
Expand Down
2 changes: 1 addition & 1 deletion arrow-array/src/ffi_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ mod tests {
fn test_error_import() -> Result<()> {
let schema = Arc::new(Schema::new(vec![Field::new("a", DataType::Int32, true)]));

let iter = Box::new(vec![Err(ArrowError::MemoryError("".to_string()))].into_iter());
let iter = Box::new(vec![Err(ArrowError::MemoryError(String::new()))].into_iter());

let reader = Box::new(TestRecordBatchReader::new(schema.clone(), iter));

Expand Down
5 changes: 1 addition & 4 deletions arrow-array/src/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ impl<T: ArrayAccessor> ArrayIter<T> {

#[inline]
fn is_null(&self, idx: usize) -> bool {
self.logical_nulls
.as_ref()
.map(|x| x.is_null(idx))
.unwrap_or_default()
self.logical_nulls.as_ref().is_some_and(|x| x.is_null(idx))
}
}

Expand Down
2 changes: 1 addition & 1 deletion arrow-avro/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ impl AvroField {
/// converted to use `Utf8View` instead of `Utf8`.
pub(crate) fn with_utf8view(&self) -> Self {
let mut field = self.clone();
if let Codec::Utf8 = field.data_type.codec {
if field.data_type.codec == Codec::Utf8 {
field.data_type.codec = Codec::Utf8View;
}
field
Expand Down
2 changes: 1 addition & 1 deletion arrow-avro/src/reader/async_reader/async_file_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub trait AsyncFileReader: Send {
async move {
let mut result = Vec::with_capacity(ranges.len());

for range in ranges.into_iter() {
for range in ranges {
let data = self.get_bytes(range).await?;
result.push(data);
}
Expand Down
4 changes: 2 additions & 2 deletions arrow-avro/src/reader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4771,8 +4771,8 @@ mod test {
{
let idx = schema.index_of("array_of_union").unwrap();
let dt = schema.field(idx).data_type().clone();
let (item_field, _) = match &dt {
DataType::List(f) => (f.clone(), ()),
let item_field = match &dt {
DataType::List(f) => f.clone(),
other => panic!("array_of_union must be List, got {other:?}"),
};
let (uf, _) = match item_field.data_type() {
Expand Down
5 changes: 2 additions & 3 deletions arrow-avro/src/reader/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,7 @@ impl Decoder {
(Codec::Float64, Some(Promotion::FloatToDouble)) => {
Self::Float32ToFloat64(Vec::with_capacity(DEFAULT_CAPACITY))
}
(Codec::Utf8, Some(Promotion::BytesToString))
| (Codec::Utf8View, Some(Promotion::BytesToString)) => Self::BytesToString(
(Codec::Utf8 | Codec::Utf8View, Some(Promotion::BytesToString)) => Self::BytesToString(
OffsetBufferBuilder::new(DEFAULT_CAPACITY),
Vec::with_capacity(DEFAULT_CAPACITY),
),
Expand Down Expand Up @@ -4430,7 +4429,7 @@ mod tests {
) -> AvroDataType {
let mut avro_children: Vec<AvroDataType> = Vec::with_capacity(children.len());
let mut fields: Vec<arrow_schema::Field> = Vec::with_capacity(children.len());
for (codec, name, dt) in children.into_iter() {
for (codec, name, dt) in children {
avro_children.push(AvroDataType::new(codec, Default::default(), None));
fields.push(arrow_schema::Field::new(name, dt, true));
}
Expand Down
2 changes: 1 addition & 1 deletion arrow-avro/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ pub(crate) enum Schema<'a> {
/// A direct type name (primitive or reference)
#[serde(borrow)]
TypeName(TypeName<'a>),
/// A union of multiple schemas (e.g., ["null", "string"])
/// A union of multiple schemas (e.g., `["null", "string"]`)
#[serde(borrow)]
Union(Vec<Schema<'a>>),
/// A complex type such as record, array, map, etc.
Expand Down
2 changes: 1 addition & 1 deletion arrow-avro/src/writer/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ impl FieldPlan {
{
matches!(
arrow_field.extension_type_name(),
Some("arrow.uuid") | Some("uuid")
Some("arrow.uuid" | "uuid")
)
}
#[cfg(not(feature = "canonical_extension_types"))]
Expand Down
2 changes: 1 addition & 1 deletion arrow-buffer/src/bigint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1478,7 +1478,7 @@ mod tests {
}

// Exponentiation
for exp in vec![0, 1, 2, 3, 8, 100].into_iter() {
for exp in [0, 1, 2, 3, 8, 100] {
let actual = il.wrapping_pow(exp);
let (expected, overflow) = i256::from_bigint_with_overflow(bl.clone().pow(exp));
assert_eq!(actual.to_string(), expected.to_string());
Expand Down
2 changes: 1 addition & 1 deletion arrow-buffer/src/util/bit_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ fn get_remainder_bits(remainder: &[u8], remainder_len: usize) -> u64 {
.iter()
.enumerate()
.fold(0_u64, |acc, (index, &byte)| {
acc | (byte as u64) << (index * 8)
acc | ((byte as u64) << (index * 8))
});

bits & ((1 << remainder_len) - 1)
Expand Down
8 changes: 5 additions & 3 deletions arrow-cast/src/cast/decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ where
let error = cast_decimal_to_decimal_error::<I, O>(output_precision, output_scale);
array.try_unary(|x| {
f_fallible(x).ok_or_else(|| error(x)).and_then(|v| {
O::validate_decimal_precision(v, output_precision, output_scale).map(|_| v)
O::validate_decimal_precision(v, output_precision, output_scale).map(|()| v)
})
})?
};
Expand Down Expand Up @@ -671,7 +671,9 @@ where
T::DATA_TYPE,
))
})
.and_then(|v| T::validate_decimal_precision(v, precision, scale).map(|_| v))
.and_then(|v| {
T::validate_decimal_precision(v, precision, scale).map(|()| v)
})
})
.transpose()
})
Expand Down Expand Up @@ -801,7 +803,7 @@ where
v
))
})
.and_then(|v| D::validate_decimal_precision(v, precision, scale).map(|_| v))
.and_then(|v| D::validate_decimal_precision(v, precision, scale).map(|()| v))
})?
.with_precision_and_scale(precision, scale)
.map(|a| Arc::new(a) as ArrayRef)
Expand Down
Loading
Loading