Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgazelka committed Oct 1, 2024
1 parent b2dabf6 commit 9658ad2
Show file tree
Hide file tree
Showing 262 changed files with 1,806 additions and 1,309 deletions.
56 changes: 56 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,63 @@ features = ["derive", "rc"]
version = "1.0.200"

[workspace.lints.clippy]
cast-sign-loss = "allow"
cast_lossless = "allow"
cast_possible_truncation = "allow"
cast_possible_wrap = "allow"
cast_precision_loss = "allow"
default_trait_access = "allow"
doc-markdown = "allow"
doc_link_with_quotes = "allow"
enum_glob_use = "allow"
float_cmp = "allow"
fn_params_excessive_bools = "allow"
from_iter_instead_of_collect = "allow"
if_not_else = "allow"
implicit_hasher = "allow"
inline_always = "allow"
into_iter_without_iter = "allow"
items_after_statements = "allow"
iter_without_into_iter = "allow"
manual_let_else = "allow"
many_single_char_names = "allow"
map_unwrap_or = "allow"
match_bool = "allow"
match_same_arms = "allow"
match_wildcard_for_single_variants = "allow"
missing-panics-doc = "allow"
missing_errors_doc = "allow"
module_name_repetitions = "allow"
must_use_candidate = "allow"
needless_pass_by_value = "allow"
needless_return = "allow"
nonminimal_bool = "allow"
only_used_in_recursion = "allow"
pedantic = {level = "deny", priority = -1}
perf = {level = "deny", priority = -1}
redundant_closure_for_method_calls = "allow"
redundant_else = "allow"
return_self_not_must_use = "allow"
similar_names = "allow"
single_match = "allow"
single_match_else = "allow"
struct_excessive_bools = "allow"
style = {level = "deny", priority = 1}
too_many_lines = "allow"
trivially_copy_pass_by_ref = "allow"
uninlined_format_args = "allow"
unnecessary_wraps = "allow"
unnested_or_patterns = "allow"
unreadable_literal = "allow"
# todo: remove?
unsafe_derive_deserialize = "allow"
unused_async = "allow"
# used_underscore_items = "allow" # REMOVE
unused_self = "allow"
use-self = "deny"
used_underscore_binding = "allow" # REMOVE REMOVE
wildcard_imports = "allow"
zero_sized_map_values = "allow"

[workspace.package]
edition = "2021"
Expand Down
5 changes: 1 addition & 4 deletions src/arrow2/src/array/binary/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,7 @@ impl<O: Offset, T: AsRef<[u8]>> TryPush<Option<T>> for MutableBinaryArray<O> {
Some(value) => {
self.values.try_push(value.as_ref())?;

match &mut self.validity {
Some(validity) => validity.push(true),
None => {}
}
if let Some(validity) = &mut self.validity { validity.push(true) }
}
None => {
self.values.push("");
Expand Down
5 changes: 1 addition & 4 deletions src/arrow2/src/array/boolean/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@ impl MutableBooleanArray {
match value {
Some(value) => {
self.values.push(value);
match &mut self.validity {
Some(validity) => validity.push(true),
None => {}
}
if let Some(validity) = &mut self.validity { validity.push(true) }
}
None => {
self.values.push(false);
Expand Down
5 changes: 1 addition & 4 deletions src/arrow2/src/array/fixed_size_binary/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,7 @@ impl MutableFixedSizeBinaryArray {
}
self.values.extend_from_slice(bytes);

match &mut self.validity {
Some(validity) => validity.push(true),
None => {}
}
if let Some(validity) = &mut self.validity { validity.push(true) }
}
None => {
self.values.resize(self.values.len() + self.size, 0);
Expand Down
2 changes: 2 additions & 0 deletions src/arrow2/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ pub(crate) trait Container {
}

/// A trait describing a mutable array; i.e. an array whose values can be changed.
///
/// Mutable arrays cannot be cloned but can be mutated in place,
/// thereby making them useful to perform numeric operations without allocations.
/// As in [`Array`], concrete arrays (such as [`MutablePrimitiveArray`]) implement how they are mutated.
Expand Down Expand Up @@ -416,6 +417,7 @@ pub fn new_empty_array(data_type: DataType) -> Box<dyn Array> {
}

/// Creates a new [`Array`] of [`DataType`] `data_type` and `length`.
///
/// The array is guaranteed to have [`Array::null_count`] equal to [`Array::len`]
/// for all types except Union, which does not have a validity.
pub fn new_null_array(data_type: DataType, length: usize) -> Box<dyn Array> {
Expand Down
5 changes: 1 addition & 4 deletions src/arrow2/src/array/primitive/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,7 @@ impl<T: NativeType> MutablePrimitiveArray<T> {
match value {
Some(value) => {
self.values.push(value);
match &mut self.validity {
Some(validity) => validity.push(true),
None => {}
}
if let Some(validity) = &mut self.validity { validity.push(true) }
}
None => {
self.values.push(T::default());
Expand Down
5 changes: 1 addition & 4 deletions src/arrow2/src/array/utf8/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,10 +521,7 @@ impl<O: Offset, T: AsRef<str>> TryPush<Option<T>> for MutableUtf8Array<O> {
Some(value) => {
self.values.try_push(value.as_ref())?;

match &mut self.validity {
Some(validity) => validity.push(true),
None => {}
}
if let Some(validity) = &mut self.validity { validity.push(true) }
}
None => {
self.values.push("");
Expand Down
1 change: 1 addition & 0 deletions src/arrow2/src/bitmap/utils/slice_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ enum State {
}

/// Iterator over a bitmap that returns slices of set regions
///
/// This is the most efficient method to extract slices of values from arrays
/// with a validity bitmap.
/// For example, the bitmap `00101111` returns `[(0,4), (6,1)]`
Expand Down
10 changes: 6 additions & 4 deletions src/arrow2/src/compute/arithmetics/basic/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ where
binary(lhs, rhs, lhs.data_type().clone(), op)
}

/// Overflowing addition of two primitive arrays. If the result from the sum is
/// larger than the possible number for this type, the result for the operation
/// Overflowing addition of two primitive arrays.
///
/// If the result from the sum is larger than the possible number for this type, the result for the operation
/// will be an array with overflowed values and a validity array indicating
/// the overflowing elements from the array.
///
Expand Down Expand Up @@ -275,8 +276,9 @@ where
unary(lhs, op, lhs.data_type().clone())
}

/// Overflowing addition of a scalar T to a primitive array of type T. If the
/// result from the sum is larger than the possible number for this type, then
/// Overflowing addition of a scalar T to a primitive array of type T.
///
/// If the result from the sum is larger than the possible number for this type, then
/// the result will be an array with overflowed values and a validity array
/// indicating the overflowing elements from the array
///
Expand Down
1 change: 1 addition & 0 deletions src/arrow2/src/compute/arithmetics/basic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use super::super::arity::{unary, unary_checked};

/// Trait describing a [`NativeType`] whose semantics of arithmetic in Arrow equals
/// the semantics in Rust.
///
/// A counter example is `i128`, that in arrow represents a decimal while in rust represents
/// a signed integer.
pub trait NativeArithmetics: NativeType {}
Expand Down
9 changes: 6 additions & 3 deletions src/arrow2/src/compute/arithmetics/basic/mul.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ where
binary(lhs, rhs, lhs.data_type().clone(), op)
}

/// Overflowing multiplication of two primitive arrays. If the result from the
/// Overflowing multiplication of two primitive arrays.
///
/// If the result from the
/// mul overflows, the result for the operation will be an array with
/// overflowed values and a validity array indicating the overflowing elements
/// from the array.
Expand Down Expand Up @@ -276,8 +278,9 @@ where
unary(lhs, op, lhs.data_type().clone())
}

/// Overflowing multiplication of a scalar T to a primitive array of type T. If
/// the result from the mul overflows for this type,
/// Overflowing multiplication of a scalar T to a primitive array of type T.
///
/// If the result from the mul overflows for this type,
/// then the result will be an array with overflowed values and a validity
/// array indicating the overflowing elements from the array
///
Expand Down
9 changes: 6 additions & 3 deletions src/arrow2/src/compute/arithmetics/basic/sub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ where
binary(lhs, rhs, lhs.data_type().clone(), op)
}

/// Overflowing subtraction of two primitive arrays. If the result from the sub
/// Overflowing subtraction of two primitive arrays.
///
/// If the result from the sub
/// is smaller than the possible number for this type, the result for the
/// operation will be an array with overflowed values and a validity array
/// indicating the overflowing elements from the array.
Expand Down Expand Up @@ -275,8 +277,9 @@ where
unary(lhs, op, lhs.data_type().clone())
}

/// Overflowing subtraction of a scalar T to a primitive array of type T. If
/// the result from the sub is smaller than the possible number for this type,
/// Overflowing subtraction of a scalar T to a primitive array of type T.
///
/// If the result from the sub is smaller than the possible number for this type,
/// then the result will be an array with overflowed values and a validity
/// array indicating the overflowing elements from the array
///
Expand Down
12 changes: 9 additions & 3 deletions src/arrow2/src/compute/arithmetics/decimal/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ pub fn add(lhs: &PrimitiveArray<i128>, rhs: &PrimitiveArray<i128>) -> PrimitiveA
}

/// Saturated addition of two decimal primitive arrays with the same precision
/// and scale. If the precision and scale is different, then an
/// and scale.
///
/// If the precision and scale is different, then an
/// InvalidArgumentError is returned. If the result from the sum is larger than
/// the possible number with the selected precision then the resulted number in
/// the arrow array is the maximum number for the selected precision.
Expand Down Expand Up @@ -98,7 +100,9 @@ pub fn saturating_add(
}

/// Checked addition of two decimal primitive arrays with the same precision
/// and scale. If the precision and scale is different, then an
/// and scale.
///
/// If the precision and scale is different, then an
/// InvalidArgumentError is returned. If the result from the sum is larger than
/// the possible number with the selected precision (overflowing), then the
/// validity for that index is changed to None
Expand Down Expand Up @@ -156,7 +160,9 @@ impl ArraySaturatingAdd<PrimitiveArray<i128>> for PrimitiveArray<i128> {
}

/// Adaptive addition of two decimal primitive arrays with different precision
/// and scale. If the precision and scale is different, then the smallest scale
/// and scale.
///
/// If the precision and scale is different, then the smallest scale
/// and precision is adjusted to the largest precision and scale. If during the
/// addition one of the results is larger than the max possible value, the
/// result precision is changed to the precision of the max value
Expand Down
20 changes: 15 additions & 5 deletions src/arrow2/src/compute/arithmetics/decimal/div.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ use crate::{

use super::{adjusted_precision_scale, get_parameters, max_value, number_digits};

/// Divide two decimal primitive arrays with the same precision and scale. If
/// Divide two decimal primitive arrays with the same precision and scale.
///
/// If
/// the precision and scale is different, then an InvalidArgumentError is
/// returned. This function panics if the dividend is divided by 0 or None.
/// This function also panics if the division produces a number larger
Expand Down Expand Up @@ -66,7 +68,9 @@ pub fn div(lhs: &PrimitiveArray<i128>, rhs: &PrimitiveArray<i128>) -> PrimitiveA
binary(lhs, rhs, lhs.data_type().clone(), op)
}

/// Multiply a decimal [`PrimitiveArray`] with a [`PrimitiveScalar`] with the same precision and scale. If
/// Multiply a decimal [`PrimitiveArray`] with a [`PrimitiveScalar`] with the same precision and scale.
///
/// If
/// the precision and scale is different, then an InvalidArgumentError is
/// returned. This function panics if the multiplied numbers result in a number
/// larger than the possible number for the selected precision.
Expand Down Expand Up @@ -109,7 +113,9 @@ pub fn div_scalar(lhs: &PrimitiveArray<i128>, rhs: &PrimitiveScalar<i128>) -> Pr
}

/// Saturated division of two decimal primitive arrays with the same
/// precision and scale. If the precision and scale is different, then an
/// precision and scale.
///
/// If the precision and scale is different, then an
/// InvalidArgumentError is returned. If the result from the division is
/// larger than the possible number with the selected precision then the
/// resulted number in the arrow array is the maximum number for the selected
Expand Down Expand Up @@ -160,7 +166,9 @@ pub fn saturating_div(
}

/// Checked division of two decimal primitive arrays with the same precision
/// and scale. If the precision and scale is different, then an
/// and scale.
///
/// If the precision and scale is different, then an
/// InvalidArgumentError is returned. If the divisor is zero, then the
/// validity for that index is changed to None
///
Expand Down Expand Up @@ -214,7 +222,9 @@ impl ArrayCheckedDiv<PrimitiveArray<i128>> for PrimitiveArray<i128> {
}

/// Adaptive division of two decimal primitive arrays with different precision
/// and scale. If the precision and scale is different, then the smallest scale
/// and scale.
///
/// If the precision and scale is different, then the smallest scale
/// and precision is adjusted to the largest precision and scale. If during the
/// division one of the results is larger than the max possible value, the
/// result precision is changed to the precision of the max value. The function
Expand Down
5 changes: 3 additions & 2 deletions src/arrow2/src/compute/arithmetics/decimal/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Defines the arithmetic kernels for Decimal `PrimitiveArrays`. The
//! [`Decimal`](crate::datatypes::DataType::Decimal) type specifies the
//! Defines the arithmetic kernels for Decimal `PrimitiveArrays`.
//!
//! The [`Decimal`](crate::datatypes::DataType::Decimal) type specifies the
//! precision and scale parameters. These affect the arithmetic operations and
//! need to be considered while doing operations with Decimal numbers.

Expand Down
20 changes: 15 additions & 5 deletions src/arrow2/src/compute/arithmetics/decimal/mul.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ use crate::{

use super::{adjusted_precision_scale, get_parameters, max_value, number_digits};

/// Multiply two decimal primitive arrays with the same precision and scale. If
/// Multiply two decimal primitive arrays with the same precision and scale.
///
/// If
/// the precision and scale is different, then an InvalidArgumentError is
/// returned. This function panics if the multiplied numbers result in a number
/// larger than the possible number for the selected precision.
Expand Down Expand Up @@ -67,7 +69,9 @@ pub fn mul(lhs: &PrimitiveArray<i128>, rhs: &PrimitiveArray<i128>) -> PrimitiveA
binary(lhs, rhs, lhs.data_type().clone(), op)
}

/// Multiply a decimal [`PrimitiveArray`] with a [`PrimitiveScalar`] with the same precision and scale. If
/// Multiply a decimal [`PrimitiveArray`] with a [`PrimitiveScalar`] with the same precision and scale.
///
/// If
/// the precision and scale is different, then an InvalidArgumentError is
/// returned. This function panics if the multiplied numbers result in a number
/// larger than the possible number for the selected precision.
Expand Down Expand Up @@ -113,7 +117,9 @@ pub fn mul_scalar(lhs: &PrimitiveArray<i128>, rhs: &PrimitiveScalar<i128>) -> Pr
}

/// Saturated multiplication of two decimal primitive arrays with the same
/// precision and scale. If the precision and scale is different, then an
/// precision and scale.
///
/// If the precision and scale is different, then an
/// InvalidArgumentError is returned. If the result from the multiplication is
/// larger than the possible number with the selected precision then the
/// resulted number in the arrow array is the maximum number for the selected
Expand Down Expand Up @@ -164,7 +170,9 @@ pub fn saturating_mul(
}

/// Checked multiplication of two decimal primitive arrays with the same
/// precision and scale. If the precision and scale is different, then an
/// precision and scale.
///
/// If the precision and scale is different, then an
/// InvalidArgumentError is returned. If the result from the mul is larger than
/// the possible number with the selected precision (overflowing), then the
/// validity for that index is changed to None
Expand Down Expand Up @@ -226,7 +234,9 @@ impl ArraySaturatingMul<PrimitiveArray<i128>> for PrimitiveArray<i128> {
}

/// Adaptive multiplication of two decimal primitive arrays with different
/// precision and scale. If the precision and scale is different, then the
/// precision and scale.
///
/// If the precision and scale is different, then the
/// smallest scale and precision is adjusted to the largest precision and
/// scale. If during the multiplication one of the results is larger than the
/// max possible value, the result precision is changed to the precision of the
Expand Down
Loading

0 comments on commit 9658ad2

Please sign in to comment.