rolling.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2025, 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>
21 #include <cudf/types.hpp>
22 #include <cudf/utilities/export.hpp>
24 
25 #include <memory>
26 
27 namespace CUDF_EXPORT cudf {
67 std::unique_ptr<column> rolling_window(
68  column_view const& input,
69  size_type preceding_window,
70  size_type following_window,
71  size_type min_periods,
72  rolling_aggregation const& agg,
75 
91 std::unique_ptr<column> rolling_window(
92  column_view const& input,
93  column_view const& default_outputs,
94  size_type preceding_window,
95  size_type following_window,
96  size_type min_periods,
97  rolling_aggregation const& agg,
100 
105  public:
112  static window_bounds get(size_type value) { return window_bounds(false, value); }
113 
120  {
121  return window_bounds(true, std::numeric_limits<cudf::size_type>::max());
122  }
123 
130  [[nodiscard]] bool is_unbounded() const { return _is_unbounded; }
131 
137  [[nodiscard]] size_type value() const { return _value; }
138 
139  private:
140  explicit window_bounds(bool is_unbounded_, size_type value_ = 0)
141  : _is_unbounded{is_unbounded_}, _value{value_}
142  {
143  }
144 
145  bool const _is_unbounded;
146  size_type const _value;
147 };
148 
241 std::unique_ptr<column> grouped_rolling_window(
242  table_view const& group_keys,
243  column_view const& input,
244  size_type preceding_window,
245  size_type following_window,
246  size_type min_periods,
247  rolling_aggregation const& aggr,
250 
263 std::unique_ptr<column> grouped_rolling_window(
264  table_view const& group_keys,
265  column_view const& input,
266  window_bounds preceding_window,
267  window_bounds following_window,
268  size_type min_periods,
269  rolling_aggregation const& aggr,
272 
289 std::unique_ptr<column> grouped_rolling_window(
290  table_view const& group_keys,
291  column_view const& input,
292  column_view const& default_outputs,
293  size_type preceding_window,
294  size_type following_window,
295  size_type min_periods,
296  rolling_aggregation const& aggr,
299 
313 std::unique_ptr<column> grouped_rolling_window(
314  table_view const& group_keys,
315  column_view const& input,
316  column_view const& default_outputs,
317  window_bounds preceding_window,
318  window_bounds following_window,
319  size_type min_periods,
320  rolling_aggregation const& aggr,
323 
411 [[deprecated("Use cudf::grouped_range_rolling_window instead")]] std::unique_ptr<column>
413  table_view const& group_keys,
414  column_view const& timestamp_column,
415  cudf::order const& timestamp_order,
416  column_view const& input,
417  size_type preceding_window_in_days,
418  size_type following_window_in_days,
419  size_type min_periods,
420  rolling_aggregation const& aggr,
423 
445 [[deprecated("Use cudf::grouped_range_rolling_window instead")]] std::unique_ptr<column>
447  table_view const& group_keys,
448  column_view const& timestamp_column,
449  cudf::order const& timestamp_order,
450  column_view const& input,
451  window_bounds preceding_window_in_days,
452  window_bounds following_window_in_days,
453  size_type min_periods,
454  rolling_aggregation const& aggr,
457 
568 std::unique_ptr<column> grouped_range_rolling_window(
569  table_view const& group_keys,
570  column_view const& orderby_column,
571  cudf::order const& order,
572  column_view const& input,
573  range_window_bounds const& preceding,
574  range_window_bounds const& following,
575  size_type min_periods,
576  rolling_aggregation const& aggr,
579 
621 std::unique_ptr<column> rolling_window(
622  column_view const& input,
623  column_view const& preceding_window,
624  column_view const& following_window,
625  size_type min_periods,
626  rolling_aggregation const& agg,
629  // end of group
631 } // 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...
Derived class intended for rolling_window specific aggregation usage.
A set of cudf::column_view's of the same size.
Definition: table_view.hpp:200
std::unique_ptr< column > grouped_rolling_window(table_view const &group_keys, column_view const &input, column_view const &default_outputs, window_bounds preceding_window, window_bounds following_window, size_type min_periods, rolling_aggregation const &aggr, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Applies a grouping-aware, fixed-size rolling window function to the values in a column.
std::unique_ptr< column > grouped_time_range_rolling_window(table_view const &group_keys, column_view const ×tamp_column, cudf::order const ×tamp_order, column_view const &input, window_bounds preceding_window_in_days, window_bounds following_window_in_days, size_type min_periods, rolling_aggregation const &aggr, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Applies a grouping-aware, timestamp-based rolling window function to the values in a column,...
std::unique_ptr< column > rolling_window(column_view const &input, column_view const &preceding_window, column_view const &following_window, size_type min_periods, rolling_aggregation const &agg, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Applies a variable-size rolling window function to the values in a column.
std::unique_ptr< column > grouped_range_rolling_window(table_view const &group_keys, column_view const &orderby_column, cudf::order const &order, column_view const &input, range_window_bounds const &preceding, range_window_bounds const &following, size_type min_periods, rolling_aggregation const &aggr, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Applies a grouping-aware, value range-based rolling window function to the values in a column.
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::async_resource_ref< cuda::mr::device_accessible > device_async_resource_ref
int32_t size_type
Row index type for columns and tables.
Definition: types.hpp:95
order
Indicates the order in which elements should be sorted.
Definition: types.hpp:118
cuDF interfaces
Definition: host_udf.hpp:37
Abstraction for window boundary sizes, to be used with grouped_range_rolling_window().
Abstraction for window boundary sizes.
Definition: rolling.hpp:104
static window_bounds unbounded()
Construct unbounded window boundary.
Definition: rolling.hpp:119
size_type value() const
Gets the row-boundary for this window_bounds.
Definition: rolling.hpp:137
bool is_unbounded() const
Definition: rolling.hpp:130
static window_bounds get(size_type value)
Construct bounded window boundary.
Definition: rolling.hpp:112
Type declarations for libcudf.