libcudf  23.12.00
copying.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2023, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
21 #include <cudf/scalar/scalar.hpp>
24 #include <cudf/table/table.hpp>
25 #include <cudf/types.hpp>
26 
28 
29 #include <memory>
30 #include <vector>
31 
32 namespace cudf {
33 
48 enum class out_of_bounds_policy : bool {
49  NULLIFY,
50  DONT_CHECK
51 };
52 
84 std::unique_ptr<table> gather(
85  table_view const& source_table,
86  column_view const& gather_map,
90 
106 std::unique_ptr<table> reverse(
107  table_view const& source_table,
110 
126 std::unique_ptr<column> reverse(
127  column_view const& source_column,
130 
166 std::unique_ptr<table> scatter(
167  table_view const& source,
168  column_view const& scatter_map,
169  table_view const& target,
172 
204 std::unique_ptr<table> scatter(
205  std::vector<std::reference_wrapper<scalar const>> const& source,
206  column_view const& indices,
207  table_view const& target,
210 
215  NEVER,
216  RETAIN,
217  ALWAYS
218 };
219 
226 std::unique_ptr<column> empty_like(column_view const& input);
227 
234 std::unique_ptr<column> empty_like(scalar const& input);
235 
251 std::unique_ptr<column> allocate_like(
252  column_view const& input,
256 
273 std::unique_ptr<column> allocate_like(
274  column_view const& input,
275  size_type size,
279 
290 std::unique_ptr<table> empty_like(table_view const& input_table);
291 
324 void copy_range_in_place(column_view const& source,
325  mutable_column_view& target,
326  size_type source_begin,
327  size_type source_end,
328  size_type target_begin,
330 
361 std::unique_ptr<column> copy_range(
362  column_view const& source,
363  column_view const& target,
364  size_type source_begin,
365  size_type source_end,
366  size_type target_begin,
369 
407 std::unique_ptr<column> shift(
408  column_view const& input,
409  size_type offset,
410  scalar const& fill_value,
413 
445 std::vector<column_view> slice(column_view const& input,
452 std::vector<column_view> slice(column_view const& input,
453  std::initializer_list<size_type> indices,
455 
489 std::vector<table_view> slice(table_view const& input,
496 std::vector<table_view> slice(table_view const& input,
497  std::initializer_list<size_type> indices,
499 
533 std::vector<column_view> split(column_view const& input,
540 std::vector<column_view> split(column_view const& input,
541  std::initializer_list<size_type> splits,
543 
579 std::vector<table_view> split(table_view const& input,
586 std::vector<table_view> split(table_view const& input,
587  std::initializer_list<size_type> splits,
589 
610 std::unique_ptr<column> copy_if_else(
611  column_view const& lhs,
612  column_view const& rhs,
613  column_view const& boolean_mask,
616 
636 std::unique_ptr<column> copy_if_else(
637  scalar const& lhs,
638  column_view const& rhs,
639  column_view const& boolean_mask,
642 
662 std::unique_ptr<column> copy_if_else(
663  column_view const& lhs,
664  scalar const& rhs,
665  column_view const& boolean_mask,
668 
686 std::unique_ptr<column> copy_if_else(
687  scalar const& lhs,
688  scalar const& rhs,
689  column_view const& boolean_mask,
692 
730 std::unique_ptr<table> boolean_mask_scatter(
731  table_view const& input,
732  table_view const& target,
733  column_view const& boolean_mask,
736 
769 std::unique_ptr<table> boolean_mask_scatter(
770  std::vector<std::reference_wrapper<scalar const>> const& input,
771  table_view const& target,
772  column_view const& boolean_mask,
775 
790 std::unique_ptr<scalar> get_element(
791  column_view const& input,
792  size_type index,
795 
799 enum class sample_with_replacement : bool {
800  FALSE,
801  TRUE
802 };
803 
832 std::unique_ptr<table> sample(
833  table_view const& input,
834  size_type const n,
836  int64_t const seed = 0,
839 
857 bool has_nonempty_nulls(column_view const& input,
859 
883 
952 std::unique_ptr<column> purge_nonempty_nulls(
953  column_view const& input,
956 
958 } // namespace 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:48
A set of cudf::column_view's of the same size.
Definition: table_view.hpp:187
column view class definitions
std::unique_ptr< column > empty_like(column_view const &input)
Initializes and returns an empty column of the same type as the input.
mask_allocation_policy
Indicates when to allocate a mask, based on an existing mask.
Definition: copying.hpp:214
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::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Gather n samples from given input randomly.
std::unique_ptr< scalar > get_element(column_view const &input, size_type index, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Get the element at specified index from a column.
std::unique_ptr< column > copy_if_else(column_view const &lhs, column_view const &rhs, column_view const &boolean_mask, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
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, mask_allocation_policy mask_alloc=mask_allocation_policy::RETAIN, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Creates an uninitialized new column of the same size and 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.
std::unique_ptr< column > purge_nonempty_nulls(column_view const &input, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
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::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Copies a range of elements out-of-place from one column to another.
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< table > reverse(table_view const &source_table, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Reverses the rows within a table.
out_of_bounds_policy
Policy to account for possible out-of-bounds indices.
Definition: copying.hpp:48
sample_with_replacement
Indicates whether a row can be sampled more than once.
Definition: copying.hpp:799
@ NEVER
Do not allocate a null mask, regardless of input.
@ RETAIN
Allocate a null mask if the input contains one.
@ ALWAYS
Allocate a null mask, regardless of input.
@ 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=out_of_bounds_policy::DONT_CHECK, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Gathers the specified rows (including null values) of a set of columns.
std::unique_ptr< table > scatter(table_view const &source, column_view const &scatter_map, table_view const &target, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Scatters the rows of the source table into a copy of the target table according to a scatter map.
std::unique_ptr< table > boolean_mask_scatter(table_view const &input, table_view const &target, column_view const &boolean_mask, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Scatters rows from the input table to rows of the output corresponding to true values in a boolean ma...
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::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Creates a new column by shifting all values by an offset.
std::vector< column_view > slice(column_view const &input, host_span< size_type const > indices, rmm::cuda_stream_view stream=cudf::get_default_stream())
Slices a column_view into a set of column_views according to a set of indices.
std::vector< column_view > split(column_view const &input, host_span< size_type const > splits, rmm::cuda_stream_view stream=cudf::get_default_stream())
Splits a column_view into a set of column_views according to a set of indices derived from expected s...
device_memory_resource * get_current_device_resource()
int32_t size_type
Row index type for columns and tables.
Definition: types.hpp:80
Class definition for cudf::lists_column_view.
cuDF interfaces
Definition: aggregation.hpp:34
rmm::cuda_stream_view const get_default_stream()
Get the current default stream.
Class definitions for cudf::scalar.
Class definition for cudf::strings_column_view.
C++20 std::span with reduced feature set.
Definition: span.hpp:210
Class definition for cudf::structs_column_view.
Class definition for cudf::table.
Type declarations for libcudf.