Expand description
Defines numeric arithmetic kernels on [PrimitiveArray], such as add
Re-exportsΒ§
use std::cmp::Ordering;πuse std::collections::TryReserveError;πuse std::convert::Infallible;πuse std::fmt::Formatter;πuse std::sync::Arc;πuse arrow_array::cast::AsArray;πuse arrow_array::temporal_conversions::NANOSECONDS;πuse arrow_array::temporal_conversions::SECONDS_IN_DAY;πuse arrow_array::timezone::Tz;πuse arrow_buffer::ArrowNativeType;πuse arrow_buffer::BooleanBuffer;πuse arrow_buffer::DivisorI32;πuse arrow_buffer::DivisorI64;πuse arrow_buffer::DivisorU32;πuse arrow_buffer::DivisorU64;πuse arrow_buffer::IntervalDayTime;πuse arrow_buffer::IntervalMonthDayNano;πuse arrow_buffer::NullBuffer;πuse arrow_buffer::i256;πuse arrow_schema::ArrowError;πuse arrow_schema::DataType;πuse arrow_schema::IntervalUnit;πuse arrow_schema::TimeUnit;πuse num_traits::CheckedMul;πuse num_traits::ToPrimitive;πuse crate::arity::binary;πuse crate::arity::try_binary;πuse arrow_array::types::*;πuse arrow_array::*;π
MacrosΒ§
- date π
- divisor_
op π - Defines
$fn, which computes/or%of an array by a scalar with a precomputed divisor. It returnsNonefor an op other than/and%, when the scalar is null, or when a value could fail to divide by it (zero, or$falliblefor/), so thatinteger_opreturns an error only for a valid value that fails. Otherwise no value can fail, andunarydivides every slot, null or not, unless the array has more than$max_nullsnulls, where dividing only the valid values withtry_unarycosts less - neg_
checked π - neg_
wrapping π - op π
- Perform an infallible binary operation on potentially scalar inputs
- op_ref π
- Same as
opbut with a type hint for the returned array - signed_
mul_ πoverflowing - The wrapping product of two signed integers and whether it overflowed.
- signed_
overflowing_ πop - timestamp π
- try_op π
- Perform a fallible binary operation on potentially scalar inputs
- try_
op_ πref - Same as
try_opbut with a type hint for the returned array - unsigned_
overflowing_ πop
EnumsΒ§
- Op π
- An enumeration of arithmetic operations
TraitsΒ§
- DateOp π
- Arithmetic trait for date arrays
- Interval
Op π - Arithmetic trait for interval arrays
- Overflowing
Op π - Wrapping
+,-and*that also report whether they overflowed, written so that LLVM vectorizes a loop over them. - Timestamp
Op π - Arithmetic trait for timestamp arrays
FunctionsΒ§
- abs_
checked π - add
- Perform
lhs + rhs, returning an error on overflow - add_
wrapping - Perform
lhs + rhs, wrapping on overflow for [DataType::is_integer] - any_
valid π - Whether any valid row of
nullsis set inoverflowed - arithmetic_
op π - Dispatch the given
opto the appropriate specialized kernel - collect_
overflowing π - Collects the values of
iter, and whether any was flagged as overflowed. - date_op π
- Perform arithmetic operation on a date array
- decimal_
op π - Perform arithmetic operation on decimal arrays
- div
- Perform
lhs / rhs - divisor_
op_ πi32 - divisor_
op_ πi64 - divisor_
op_ πu32 - divisor_
op_ πu64 - duration_
op π - float_
op π - Perform an arithmetic operation on floats
- integer_
op π - Perform an arithmetic operation on integers
- interval_
f64_ πop - interval_
mul_ πf64 - Multiplies an
IntervalMonthDayNanoby anf64, mirroring DuckDBβsinterval_tlayout of months, days, and a sub-day component (nanoseconds in Arrow, microseconds in DuckDB). https://github.com/duckdb/duckdb/blob/21aca0424f1faf78b593b1e6fbfdd4846624c987/src/include/duckdb/common/types/interval.hpp#L24-L27 - interval_
mul_ πop - interval_
op π - Perform arithmetic operation on an interval array
- memory_
error π - Converts an allocation failure in
collect_overflowing. - mul
- Perform
lhs * rhs, returning an error on overflow - mul_
checked_ πcold - [
ArrowNativeTypeOp::mul_checked] out of line, for closures that call it only afterchecked_muloverflows, so that building the error doesnβt stop them from being inlined - mul_
i32_ πi64 - mul_
wrapping - Perform
lhs * rhs, wrapping on overflow for [DataType::is_integer] - neg
- Negates each element of
array, returning an error on overflow - neg_
wrapping - Negates each element of
array, wrapping on overflow for [DataType::is_integer] - overflowing_
op π - Applies
opto every slot oflandr, including null slots, without branching on overflow. - rem
- Perform
lhs % rhs - rescale_
left π - Multiplies
lbymul, then appliesop, reporting whether either step overflowed. With unequal scales only the operand with the smaller scale is multiplied, because the other multiplier is one. - rescale_
right π - Like
rescale_left, but multipliesrbymul. - rescale_
scalar π - Multiplies the value of the decimal scalar
arraybymul, so that the kernel doesnβt rescale it on every row. - scalar_
divisor π - Returns the scalar divisor
rscaled byr_mul, whenlis an array and dividing any value by it canβt fail. That needsrto be valid and the product to fit and be neither 0 nor -1. - scaled_
div π - Divides
l * 10^mul_powbyra digit at a time, without forming the scaled numerator. Used when scalinglwould overflowT::Native, which it does well before the quotient does. - sub
- Perform
lhs - rhs, returning an error on overflow - sub_
wrapping - Perform
lhs - rhs, wrapping on overflow for [DataType::is_integer] - timestamp_
op π - Perform arithmetic operation on a timestamp array
- unless_
valid_ πoverflow - Builds the array from the output of
collect_overflowing, or returnsNoneif a valid row overflowed.