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,
77  cuda::stream_ref stream = cudf::get_default_stream(),
79 
107 std::unique_ptr<table> drop_nulls(
108  table_view const& input,
109  std::vector<size_type> const& keys,
110  cuda::stream_ref stream = cudf::get_default_stream(),
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,
155  cuda::stream_ref stream = cudf::get_default_stream(),
157 
186 std::unique_ptr<table> drop_nans(
187  table_view const& input,
188  std::vector<size_type> const& keys,
189  cuda::stream_ref stream = cudf::get_default_stream(),
191 
214 std::unique_ptr<table> apply_retention_mask(
215  table_view const& input,
216  column_view const& retention_mask,
217  cuda::stream_ref stream = cudf::get_default_stream(),
219 
233 [[deprecated("Use apply_retention_mask() instead")]] std::unique_ptr<table> apply_boolean_mask(
234  table_view const& input,
235  column_view const& boolean_mask,
236  cuda::stream_ref stream = cudf::get_default_stream(),
238 
262 std::unique_ptr<table> apply_deletion_mask(
263  table_view const& input,
264  column_view const& deletion_mask,
265  cuda::stream_ref stream = cudf::get_default_stream(),
267 
272  KEEP_ANY = 0,
273  KEEP_FIRST,
274  KEEP_LAST,
275  KEEP_NONE
276 };
277 
309 std::unique_ptr<table> unique(
310  table_view const& input,
311  std::vector<size_type> const& keys,
313  null_equality nulls_equal = null_equality::EQUAL,
314  cuda::stream_ref stream = cudf::get_default_stream(),
316 
341 std::unique_ptr<table> distinct(
342  table_view const& input,
343  std::vector<size_type> const& keys,
344  duplicate_keep_option keep = duplicate_keep_option::KEEP_ANY,
345  null_equality nulls_equal = null_equality::EQUAL,
346  nan_equality nans_equal = nan_equality::ALL_EQUAL,
347  cuda::stream_ref stream = cudf::get_default_stream(),
349 
368 std::unique_ptr<column> distinct_indices(
369  table_view const& input,
370  duplicate_keep_option keep = duplicate_keep_option::KEEP_ANY,
371  null_equality nulls_equal = null_equality::EQUAL,
372  nan_equality nans_equal = nan_equality::ALL_EQUAL,
373  cuda::stream_ref stream = cudf::get_default_stream(),
375 
403 std::unique_ptr<table> stable_distinct(
404  table_view const& input,
405  std::vector<size_type> const& keys,
406  duplicate_keep_option keep = duplicate_keep_option::KEEP_ANY,
407  null_equality nulls_equal = null_equality::EQUAL,
408  nan_equality nans_equal = nan_equality::ALL_EQUAL,
409  cuda::stream_ref stream = cudf::get_default_stream(),
411 
446 [[deprecated("Use filter_extended instead")]] std::vector<std::unique_ptr<column>> filter(
447  std::vector<column_view> const& predicate_columns,
448  std::string const& predicate_udf,
449  std::vector<column_view> const& filter_columns,
450  bool is_ptx,
451  std::optional<void*> user_data = std::nullopt,
452  null_aware is_null_aware = null_aware::NO,
453  output_nullability predicate_nullability = output_nullability::PRESERVE,
454  cuda::stream_ref stream = cudf::get_default_stream(),
456 
461 using filter_input = std::variant<column_view, scalar_column_view>;
462 
497 std::vector<std::unique_ptr<column>> filter_extended(
498  std::span<std::variant<column_view, scalar_column_view> const> predicate_inputs,
499  std::string const& predicate_udf,
500  std::vector<column_view> const& filter_columns,
501  cudf::udf_source_type source_type,
502  std::optional<void*> user_data = std::nullopt,
503  null_aware is_null_aware = null_aware::NO,
504  output_nullability predicate_nullability = output_nullability::PRESERVE,
505  cuda::stream_ref stream = cudf::get_default_stream(),
507 
528 std::unique_ptr<table> filter(
529  table_view const& predicate_table,
530  ast::expression const& predicate_expr,
531  table_view const& filter_table,
532  cuda::stream_ref stream = cudf::get_default_stream(),
534 
536 } // 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.
cuda::stream_ref 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 > apply_boolean_mask(table_view const &input, column_view const &boolean_mask, cuda::stream_ref 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::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, cuda::stream_ref 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::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, cuda::stream_ref stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Create a new table without duplicate rows.
std::unique_ptr< table > apply_deletion_mask(table_view const &input, column_view const &deletion_mask, cuda::stream_ref 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::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, cuda::stream_ref 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.
duplicate_keep_option
Choices for drop_duplicates API for retainment of duplicate rows.
std::unique_ptr< table > drop_nulls(table_view const &input, std::vector< size_type > const &keys, cuda::stream_ref 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::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< 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, cuda::stream_ref 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, cuda::stream_ref 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, cuda::stream_ref stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Filters a table to remove NANs.
std::unique_ptr< table > filter(table_view const &predicate_table, ast::expression const &predicate_expr, table_view const &filter_table, cuda::stream_ref 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 > apply_retention_mask(table_view const &input, column_view const &retention_mask, cuda::stream_ref stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Filters input using retention_mask of boolean values as a mask.
@ 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:250
null_aware
A function is null-aware if its output value uses the input validity.
Definition: types.hpp:224
udf_source_type
Indicates the source language of a user defined function (UDF) to be used in JIT APIs.
Definition: types.hpp:268
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:27
A generic expression that can be evaluated to return a value.
Definition: expressions.hpp:72
Type declarations for libcudf.