transform.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 
6 #pragma once
7 
9 #include <cudf/column/scalar_column_view.hpp>
10 #include <cudf/types.hpp>
11 #include <cudf/utilities/export.hpp>
13 
14 #include <memory>
15 #include <optional>
16 #include <variant>
17 #include <vector>
18 
19 namespace CUDF_EXPORT cudf {
20 
59 [[deprecated("Use transform_extended instead")]] std::unique_ptr<column> transform(
60  std::vector<column_view> const& inputs,
61  std::string const& transform_udf,
62  data_type output_type,
63  bool is_ptx,
64  std::optional<void*> user_data = std::nullopt,
65  null_aware is_null_aware = null_aware::NO,
66  output_nullability null_policy = output_nullability::PRESERVE,
69 
74 using transform_input = std::variant<column_view, scalar_column_view>;
75 
82  data_type type = data_type{type_id::EMPTY};
83 
84  output_nullability nullability =
85  output_nullability::PRESERVE;
87 };
88 
124 std::unique_ptr<column> transform_extended(
125  std::span<transform_input const> inputs,
126  std::string const& udf,
127  data_type output_type,
128  udf_source_type source_type,
129  std::optional<void*> user_data = std::nullopt,
130  null_aware is_null_aware = null_aware::NO,
131  std::optional<size_type> row_size = std::nullopt,
132  output_nullability null_policy = output_nullability::PRESERVE,
135 
178 std::unique_ptr<table> multi_transform(
179  std::string const& udf,
180  udf_source_type source_type,
181  null_aware is_null_aware,
182  std::optional<void*> user_data,
183  std::span<transform_input const> inputs,
184  std::span<transform_output const> outputs,
185  std::vector<std::unique_ptr<column>>&& string_offsets,
186  std::optional<size_type> row_size,
189 
193 enum class lto_binary_type : uint8_t {
194  LTO_IR, //< LTO-IR binary
195  FATBIN //< FATBIN binary
196 };
197 
236 std::unique_ptr<table> transform_lto(
237  std::span<uint8_t const> udf,
238  lto_binary_type binary_type,
239  null_aware is_null_aware,
240  std::optional<void*> user_data,
241  std::span<transform_input const> inputs,
242  std::span<transform_output const> outputs,
243  std::vector<std::unique_ptr<column>>&& string_offsets,
244  std::optional<size_type> row_size,
247 
262 [[deprecated]] std::pair<std::unique_ptr<rmm::device_buffer>, size_type> nans_to_nulls(
263  column_view const& input,
266 
278 std::unique_ptr<column> column_nans_to_nulls(
279  column_view const& input,
282 
301 std::unique_ptr<column> compute_column(
302  table_view const& table,
303  ast::expression const& expr,
306 
326 std::unique_ptr<column> compute_column_jit(
327  table_view const& table,
328  ast::expression const& expr,
331 
348 std::pair<std::unique_ptr<rmm::device_buffer>, cudf::size_type> bools_to_mask(
349  column_view const& input,
352 
378 std::pair<std::unique_ptr<cudf::table>, std::unique_ptr<cudf::column>> encode(
379  cudf::table_view const& input,
382 
411 std::pair<std::unique_ptr<column>, table_view> one_hot_encode(
412  column_view const& input,
413  column_view const& categories,
416 
439 std::unique_ptr<column> mask_to_bools(
440  bitmask_type const* bitmask,
441  size_type begin_bit,
442  size_type end_bit,
445 
472 std::unique_ptr<column> row_bit_count(
473  table_view const& t,
476 
496 std::unique_ptr<column> segmented_row_bit_count(
497  table_view const& t,
498  size_type segment_length,
501  // end of group
503 } // namespace CUDF_EXPORT cudf
A non-owning, immutable view of device data as a column of elements, some of which may be null as ind...
Indicator for the logical data type of an element in a column.
Definition: types.hpp:287
A set of cudf::column_view's of the same size.
Definition: table_view.hpp:189
A set of cudf::column's of the same size.
Definition: table.hpp:29
Class definitions for building and evaluating abstract syntax tree expressions.
rmm::cuda_stream_view const get_default_stream()
Get the current default stream.
rmm::device_async_resource_ref get_current_device_resource_ref()
Get the current device memory resource reference.
cuda::mr::resource_ref< cuda::mr::device_accessible > device_async_resource_ref
std::pair< std::unique_ptr< cudf::table >, std::unique_ptr< cudf::column > > encode(cudf::table_view const &input, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Encode the rows of the given table as integers.
std::unique_ptr< column > row_bit_count(table_view const &t, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Returns an approximate cumulative size in bits of all columns in the table_view for each row.
std::unique_ptr< column > transform_extended(std::span< transform_input const > inputs, std::string const &udf, data_type output_type, udf_source_type source_type, std::optional< void * > user_data=std::nullopt, null_aware is_null_aware=null_aware::NO, std::optional< size_type > row_size=std::nullopt, output_nullability null_policy=output_nullability::PRESERVE, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Creates a new column by applying a transform function against every element of the input columns.
std::unique_ptr< table > multi_transform(std::string const &udf, udf_source_type source_type, null_aware is_null_aware, std::optional< void * > user_data, std::span< transform_input const > inputs, std::span< transform_output const > outputs, std::vector< std::unique_ptr< column >> &&string_offsets, std::optional< size_type > row_size, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Creates a new table by applying a transform function against every element of the input columns.
std::pair< std::unique_ptr< rmm::device_buffer >, cudf::size_type > bools_to_mask(column_view const &input, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Creates a bitmask from a column of boolean elements.
std::pair< std::unique_ptr< column >, table_view > one_hot_encode(column_view const &input, column_view const &categories, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Encodes input by generating a new column for each value in categories indicating the presence of that...
std::unique_ptr< column > mask_to_bools(bitmask_type const *bitmask, size_type begin_bit, size_type end_bit, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Creates a boolean column from given bitmask.
std::unique_ptr< column > transform(std::vector< column_view > const &inputs, std::string const &transform_udf, data_type output_type, bool is_ptx, std::optional< void * > user_data=std::nullopt, null_aware is_null_aware=null_aware::NO, output_nullability null_policy=output_nullability::PRESERVE, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Creates a new column by applying a transform function against every element of the input columns.
std::variant< column_view, scalar_column_view > transform_input
Typedef for inputs to the transform function. Each input can be either a column or a scalar column.
Definition: transform.hpp:74
std::pair< std::unique_ptr< rmm::device_buffer >, size_type > nans_to_nulls(column_view const &input, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Creates a null_mask from input by converting NaN to null and preserving existing null values and also...
std::unique_ptr< table > transform_lto(std::span< uint8_t const > udf, lto_binary_type binary_type, null_aware is_null_aware, std::optional< void * > user_data, std::span< transform_input const > inputs, std::span< transform_output const > outputs, std::vector< std::unique_ptr< column >> &&string_offsets, std::optional< size_type > row_size, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Creates a new table by applying a transform function against every element of the input columns.
std::unique_ptr< column > compute_column(table_view const &table, ast::expression const &expr, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Compute a new column by evaluating an expression tree on a table.
std::unique_ptr< column > column_nans_to_nulls(column_view const &input, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Creates a null_mask from input by converting NaN elements to null rows and preserving existing null v...
std::unique_ptr< column > segmented_row_bit_count(table_view const &t, size_type segment_length, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Returns an approximate cumulative size in bits of all columns in the table_view for each segment of r...
std::unique_ptr< column > compute_column_jit(table_view const &table, ast::expression const &expr, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Compute a new column by evaluating an expression tree on a table using a JIT-compiled kernel.
lto_binary_type
The type of LTO Binary.
Definition: transform.hpp:193
int32_t size_type
Row index type for columns and tables.
Definition: types.hpp:85
null_policy
Enum to specify whether to include nulls or exclude nulls.
Definition: types.hpp:116
uint32_t bitmask_type
Bitmask type stored as 32-bit unsigned integer.
Definition: types.hpp:86
output_nullability
Indicates the null output policy of a function.
Definition: types.hpp:258
null_aware
A function is null-aware if its output value uses the input validity.
Definition: types.hpp:232
udf_source_type
Indicates the source language of a user defined function (UDF) to be used in JIT APIs.
Definition: types.hpp:276
APIs for getting and setting the current device memory resource.
cuDF interfaces
Definition: host_udf.hpp:26
A generic expression that can be evaluated to return a value.
Definition: expressions.hpp:66
Specification for the outputs of the transform function. This includes the output type and nullabilit...
Definition: transform.hpp:81
Type declarations for libcudf.