copying.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2018-2026, NVIDIA CORPORATION.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 
6 #pragma once
7 
10 #include <cudf/scalar/scalar.hpp>
13 #include <cudf/table/table.hpp>
14 #include <cudf/types.hpp>
15 #include <cudf/utilities/export.hpp>
17 
18 #include <memory>
19 #include <vector>
20 
21 namespace CUDF_EXPORT cudf {
22 
33 enum class out_of_bounds_policy : bool {
34  NULLIFY,
35  DONT_CHECK
36 };
37 
41 enum class negative_index_policy : bool {
42  ALLOWED,
44 };
45 
77 std::unique_ptr<table> gather(
78  table_view const& source_table,
79  column_view const& gather_map,
80  out_of_bounds_policy bounds_policy = out_of_bounds_policy::DONT_CHECK,
83 
114 std::unique_ptr<table> gather(
115  table_view const& source_table,
116  column_view const& gather_map,
117  out_of_bounds_policy bounds_policy,
118  negative_index_policy neg_indices,
121 
137 std::unique_ptr<table> reverse(
138  table_view const& source_table,
141 
157 std::unique_ptr<column> reverse(
158  column_view const& source_column,
161 
204 std::unique_ptr<table> scatter(
205  table_view const& source,
206  column_view const& scatter_map,
207  table_view const& target,
210 
247 std::unique_ptr<table> scatter(
248  std::vector<std::reference_wrapper<scalar const>> const& source,
249  column_view const& indices,
250  table_view const& target,
253 
257 enum class mask_allocation_policy : int32_t {
258  NEVER,
259  RETAIN,
260  ALWAYS
261 };
262 
269 std::unique_ptr<column> empty_like(column_view const& input);
270 
277 std::unique_ptr<column> empty_like(scalar const& input);
278 
296 std::unique_ptr<column> allocate_like(
297  column_view const& input,
298  mask_allocation_policy mask_alloc = mask_allocation_policy::RETAIN,
301 
318 std::unique_ptr<column> allocate_like(
319  column_view const& input,
320  size_type size,
321  mask_allocation_policy mask_alloc = mask_allocation_policy::RETAIN,
324 
335 std::unique_ptr<table> empty_like(table_view const& input_table);
336 
369 void copy_range_in_place(column_view const& source,
370  mutable_column_view& target,
371  size_type source_begin,
372  size_type source_end,
373  size_type target_begin,
375 
408 std::unique_ptr<column> copy_range(
409  column_view const& source,
410  column_view const& target,
411  size_type source_begin,
412  size_type source_end,
413  size_type target_begin,
416 
454 std::unique_ptr<column> shift(
455  column_view const& input,
456  size_type offset,
457  scalar const& fill_value,
460 
492 std::vector<column_view> slice(column_view const& input,
499 std::vector<column_view> slice(column_view const& input,
500  std::initializer_list<size_type> indices,
502 
536 std::vector<table_view> slice(table_view const& input,
543 std::vector<table_view> slice(table_view const& input,
544  std::initializer_list<size_type> indices,
546 
580 std::vector<column_view> split(column_view const& input,
587 std::vector<column_view> split(column_view const& input,
588  std::initializer_list<size_type> splits,
590 
626 std::vector<table_view> split(table_view const& input,
633 std::vector<table_view> split(table_view const& input,
634  std::initializer_list<size_type> splits,
636 
657 std::unique_ptr<column> copy_if_else(
658  column_view const& lhs,
659  column_view const& rhs,
660  column_view const& boolean_mask,
663 
683 std::unique_ptr<column> copy_if_else(
684  scalar const& lhs,
685  column_view const& rhs,
686  column_view const& boolean_mask,
689 
709 std::unique_ptr<column> copy_if_else(
710  column_view const& lhs,
711  scalar const& rhs,
712  column_view const& boolean_mask,
715 
733 std::unique_ptr<column> copy_if_else(
734  scalar const& lhs,
735  scalar const& rhs,
736  column_view const& boolean_mask,
739 
777 std::unique_ptr<table> boolean_mask_scatter(
778  table_view const& input,
779  table_view const& target,
780  column_view const& boolean_mask,
783 
816 std::unique_ptr<table> boolean_mask_scatter(
817  std::vector<std::reference_wrapper<scalar const>> const& input,
818  table_view const& target,
819  column_view const& boolean_mask,
822 
837 std::unique_ptr<scalar> get_element(
838  column_view const& input,
839  size_type index,
842 
846 enum class sample_with_replacement : bool {
847  FALSE,
848  TRUE
849 };
850 
879 std::unique_ptr<table> sample(
880  table_view const& input,
881  size_type const n,
882  sample_with_replacement replacement = sample_with_replacement::FALSE,
883  int64_t const seed = 0,
886 
904 bool has_nonempty_nulls(column_view const& input,
906 
930 
999 std::unique_ptr<column> purge_nonempty_nulls(
1000  column_view const& input,
1003 
1005 } // 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...
A non-owning, mutable view of device data as a column of elements, some of which may be null as indic...
An owning class to represent a singular value.
Definition: scalar.hpp:40
A set of cudf::column_view's of the same size.
Definition: table_view.hpp:189
column view class definitions
mask_allocation_policy
Indicates when to allocate a mask, based on an existing mask.
Definition: copying.hpp:257
std::unique_ptr< column > reverse(column_view const &source_column, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Reverses the elements of a column.
std::unique_ptr< column > copy_if_else(scalar const &lhs, scalar const &rhs, column_view const &boolean_mask, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Returns a new column, where each element is selected from either lhs or rhs based on the value of the...
std::unique_ptr< column > allocate_like(column_view const &input, size_type size, mask_allocation_policy mask_alloc=mask_allocation_policy::RETAIN, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Creates an uninitialized new column of the specified size and same type as the input.
bool may_have_nonempty_nulls(column_view const &input)
Approximates if a column or its descendants may have non-empty null elements.
void copy_range_in_place(column_view const &source, mutable_column_view &target, size_type source_begin, size_type source_end, size_type target_begin, rmm::cuda_stream_view stream=cudf::get_default_stream())
Copies a range of elements in-place from one column to another.
negative_index_policy
Policy to recognize negative indices as relative to the end of the source.
Definition: copying.hpp:41
std::unique_ptr< table > sample(table_view const &input, size_type const n, sample_with_replacement replacement=sample_with_replacement::FALSE, int64_t const seed=0, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Gather n samples from given input randomly.
bool has_nonempty_nulls(column_view const &input, rmm::cuda_stream_view stream=cudf::get_default_stream())
Checks if a column or its descendants have non-empty null rows.
std::unique_ptr< column > purge_nonempty_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())
Copy input into output while purging any non-empty null rows in the column or its descendants.
std::unique_ptr< column > copy_range(column_view const &source, column_view const &target, size_type source_begin, size_type source_end, size_type target_begin, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Copies a range of elements out-of-place from one column to another.
out_of_bounds_policy
Policy to account for possible out-of-bounds indices.
Definition: copying.hpp:33
sample_with_replacement
Indicates whether a row can be sampled more than once.
Definition: copying.hpp:846
std::unique_ptr< scalar > get_element(column_view const &input, size_type index, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Get the element at specified index from a column.
std::unique_ptr< table > empty_like(table_view const &input_table)
Creates a table of empty columns with the same types as the input_table
@ RETAIN
Allocate a null mask if the input contains one.
@ NOT_ALLOWED
Negative indices are not allowed and result in undefined behavior.
@ ALLOWED
Negative indices are allowed and result in wrapping behavior.
@ DONT_CHECK
No bounds checking is performed, better performance.
@ NULLIFY
Output values corresponding to out-of-bounds indices are null.
@ FALSE
A row can be sampled only once.
@ TRUE
A row can be sampled more than once.
std::unique_ptr< table > gather(table_view const &source_table, column_view const &gather_map, out_of_bounds_policy bounds_policy, negative_index_policy neg_indices, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Gathers the specified rows of a set of columns according to a gather map.
std::unique_ptr< table > scatter(std::vector< std::reference_wrapper< scalar const >> const &source, column_view const &indices, table_view const &target, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Scatters a row of scalar values into a copy of the target table according to a scatter map.
std::unique_ptr< table > boolean_mask_scatter(std::vector< std::reference_wrapper< scalar const >> const &input, table_view const &target, column_view const &boolean_mask, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Scatters scalar values to rows of the output corresponding to true values in a boolean mask.
std::unique_ptr< column > shift(column_view const &input, size_type offset, scalar const &fill_value, 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 shifting all values by an offset.
std::vector< table_view > slice(table_view const &input, std::initializer_list< size_type > indices, rmm::cuda_stream_view stream=cudf::get_default_stream())
Slices a table_view into a set of table_views according to a set of indices.
std::vector< table_view > split(table_view const &input, std::initializer_list< size_type > splits, rmm::cuda_stream_view stream=cudf::get_default_stream())
Splits a table_view into a set of table_views according to a set of indices derived from expected spl...
rmm::cuda_stream_view const get_default_stream()
Get the current default stream.
@ ALWAYS
Use dictionary regardless of impact on compression.
Definition: io/types.hpp:217
@ NEVER
Never use dictionary encoding.
Definition: io/types.hpp:215
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
int32_t size_type
Row index type for columns and tables.
Definition: types.hpp:84
Class definition for cudf::lists_column_view.
cuDF interfaces
Definition: host_udf.hpp:26
Class definitions for cudf::scalar.
Class definition for cudf::strings_column_view.
C++20 std::span with reduced feature set.
Definition: span.hpp:184
Class definition for cudf::structs_column_view.
Class definition for cudf::table.
Type declarations for libcudf.