libcudf  24.02.00
rolling.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2023, 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 
23 
24 #include <memory>
25 
26 namespace cudf {
63 std::unique_ptr<column> rolling_window(
64  column_view const& input,
65  size_type preceding_window,
66  size_type following_window,
67  size_type min_periods,
68  rolling_aggregation const& agg,
70 
85 std::unique_ptr<column> rolling_window(
86  column_view const& input,
87  column_view const& default_outputs,
88  size_type preceding_window,
89  size_type following_window,
90  size_type min_periods,
91  rolling_aggregation const& agg,
93 
97 struct window_bounds {
98  public:
105  static window_bounds get(size_type value) { return window_bounds(false, value); }
106 
113  {
114  return window_bounds(true, std::numeric_limits<cudf::size_type>::max());
115  }
116 
123  [[nodiscard]] bool is_unbounded() const { return _is_unbounded; }
124 
130  [[nodiscard]] size_type value() const { return _value; }
131 
132  private:
133  explicit window_bounds(bool is_unbounded_, size_type value_ = 0)
134  : _is_unbounded{is_unbounded_}, _value{value_}
135  {
136  }
137 
138  bool const _is_unbounded;
139  size_type const _value;
140 };
141 
233 std::unique_ptr<column> grouped_rolling_window(
234  table_view const& group_keys,
235  column_view const& input,
236  size_type preceding_window,
237  size_type following_window,
238  size_type min_periods,
239  rolling_aggregation const& aggr,
241 
253 std::unique_ptr<column> grouped_rolling_window(
254  table_view const& group_keys,
255  column_view const& input,
256  window_bounds preceding_window,
257  window_bounds following_window,
258  size_type min_periods,
259  rolling_aggregation const& aggr,
261 
277 std::unique_ptr<column> grouped_rolling_window(
278  table_view const& group_keys,
279  column_view const& input,
280  column_view const& default_outputs,
281  size_type preceding_window,
282  size_type following_window,
283  size_type min_periods,
284  rolling_aggregation const& aggr,
286 
299 std::unique_ptr<column> grouped_rolling_window(
300  table_view const& group_keys,
301  column_view const& input,
302  column_view const& default_outputs,
303  window_bounds preceding_window,
304  window_bounds following_window,
305  size_type min_periods,
306  rolling_aggregation const& aggr,
308 
393 std::unique_ptr<column> grouped_time_range_rolling_window(
394  table_view const& group_keys,
395  column_view const& timestamp_column,
396  cudf::order const& timestamp_order,
397  column_view const& input,
398  size_type preceding_window_in_days,
399  size_type following_window_in_days,
400  size_type min_periods,
401  rolling_aggregation const& aggr,
403 
422 std::unique_ptr<column> grouped_time_range_rolling_window(
423  table_view const& group_keys,
424  column_view const& timestamp_column,
425  cudf::order const& timestamp_order,
426  column_view const& input,
427  window_bounds preceding_window_in_days,
428  window_bounds following_window_in_days,
429  size_type min_periods,
430  rolling_aggregation const& aggr,
432 
542 std::unique_ptr<column> grouped_range_rolling_window(
543  table_view const& group_keys,
544  column_view const& orderby_column,
545  cudf::order const& order,
546  column_view const& input,
547  range_window_bounds const& preceding,
548  range_window_bounds const& following,
549  size_type min_periods,
550  rolling_aggregation const& aggr,
552 
588 std::unique_ptr<column> rolling_window(
589  column_view const& input,
590  column_view const& preceding_window,
591  column_view const& following_window,
592  size_type min_periods,
593  rolling_aggregation const& agg,
595  // end of group
597 } // namespace 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:187
std::unique_ptr< column > rolling_window(column_view const &input, size_type preceding_window, size_type following_window, size_type min_periods, rolling_aggregation const &agg, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Applies a fixed-size rolling window function to the values in a column.
std::unique_ptr< column > grouped_rolling_window(table_view const &group_keys, column_view const &input, size_type preceding_window, size_type following_window, size_type min_periods, rolling_aggregation const &aggr, rmm::mr::device_memory_resource *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 > 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::mr::device_memory_resource *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, size_type preceding_window_in_days, size_type following_window_in_days, size_type min_periods, rolling_aggregation const &aggr, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Applies a grouping-aware, timestamp-based rolling window function to the values in a column.
device_memory_resource * get_current_device_resource()
int32_t size_type
Row index type for columns and tables.
Definition: types.hpp:93
order
Indicates the order in which elements should be sorted.
Definition: types.hpp:116
cuDF interfaces
Definition: aggregation.hpp:34
Abstraction for window boundary sizes, to be used with grouped_range_rolling_window().
Abstraction for window boundary sizes.
Definition: rolling.hpp:97
static window_bounds unbounded()
Construct unbounded window boundary.
Definition: rolling.hpp:112
size_type value() const
Gets the row-boundary for this window_bounds.
Definition: rolling.hpp:130
bool is_unbounded() const
Definition: rolling.hpp:123
static window_bounds get(size_type value)
Construct bounded window boundary.
Definition: rolling.hpp:105
Type declarations for libcudf.