Transformation Binaryops#

group transformation_binaryops

Enums

enum class binary_operator : int32_t#

Types of binary operations that can be performed on data.

Values:

enumerator ADD#

operator +

enumerator SUB#

operator -

enumerator MUL#

operator *

enumerator DIV#

operator / using common type of lhs and rhs

enumerator TRUE_DIV#

operator / after promoting type to floating point

enumerator FLOOR_DIV#

operator // integer division rounding towards negative infinity if both arguments are integral; floor division for floating types (using C++ type promotion for mixed integral/floating arguments) If different promotion semantics are required, it is the responsibility of the caller to promote manually before calling in to this function.

enumerator MOD#

operator %

enumerator PMOD#

positive modulo operator If remainder is negative, this returns (remainder + divisor) % divisor else, it returns (dividend % divisor)

enumerator PYMOD#

operator % but following Python’s sign rules for negatives

enumerator POW#

lhs ^ rhs

enumerator INT_POW#

int ^ int, used to avoid floating point precision loss. Returns 0 for negative exponents.

enumerator LOG_BASE#

logarithm to the base

enumerator ATAN2#

2-argument arctangent

enumerator SHIFT_LEFT#

operator <<

enumerator SHIFT_RIGHT#

operator >>

enumerator SHIFT_RIGHT_UNSIGNED#

operator >>> (from Java) Logical right shift. Casts to an unsigned value before shifting.

enumerator BITWISE_AND#

operator &

enumerator BITWISE_OR#

operator |

enumerator BITWISE_XOR#

operator ^

enumerator LOGICAL_AND#

operator &&

enumerator LOGICAL_OR#

operator ||

enumerator EQUAL#

operator ==

enumerator NOT_EQUAL#

operator !=

enumerator LESS#

operator <

enumerator GREATER#

operator >

enumerator LESS_EQUAL#

operator <=

enumerator GREATER_EQUAL#

operator >=

enumerator NULL_EQUALS#

Returns true when both operands are null; false when one is null; the result of equality when both are non-null

enumerator NULL_MAX#

Returns max of operands when both are non-null; returns the non-null operand when one is null; or invalid when both are null

enumerator NULL_MIN#

Returns min of operands when both are non-null; returns the non-null operand when one is null; or invalid when both are null

enumerator GENERIC_BINARY#

generic binary operator to be generated with input ptx code

enumerator NULL_LOGICAL_AND#

operator && with Spark rules: (null, null) is null, (null, true) is null, (null, false) is false, and (valid, valid) == LOGICAL_AND(valid, valid)

enumerator NULL_LOGICAL_OR#

operator || with Spark rules: (null, null) is null, (null, true) is true, (null, false) is null, and (valid, valid) == LOGICAL_OR(valid, valid)

enumerator INVALID_BINARY#

invalid operation

Functions

std::unique_ptr<column> binary_operation(scalar const &lhs, column_view const &rhs, binary_operator op, data_type output_type, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource())#

Performs a binary operation between a scalar and a column.

The output contains the result of op(lhs, rhs[i]) for all 0 <= i < rhs.size() The scalar is the left operand and the column elements are the right operand. This distinction is significant in case of non-commutative binary operations

Regardless of the operator, the validity of the output value is the logical AND of the validity of the two operands except NullMin and NullMax (logical OR).

Parameters:
  • lhs – The left operand scalar

  • rhs – The right operand column

  • op – The binary operator

  • output_type – The desired data type of the output column

  • stream – CUDA stream used for device memory operations and kernel launches

  • mr – Device memory resource used to allocate the returned column’s device memory

Throws:
  • cudf::logic_error – if output_type dtype isn’t fixed-width

  • cudf::logic_error – if output_type dtype isn’t boolean for comparison and logical operations.

  • cudf::data_type_error – if the operation is not supported for the types of lhs and rhs

Returns:

Output column of output_type type containing the result of the binary operation

std::unique_ptr<column> binary_operation(column_view const &lhs, scalar const &rhs, binary_operator op, data_type output_type, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource())#

Performs a binary operation between a column and a scalar.

The output contains the result of op(lhs[i], rhs) for all 0 <= i < lhs.size() The column elements are the left operand and the scalar is the right operand. This distinction is significant in case of non-commutative binary operations

Regardless of the operator, the validity of the output value is the logical AND of the validity of the two operands except NullMin and NullMax (logical OR).

Parameters:
  • lhs – The left operand column

  • rhs – The right operand scalar

  • op – The binary operator

  • output_type – The desired data type of the output column

  • stream – CUDA stream used for device memory operations and kernel launches

  • mr – Device memory resource used to allocate the returned column’s device memory

Throws:
  • cudf::logic_error – if output_type dtype isn’t fixed-width

  • cudf::logic_error – if output_type dtype isn’t boolean for comparison and logical operations.

  • cudf::data_type_error – if the operation is not supported for the types of lhs and rhs

Returns:

Output column of output_type type containing the result of the binary operation

std::unique_ptr<column> binary_operation(column_view const &lhs, column_view const &rhs, binary_operator op, data_type output_type, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource())#

Performs a binary operation between two columns.

The output contains the result of op(lhs[i], rhs[i]) for all 0 <= i < lhs.size()

Regardless of the operator, the validity of the output value is the logical AND of the validity of the two operands except NullMin and NullMax (logical OR).

Parameters:
  • lhs – The left operand column

  • rhs – The right operand column

  • op – The binary operator

  • output_type – The desired data type of the output column

  • stream – CUDA stream used for device memory operations and kernel launches

  • mr – Device memory resource used to allocate the returned column’s device memory

Throws:
Returns:

Output column of output_type type containing the result of the binary operation

std::unique_ptr<column> binary_operation(column_view const &lhs, column_view const &rhs, std::string const &ptx, data_type output_type, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::mr::device_memory_resource *mr = rmm::mr::get_current_device_resource())#

Performs a binary operation between two columns using a user-defined PTX function.

The output contains the result of op(lhs[i], rhs[i]) for all 0 <= i < lhs.size()

Regardless of the operator, the validity of the output value is the logical AND of the validity of the two operands

Parameters:
  • lhs – The left operand column

  • rhs – The right operand column

  • ptx – String containing the PTX of a binary function

  • output_type – The desired data type of the output column. It is assumed that output_type is compatible with the output data type of the function in the PTX code

  • stream – CUDA stream used for device memory operations and kernel launches

  • mr – Device memory resource used to allocate the returned column’s device memory

Throws:
Returns:

Output column of output_type type containing the result of the binary operation

int32_t binary_operation_fixed_point_scale(binary_operator op, int32_t left_scale, int32_t right_scale)#

Computes the scale for a fixed_point number based on given binary operator op

Parameters:
  • op – The binary_operator used for two fixed_point numbers

  • left_scale – Scale of left fixed_point number

  • right_scale – Scale of right fixed_point number

Returns:

The resulting scale of the computed fixed_point number

cudf::data_type binary_operation_fixed_point_output_type(binary_operator op, cudf::data_type const &lhs, cudf::data_type const &rhs)#

Computes the data_type for a fixed_point number based on given binary operator op

Parameters:
  • op – The binary_operator used for two fixed_point numbers

  • lhscudf::data_type of left fixed_point number

  • rhscudf::data_type of right fixed_point number

Returns:

The resulting cudf::data_type of the computed fixed_point number