stream_compaction.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>
12 #include <cudf/utilities/export.hpp>
14 
15 #include <memory>
16 #include <optional>
17 #include <variant>
18 #include <vector>
19 
25 namespace CUDF_EXPORT cudf {
31 namespace ast {
32 struct expression;
33 }
34 
73 std::unique_ptr<table> drop_nulls(
74  table_view const& input,
75  std::vector<size_type> const& keys,
76  cudf::size_type keep_threshold,
79 
107 std::unique_ptr<table> drop_nulls(
108  table_view const& input,
109  std::vector<size_type> const& keys,
112 
151 std::unique_ptr<table> drop_nans(
152  table_view const& input,
153  std::vector<size_type> const& keys,
154  cudf::size_type keep_threshold,
157 
186 std::unique_ptr<table> drop_nans(
187  table_view const& input,
188  std::vector<size_type> const& keys,
191 
214 std::unique_ptr<table> apply_boolean_mask(
215  table_view const& input,
216  column_view const& boolean_mask,
219 
242 std::unique_ptr<table> apply_deletion_mask(
243  table_view const& input,
244  column_view const& deletion_mask,
247 
252  KEEP_ANY = 0,
253  KEEP_FIRST,
254  KEEP_LAST,
255  KEEP_NONE
256 };
257 
289 std::unique_ptr<table> unique(
290  table_view const& input,
291  std::vector<size_type> const& keys,
293  null_equality nulls_equal = null_equality::EQUAL,
296 
321 std::unique_ptr<table> distinct(
322  table_view const& input,
323  std::vector<size_type> const& keys,
324  duplicate_keep_option keep = duplicate_keep_option::KEEP_ANY,
325  null_equality nulls_equal = null_equality::EQUAL,
326  nan_equality nans_equal = nan_equality::ALL_EQUAL,
329 
348 std::unique_ptr<column> distinct_indices(
349  table_view const& input,
350  duplicate_keep_option keep = duplicate_keep_option::KEEP_ANY,
351  null_equality nulls_equal = null_equality::EQUAL,
352  nan_equality nans_equal = nan_equality::ALL_EQUAL,
355 
383 std::unique_ptr<table> stable_distinct(
384  table_view const& input,
385  std::vector<size_type> const& keys,
386  duplicate_keep_option keep = duplicate_keep_option::KEEP_ANY,
387  null_equality nulls_equal = null_equality::EQUAL,
388  nan_equality nans_equal = nan_equality::ALL_EQUAL,
391 
426 [[deprecated("Use filter_extended instead")]] std::vector<std::unique_ptr<column>> filter(
427  std::vector<column_view> const& predicate_columns,
428  std::string const& predicate_udf,
429  std::vector<column_view> const& filter_columns,
430  bool is_ptx,
431  std::optional<void*> user_data = std::nullopt,
432  null_aware is_null_aware = null_aware::NO,
433  output_nullability predicate_nullability = output_nullability::PRESERVE,
436 
441 using filter_input = std::variant<column_view, scalar_column_view>;
442 
477 std::vector<std::unique_ptr<column>> filter_extended(
478  std::span<std::variant<column_view, scalar_column_view> const> predicate_inputs,
479  std::string const& predicate_udf,
480  std::vector<column_view> const& filter_columns,
481  cudf::udf_source_type source_type,
482  std::optional<void*> user_data = std::nullopt,
483  null_aware is_null_aware = null_aware::NO,
484  output_nullability predicate_nullability = output_nullability::PRESERVE,
487 
508 std::unique_ptr<table> filter(
509  table_view const& predicate_table,
510  ast::expression const& predicate_expr,
511  table_view const& filter_table,
514 
516 } // 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 set of cudf::column_view's of the same size.
Definition: table_view.hpp:206
column view class definitions
APIs for querying the default CUDA stream and per-thread default stream status.
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::unique_ptr< table > filter(table_view const &predicate_table, ast::expression const &predicate_expr, table_view const &filter_table, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Creates new table by applying a filter function against every element of the input columns.
std::unique_ptr< table > drop_nulls(table_view const &input, std::vector< size_type > const &keys, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Filters a table to remove null elements.
std::unique_ptr< table > apply_deletion_mask(table_view const &input, column_view const &deletion_mask, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Filters input using deletion_mask of boolean values as a mask.
std::unique_ptr< column > distinct_indices(table_view const &input, duplicate_keep_option keep=duplicate_keep_option::KEEP_ANY, null_equality nulls_equal=null_equality::EQUAL, nan_equality nans_equal=nan_equality::ALL_EQUAL, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Create a column of indices of all distinct rows in the input table.
std::unique_ptr< table > unique(table_view const &input, std::vector< size_type > const &keys, duplicate_keep_option keep, null_equality nulls_equal=null_equality::EQUAL, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Create a new table with consecutive duplicate rows removed.
std::unique_ptr< table > drop_nans(table_view const &input, std::vector< size_type > const &keys, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Filters a table to remove NANs.
duplicate_keep_option
Choices for drop_duplicates API for retainment of duplicate rows.
std::unique_ptr< table > apply_boolean_mask(table_view const &input, 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())
Filters input using boolean_mask of boolean values as a mask.
std::variant< column_view, scalar_column_view > filter_input
Typedef for inputs to the filter function. Each input can be either a column or a scalar column.
std::unique_ptr< table > stable_distinct(table_view const &input, std::vector< size_type > const &keys, duplicate_keep_option keep=duplicate_keep_option::KEEP_ANY, null_equality nulls_equal=null_equality::EQUAL, nan_equality nans_equal=nan_equality::ALL_EQUAL, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Create a new table without duplicate rows, preserving input order.
std::vector< std::unique_ptr< column > > filter_extended(std::span< std::variant< column_view, scalar_column_view > const > predicate_inputs, std::string const &predicate_udf, std::vector< column_view > const &filter_columns, cudf::udf_source_type source_type, std::optional< void * > user_data=std::nullopt, null_aware is_null_aware=null_aware::NO, output_nullability predicate_nullability=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 filter function against every element of the input columns.
std::unique_ptr< table > distinct(table_view const &input, std::vector< size_type > const &keys, duplicate_keep_option keep=duplicate_keep_option::KEEP_ANY, null_equality nulls_equal=null_equality::EQUAL, nan_equality nans_equal=nan_equality::ALL_EQUAL, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Create a new table without duplicate rows.
@ KEEP_ANY
Keep an unspecified occurrence.
@ KEEP_NONE
Keep no (remove all) occurrences of duplicates.
@ KEEP_LAST
Keep last occurrence.
@ KEEP_FIRST
Keep first occurrence.
null_equality
Enum to consider two nulls as equal or unequal.
Definition: types.hpp:132
int32_t size_type
Row index type for columns and tables.
Definition: types.hpp:76
output_nullability
Indicates the null output policy of a function.
Definition: types.hpp:249
null_aware
A function is null-aware if its output value uses the input validity.
Definition: types.hpp:223
udf_source_type
Indicates the source language of a user defined function (UDF) to be used in JIT APIs.
Definition: types.hpp:267
nan_equality
Enum to consider different elements (of floating point types) holding NaN value as equal or unequal.
Definition: types.hpp:124
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:69
Type declarations for libcudf.