转换 Binaryops#

二元操作

类型定义

template<typename L, typename R>
using binary_op_common_type_t = typename binary_op_common_type<L, R>::type#

二元操作通用类型助手。

枚举

enum class binary_operator : int32_t#

可在数据上执行的二元操作类型。

enumerator ADD#

运算符 +

enumerator SUB#

运算符 -

enumerator MUL#

运算符 *

enumerator DIV#

使用 lhs 和 rhs 的通用类型进行运算符 / 操作

enumerator TRUE_DIV#

在将类型提升为浮点类型后进行运算符 / 操作

enumerator FLOOR_DIV#

运算符 // 整数除法,如果两个参数都是整数,则向负无穷舍入;浮点类型的向下取整除法(对混合整数/浮点参数使用 C++ 类型提升)。如果需要不同的类型提升语义,调用方有责任在调用此函数之前手动进行提升。

enumerator MOD#

运算符 %

enumerator PMOD#

正数模运算符 如果余数为负,则返回 (remainder + divisor) % divisor;否则返回 (dividend % divisor)

enumerator PYMOD#

运算符 %,但遵循 Python 的负数符号规则

enumerator POW#

lhs ^ rhs

enumerator INT_POW#

int ^ int,用于避免浮点精度损失。对于负指数返回 0。

enumerator LOG_BASE#

对数运算(指定底数)

enumerator ATAN2#

二参数反正切

enumerator SHIFT_LEFT#

运算符 <<

enumerator SHIFT_RIGHT#

运算符 >>

enumerator SHIFT_RIGHT_UNSIGNED#

运算符 >>>(来自 Java)逻辑右移。在移位前转换为无符号值。

enumerator BITWISE_AND#

运算符 &

enumerator BITWISE_OR#

运算符 |

enumerator BITWISE_XOR#

运算符 ^

enumerator LOGICAL_AND#

运算符 &&

enumerator LOGICAL_OR#

运算符 ||

enumerator EQUAL#

运算符 ==

enumerator NOT_EQUAL#

运算符 !=

enumerator LESS#

运算符 <

enumerator GREATER#

运算符 >

enumerator LESS_EQUAL#

运算符 <=

enumerator GREATER_EQUAL#

运算符 >=

enumerator NULL_EQUALS#

当两个操作数都为 null 时返回 true;当其中一个为 null 时返回 false;当两个操作数都非 null 时返回相等性检查结果

enumerator NULL_NOT_EQUALS#

当两个操作数都为 null 时返回 false;当其中一个为 null 时返回 true;当两个操作数都非 null 时返回不等性检查结果

enumerator NULL_MAX#

当两个操作数都非 null 时返回最大值;当其中一个为 null 时返回非 null 的操作数;当两个操作数都为 null 时返回无效值

enumerator NULL_MIN#

当两个操作数都非 null 时返回最小值;当其中一个为 null 时返回非 null 的操作数;当两个操作数都为 null 时返回无效值

enumerator GENERIC_BINARY#

使用输入的 ptx 代码生成的通用二元运算符

enumerator NULL_LOGICAL_AND#

运算符 &&,遵循 Spark 规则:(null, null) 为 null,(null, true) 为 null,(null, false) 为 false,且 (valid, valid) == LOGICAL_AND(valid, valid)

enumerator NULL_LOGICAL_OR#

运算符 ||,遵循 Spark 规则:(null, null) 为 null,(null, true) 为 true,(null, false) 为 null,且 (valid, valid) == LOGICAL_OR(valid, valid)

enumerator INVALID_BINARY#

无效操作

函数

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::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#

在标量和列之间执行二元操作。

输出包含所有 0 <= i < rhs.size()op(lhs, rhs[i]) 结果。标量是左操作数,列元素是右操作数。在非交换二元操作的情况下,这种区别很重要。

无论运算符如何,输出值的有效性是两个操作数有效性的逻辑与(NullMin 和 NullMax 除外,它们是逻辑或)。

参数:
  • lhs – 左操作数标量

  • rhs – 右操作数列

  • op – 二元运算符

  • output_type – 输出列的期望数据类型

  • stream – 用于设备内存操作和内核启动的 CUDA 流

  • mr – 用于分配返回列的设备内存的设备内存资源

抛出:
  • cudf::logic_error – 如果 output_type 的 dtype 不是固定宽度类型

  • cudf::logic_error – 如果 output_type 的 dtype 对于比较和逻辑操作不是布尔类型。

  • cudf::data_type_error – 如果该操作不支持 lhsrhs 的类型

返回:

类型为 output_type 的输出列,包含二元操作的结果

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::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#

在列和标量之间执行二元操作。

输出包含所有 0 <= i < lhs.size()op(lhs[i], rhs) 结果。列元素是左操作数,标量是右操作数。在非交换二元操作的情况下,这种区别很重要。

无论运算符如何,输出值的有效性是两个操作数有效性的逻辑与(NullMin 和 NullMax 除外,它们是逻辑或)。

参数:
  • lhs – 左操作数列

  • rhs – 右操作数标量

  • op – 二元运算符

  • output_type – 输出列的期望数据类型

  • stream – 用于设备内存操作和内核启动的 CUDA 流

  • mr – 用于分配返回列的设备内存的设备内存资源

抛出:
  • cudf::logic_error – 如果 output_type 的 dtype 不是固定宽度类型

  • cudf::logic_error – 如果 output_type 的 dtype 对于比较和逻辑操作不是布尔类型。

  • cudf::data_type_error – 如果该操作不支持 lhsrhs 的类型

返回:

类型为 output_type 的输出列,包含二元操作的结果

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::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#

在两列之间执行二元操作。

输出包含所有 0 <= i < lhs.size()op(lhs[i], rhs[i]) 结果。

无论运算符如何,输出值的有效性是两个操作数有效性的逻辑与(NullMin 和 NullMax 除外,它们是逻辑或)。

参数:
  • lhs – 左操作数列

  • rhs – 右操作数列

  • op – 二元运算符

  • output_type – 输出列的期望数据类型

  • stream – 用于设备内存操作和内核启动的 CUDA 流

  • mr – 用于分配返回列的设备内存的设备内存资源

抛出:
返回:

类型为 output_type 的输出列,包含二元操作的结果

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::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#

使用用户定义的 PTX 函数在两列之间执行二元操作。

输出包含所有 0 <= i < lhs.size()op(lhs[i], rhs[i]) 结果。

无论运算符如何,输出值的有效性是两个操作数有效性的逻辑与。

参数:
  • lhs – 左操作数列

  • rhs – 右操作数列

  • ptx – 包含二元函数 PTX 代码的字符串

  • output_type – 输出列的期望数据类型。假设 output_type 与 PTX 代码中函数的输出数据类型兼容

  • stream – 用于设备内存操作和内核启动的 CUDA 流

  • mr – 用于分配返回列的设备内存的设备内存资源

抛出:
返回:

类型为 output_type 的输出列,包含二元操作的结果

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

根据给定的二元运算符 op 计算 fixed_point 数的 scale

参数:
  • op – 用于两个 fixed_point 数的 binary_operator

  • left_scale – 左侧 fixed_point 数的 Scale

  • right_scale – 右侧 fixed_point 数的 Scale

返回:

计算出的 fixed_point 数的结果 scale

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

根据给定的二元运算符 op 计算 fixed_point 数的 data_type

参数:
  • op – 用于两个 fixed_point 数的 binary_operator

  • lhs – 左侧 fixed_point 数的 cudf::data_type

  • rhs – 右侧 fixed_point 数的 cudf::data_type

返回:

计算出的 fixed_point 数的结果 cudf::data_type

变量

template<typename L, typename R>
constexpr bool binary_op_has_common_type_v = detail::binary_op_has_common_type_impl<void, L, R>::value#

检查二元操作类型是否具有通用类型。

template<typename L, typename R, typename = void>
struct binary_op_common_type#
#include <binaryop.hpp>

二元操作通用类型默认值。

template<typename L, typename R>
struct binary_op_common_type<L, R, std::enable_if_t<has_common_type_v<L, R>>>#
#include <binaryop.hpp>

二元操作通用类型特化。

公共类型

using type = std::common_type_t<L, R>#

模板参数的通用类型。

template<typename L, typename R>
struct binary_op_common_type<L, R, std::enable_if_t<is_fixed_point<L>() && cuda::std::is_floating_point_v<R>>>#
#include <binaryop.hpp>

二元操作通用类型特化。

公共类型

using type = L#

模板参数的通用类型。

template<typename L, typename R>
struct binary_op_common_type<L, R, std::enable_if_t<is_fixed_point<R>() && cuda::std::is_floating_point_v<L>>>#
#include <binaryop.hpp>

二元操作通用类型特化。

公共类型

using type = R#

模板参数的通用类型。