rolling.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 
20 #include <cudf/types.hpp>
21 #include <cudf/utilities/export.hpp>
22 
24 #include <rmm/resource_ref.hpp>
25 
26 #include <memory>
27 
28 namespace CUDF_EXPORT cudf {
66 std::unique_ptr<column> rolling_window(
67  column_view const& input,
68  size_type preceding_window,
69  size_type following_window,
70  size_type min_periods,
71  rolling_aggregation const& agg,
74 
90 std::unique_ptr<column> rolling_window(
91  column_view const& input,
92  column_view const& default_outputs,
93  size_type preceding_window,
94  size_type following_window,
95  size_type min_periods,
96  rolling_aggregation const& agg,
99 
104  public:
111  static window_bounds get(size_type value) { return window_bounds(false, value); }
112 
119  {
120  return window_bounds(true, std::numeric_limits<cudf::size_type>::max());
121  }
122 
129  [[nodiscard]] bool is_unbounded() const { return _is_unbounded; }
130 
136  [[nodiscard]] size_type value() const { return _value; }
137 
138  private:
139  explicit window_bounds(bool is_unbounded_, size_type value_ = 0)
140  : _is_unbounded{is_unbounded_}, _value{value_}
141  {
142  }
143 
144  bool const _is_unbounded;
145  size_type const _value;
146 };
147 
240 std::unique_ptr<column> grouped_rolling_window(
241  table_view const& group_keys,
242  column_view const& input,
243  size_type preceding_window,
244  size_type following_window,
245  size_type min_periods,
246  rolling_aggregation const& aggr,
249 
262 std::unique_ptr<column> grouped_rolling_window(
263  table_view const& group_keys,
264  column_view const& input,
265  window_bounds preceding_window,
266  window_bounds following_window,
267  size_type min_periods,
268  rolling_aggregation const& aggr,
271 
288 std::unique_ptr<column> grouped_rolling_window(
289  table_view const& group_keys,
290  column_view const& input,
291  column_view const& default_outputs,
292  size_type preceding_window,
293  size_type following_window,
294  size_type min_periods,
295  rolling_aggregation const& aggr,
298 
312 std::unique_ptr<column> grouped_rolling_window(
313  table_view const& group_keys,
314  column_view const& input,
315  column_view const& default_outputs,
316  window_bounds preceding_window,
317  window_bounds following_window,
318  size_type min_periods,
319  rolling_aggregation const& aggr,
322 
408 std::unique_ptr<column> grouped_time_range_rolling_window(
409  table_view const& group_keys,
410  column_view const& timestamp_column,
411  cudf::order const& timestamp_order,
412  column_view const& input,
413  size_type preceding_window_in_days,
414  size_type following_window_in_days,
415  size_type min_periods,
416  rolling_aggregation const& aggr,
419 
439 std::unique_ptr<column> grouped_time_range_rolling_window(
440  table_view const& group_keys,
441  column_view const& timestamp_column,
442  cudf::order const& timestamp_order,
443  column_view const& input,
444  window_bounds preceding_window_in_days,
445  window_bounds following_window_in_days,
446  size_type min_periods,
447  rolling_aggregation const& aggr,
450 
561 std::unique_ptr<column> grouped_range_rolling_window(
562  table_view const& group_keys,
563  column_view const& orderby_column,
564  cudf::order const& order,
565  column_view const& input,
566  range_window_bounds const& preceding,
567  range_window_bounds const& following,
568  size_type min_periods,
569  rolling_aggregation const& aggr,
572 
609 std::unique_ptr<column> rolling_window(
610  column_view const& input,
611  column_view const& preceding_window,
612  column_view const& following_window,
613  size_type min_periods,
614  rolling_aggregation const& agg,
617  // end of group
619 } // 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...
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=rmm::mr::get_current_device_resource())
Applies a grouping-aware, fixed-size 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=rmm::mr::get_current_device_resource())
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=rmm::mr::get_current_device_resource())
Applies a grouping-aware, value range-based 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 &timestamp_column, cudf::order const &timestamp_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=rmm::mr::get_current_device_resource())
Applies a grouping-aware, timestamp-based rolling window function to the values in a column,...
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()
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: aggregation.hpp:35
Abstraction for window boundary sizes, to be used with grouped_range_rolling_window().
Abstraction for window boundary sizes.
Definition: rolling.hpp:103
static window_bounds unbounded()
Construct unbounded window boundary.
Definition: rolling.hpp:118
size_type value() const
Gets the row-boundary for this window_bounds.
Definition: rolling.hpp:136
bool is_unbounded() const
Definition: rolling.hpp:129
static window_bounds get(size_type value)
Construct bounded window boundary.
Definition: rolling.hpp:111
Type declarations for libcudf.