sorting.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2024, 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 
19 #include <cudf/aggregation.hpp>
20 #include <cudf/types.hpp>
22 #include <cudf/utilities/export.hpp>
23 
25 #include <rmm/resource_ref.hpp>
26 
27 #include <memory>
28 #include <vector>
29 
30 namespace CUDF_EXPORT cudf {
31 
54 std::unique_ptr<column> sorted_order(
55  table_view const& input,
56  std::vector<order> const& column_order = {},
57  std::vector<null_order> const& null_precedence = {},
60 
69 std::unique_ptr<column> stable_sorted_order(
70  table_view const& input,
71  std::vector<order> const& column_order = {},
72  std::vector<null_order> const& null_precedence = {},
75 
94  std::vector<order> const& column_order,
95  std::vector<null_order> const& null_precedence,
97 
113 std::unique_ptr<table> sort(
114  table_view const& input,
115  std::vector<order> const& column_order = {},
116  std::vector<null_order> const& null_precedence = {},
119 
125 std::unique_ptr<table> stable_sort(
126  table_view const& input,
127  std::vector<order> const& column_order = {},
128  std::vector<null_order> const& null_precedence = {},
131 
154 std::unique_ptr<table> sort_by_key(
155  table_view const& values,
156  table_view const& keys,
157  std::vector<order> const& column_order = {},
158  std::vector<null_order> const& null_precedence = {},
161 
167 std::unique_ptr<table> stable_sort_by_key(
168  table_view const& values,
169  table_view const& keys,
170  std::vector<order> const& column_order = {},
171  std::vector<null_order> const& null_precedence = {},
174 
205 std::unique_ptr<column> rank(
206  column_view const& input,
207  rank_method method,
208  order column_order,
209  null_policy null_handling,
210  null_order null_precedence,
211  bool percentage,
214 
258 std::unique_ptr<column> segmented_sorted_order(
259  table_view const& keys,
260  column_view const& segment_offsets,
261  std::vector<order> const& column_order = {},
262  std::vector<null_order> const& null_precedence = {},
265 
271 std::unique_ptr<column> stable_segmented_sorted_order(
272  table_view const& keys,
273  column_view const& segment_offsets,
274  std::vector<order> const& column_order = {},
275  std::vector<null_order> const& null_precedence = {},
278 
326 std::unique_ptr<table> segmented_sort_by_key(
327  table_view const& values,
328  table_view const& keys,
329  column_view const& segment_offsets,
330  std::vector<order> const& column_order = {},
331  std::vector<null_order> const& null_precedence = {},
334 
340 std::unique_ptr<table> stable_segmented_sort_by_key(
341  table_view const& values,
342  table_view const& keys,
343  column_view const& segment_offsets,
344  std::vector<order> const& column_order = {},
345  std::vector<null_order> const& null_precedence = {},
348  // end of group
350 } // namespace CUDF_EXPORT cudf
Representation for specifying desired aggregations from aggregation-based APIs, e....
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:200
A set of cudf::column's of the same size.
Definition: table.hpp:41
std::unique_ptr< column > sorted_order(table_view const &input, std::vector< order > const &column_order={}, std::vector< null_order > const &null_precedence={}, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Computes the row indices that would produce input in a lexicographical sorted order.
std::unique_ptr< column > rank(column_view const &input, rank_method method, order column_order, null_policy null_handling, null_order null_precedence, bool percentage, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Computes the ranks of input column in sorted order.
std::unique_ptr< table > sort(table_view const &input, std::vector< order > const &column_order={}, std::vector< null_order > const &null_precedence={}, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Performs a lexicographic sort of the rows of a table.
std::unique_ptr< column > segmented_sorted_order(table_view const &keys, column_view const &segment_offsets, std::vector< order > const &column_order={}, std::vector< null_order > const &null_precedence={}, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Returns sorted order after sorting each segment in the table.
bool is_sorted(cudf::table_view const &table, std::vector< order > const &column_order, std::vector< null_order > const &null_precedence, rmm::cuda_stream_view stream=cudf::get_default_stream())
Checks whether the rows of a table are sorted in a lexicographical order.
std::unique_ptr< table > sort_by_key(table_view const &values, table_view const &keys, std::vector< order > const &column_order={}, std::vector< null_order > const &null_precedence={}, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Performs a key-value sort.
std::unique_ptr< table > stable_sort_by_key(table_view const &values, table_view const &keys, std::vector< order > const &column_order={}, std::vector< null_order > const &null_precedence={}, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Performs a key-value stable sort.
std::unique_ptr< column > stable_sorted_order(table_view const &input, std::vector< order > const &column_order={}, std::vector< null_order > const &null_precedence={}, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Computes the row indices that would produce input in a stable lexicographical sorted order.
std::unique_ptr< table > stable_sort(table_view const &input, std::vector< order > const &column_order={}, std::vector< null_order > const &null_precedence={}, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Performs a stable lexicographic sort of the rows of a table.
rank_method
Tie-breaker method to use for ranking the column.
Definition: aggregation.hpp:54
std::unique_ptr< table > segmented_sort_by_key(table_view const &values, table_view const &keys, column_view const &segment_offsets, std::vector< order > const &column_order={}, std::vector< null_order > const &null_precedence={}, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Performs a lexicographic segmented sort of a table.
std::unique_ptr< column > stable_segmented_sorted_order(table_view const &keys, column_view const &segment_offsets, std::vector< order > const &column_order={}, std::vector< null_order > const &null_precedence={}, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Returns sorted order after stably sorting each segment in the table.
std::unique_ptr< table > stable_segmented_sort_by_key(table_view const &values, table_view const &keys, column_view const &segment_offsets, std::vector< order > const &column_order={}, std::vector< null_order > const &null_precedence={}, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Performs a stably lexicographic segmented sort of a table.
rmm::cuda_stream_view const get_default_stream()
Get the current default stream.
cuda::mr::async_resource_ref< cuda::mr::device_accessible > device_async_resource_ref
device_memory_resource * get_current_device_resource()
null_order
Indicates how null values compare against all other values.
Definition: types.hpp:159
null_policy
Enum to specify whether to include nulls or exclude nulls.
Definition: types.hpp:126
order
Indicates the order in which elements should be sorted.
Definition: types.hpp:118
cuDF interfaces
Definition: aggregation.hpp:35
Type declarations for libcudf.