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>
23 
24 #include <memory>
25 
26 namespace CUDF_EXPORT cudf {
64 std::unique_ptr<column> rolling_window(
65  column_view const& input,
66  size_type preceding_window,
67  size_type following_window,
68  size_type min_periods,
69  rolling_aggregation const& agg,
72 
88 std::unique_ptr<column> rolling_window(
89  column_view const& input,
90  column_view const& default_outputs,
91  size_type preceding_window,
92  size_type following_window,
93  size_type min_periods,
94  rolling_aggregation const& agg,
97 
102  public:
109  static window_bounds get(size_type value) { return window_bounds(false, value); }
110 
117  {
118  return window_bounds(true, std::numeric_limits<cudf::size_type>::max());
119  }
120 
127  [[nodiscard]] bool is_unbounded() const { return _is_unbounded; }
128 
134  [[nodiscard]] size_type value() const { return _value; }
135 
136  private:
137  explicit window_bounds(bool is_unbounded_, size_type value_ = 0)
138  : _is_unbounded{is_unbounded_}, _value{value_}
139  {
140  }
141 
142  bool const _is_unbounded;
143  size_type const _value;
144 };
145 
238 std::unique_ptr<column> grouped_rolling_window(
239  table_view const& group_keys,
240  column_view const& input,
241  size_type preceding_window,
242  size_type following_window,
243  size_type min_periods,
244  rolling_aggregation const& aggr,
247 
260 std::unique_ptr<column> grouped_rolling_window(
261  table_view const& group_keys,
262  column_view const& input,
263  window_bounds preceding_window,
264  window_bounds following_window,
265  size_type min_periods,
266  rolling_aggregation const& aggr,
269 
286 std::unique_ptr<column> grouped_rolling_window(
287  table_view const& group_keys,
288  column_view const& input,
289  column_view const& default_outputs,
290  size_type preceding_window,
291  size_type following_window,
292  size_type min_periods,
293  rolling_aggregation const& aggr,
296 
310 std::unique_ptr<column> grouped_rolling_window(
311  table_view const& group_keys,
312  column_view const& input,
313  column_view const& default_outputs,
314  window_bounds preceding_window,
315  window_bounds following_window,
316  size_type min_periods,
317  rolling_aggregation const& aggr,
320 
406 std::unique_ptr<column> grouped_time_range_rolling_window(
407  table_view const& group_keys,
408  column_view const& timestamp_column,
409  cudf::order const& timestamp_order,
410  column_view const& input,
411  size_type preceding_window_in_days,
412  size_type following_window_in_days,
413  size_type min_periods,
414  rolling_aggregation const& aggr,
417 
437 std::unique_ptr<column> grouped_time_range_rolling_window(
438  table_view const& group_keys,
439  column_view const& timestamp_column,
440  cudf::order const& timestamp_order,
441  column_view const& input,
442  window_bounds preceding_window_in_days,
443  window_bounds following_window_in_days,
444  size_type min_periods,
445  rolling_aggregation const& aggr,
448 
559 std::unique_ptr<column> grouped_range_rolling_window(
560  table_view const& group_keys,
561  column_view const& orderby_column,
562  cudf::order const& order,
563  column_view const& input,
564  range_window_bounds const& preceding,
565  range_window_bounds const& following,
566  size_type min_periods,
567  rolling_aggregation const& aggr,
570 
607 std::unique_ptr<column> rolling_window(
608  column_view const& input,
609  column_view const& preceding_window,
610  column_view const& following_window,
611  size_type min_periods,
612  rolling_aggregation const& agg,
615  // end of group
617 } // 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=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 &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=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:39
Abstraction for window boundary sizes, to be used with grouped_range_rolling_window().
Abstraction for window boundary sizes.
Definition: rolling.hpp:101
static window_bounds unbounded()
Construct unbounded window boundary.
Definition: rolling.hpp:116
size_type value() const
Gets the row-boundary for this window_bounds.
Definition: rolling.hpp:134
bool is_unbounded() const
Definition: rolling.hpp:127
static window_bounds get(size_type value)
Construct bounded window boundary.
Definition: rolling.hpp:109
Type declarations for libcudf.