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 
19 #include <cudf/rolling/range_window_bounds.hpp>
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,
69  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
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,
92  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
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 
213 std::unique_ptr<column> grouped_rolling_window(
214  table_view const& group_keys,
215  column_view const& input,
216  size_type preceding_window,
217  size_type following_window,
218  size_type min_periods,
219  rolling_aggregation const& aggr,
220  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
221 
233 std::unique_ptr<column> grouped_rolling_window(
234  table_view const& group_keys,
235  column_view const& input,
236  window_bounds preceding_window,
237  window_bounds following_window,
238  size_type min_periods,
239  rolling_aggregation const& aggr,
240  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
241 
257 std::unique_ptr<column> grouped_rolling_window(
258  table_view const& group_keys,
259  column_view const& input,
260  column_view const& default_outputs,
261  size_type preceding_window,
262  size_type following_window,
263  size_type min_periods,
264  rolling_aggregation const& aggr,
265  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
266 
279 std::unique_ptr<column> grouped_rolling_window(
280  table_view const& group_keys,
281  column_view const& input,
282  column_view const& default_outputs,
283  window_bounds preceding_window,
284  window_bounds following_window,
285  size_type min_periods,
286  rolling_aggregation const& aggr,
287  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
288 
373 std::unique_ptr<column> grouped_time_range_rolling_window(
374  table_view const& group_keys,
375  column_view const& timestamp_column,
376  cudf::order const& timestamp_order,
377  column_view const& input,
378  size_type preceding_window_in_days,
379  size_type following_window_in_days,
380  size_type min_periods,
381  rolling_aggregation const& aggr,
382  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
383 
402 std::unique_ptr<column> grouped_time_range_rolling_window(
403  table_view const& group_keys,
404  column_view const& timestamp_column,
405  cudf::order const& timestamp_order,
406  column_view const& input,
407  window_bounds preceding_window_in_days,
408  window_bounds following_window_in_days,
409  size_type min_periods,
410  rolling_aggregation const& aggr,
411  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
412 
522 std::unique_ptr<column> grouped_range_rolling_window(
523  table_view const& group_keys,
524  column_view const& orderby_column,
525  cudf::order const& order,
526  column_view const& input,
527  range_window_bounds const& preceding,
528  range_window_bounds const& following,
529  size_type min_periods,
530  rolling_aggregation const& aggr,
531  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
532 
568 std::unique_ptr<column> rolling_window(
569  column_view const& input,
570  column_view const& preceding_window,
571  column_view const& following_window,
572  size_type min_periods,
573  rolling_aggregation const& agg,
574  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
575  // end of group
577 } // namespace cudf
cudf::window_bounds::value
size_type value() const
Gets the row-boundary for this window_bounds.
Definition: rolling.hpp:130
per_device_resource.hpp
cudf::grouped_rolling_window
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.
cudf::size_type
int32_t size_type
Row index type for columns and tables.
Definition: types.hpp:80
cudf::column_view
A non-owning, immutable view of device data as a column of elements, some of which may be null as ind...
Definition: column_view.hpp:313
types.hpp
Type declarations for libcudf.
cudf::range_window_bounds
Abstraction for window boundary sizes, to be used with grouped_range_rolling_window().
Definition: range_window_bounds.hpp:38
cudf::rolling_window
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.
cudf::grouped_time_range_rolling_window
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.
cudf::window_bounds
Abstraction for window boundary sizes.
Definition: rolling.hpp:97
cudf::table_view
A set of cudf::column_view's of the same size.
Definition: table_view.hpp:187
cudf::window_bounds::get
static window_bounds get(size_type value)
Construct bounded window boundary.
Definition: rolling.hpp:105
cudf::window_bounds::unbounded
static window_bounds unbounded()
Construct unbounded window boundary.
Definition: rolling.hpp:112
cudf
cuDF interfaces
Definition: aggregation.hpp:34
cudf::rolling_aggregation
Derived class intended for rolling_window specific aggregation usage.
Definition: aggregation.hpp:182
cudf::grouped_range_rolling_window
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.
cudf::window_bounds::is_unbounded
bool is_unbounded() const
Definition: rolling.hpp:123
rmm::mr::device_memory_resource
cudf::order
order
Indicates the order in which elements should be sorted.
Definition: types.hpp:103