rolling.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2020, 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/types.hpp>
20 
21 #include <memory>
22 
23 namespace cudf {
56 std::unique_ptr<column> rolling_window(
57  column_view const& input,
58  size_type preceding_window,
59  size_type following_window,
60  size_type min_periods,
61  std::unique_ptr<aggregation> const& agg,
62  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
63 
77 std::unique_ptr<column> rolling_window(
78  column_view const& input,
79  column_view const& default_outputs,
80  size_type preceding_window,
81  size_type following_window,
82  size_type min_periods,
83  std::unique_ptr<aggregation> const& agg,
84  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
85 
89 struct window_bounds {
90  public:
96  static window_bounds get(size_type value) { return window_bounds(false, value); }
97 
104  {
105  return window_bounds(true, std::numeric_limits<cudf::size_type>::max());
106  }
107 
108  // TODO: In the future, add units for bounds.
109  // E.g. {value=1, unit=DAYS, unbounded=false}
110  // For the present, assume units from context:
111  // 1. For time-based window functions, assume DAYS as before
112  // 2. For all else, assume ROWS as before.
113  const bool is_unbounded;
114  const size_type value;
115 
116  private:
117  explicit window_bounds(bool is_unbounded_, size_type value_ = 0)
118  : is_unbounded{is_unbounded_}, value{value_}
119  {
120  }
121 };
192 std::unique_ptr<column> grouped_rolling_window(
193  table_view const& group_keys,
194  column_view const& input,
195  size_type preceding_window,
196  size_type following_window,
197  size_type min_periods,
198  std::unique_ptr<aggregation> const& aggr,
199  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
200 
211 std::unique_ptr<column> grouped_rolling_window(
212  table_view const& group_keys,
213  column_view const& input,
214  window_bounds preceding_window,
215  window_bounds following_window,
216  size_type min_periods,
217  std::unique_ptr<aggregation> const& aggr,
218  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
219 
234 std::unique_ptr<column> grouped_rolling_window(
235  table_view const& group_keys,
236  column_view const& input,
237  column_view const& default_outputs,
238  size_type preceding_window,
239  size_type following_window,
240  size_type min_periods,
241  std::unique_ptr<aggregation> const& aggr,
242  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
243 
255 std::unique_ptr<column> grouped_rolling_window(
256  table_view const& group_keys,
257  column_view const& input,
258  column_view const& default_outputs,
259  window_bounds preceding_window,
260  window_bounds following_window,
261  size_type min_periods,
262  std::unique_ptr<aggregation> const& aggr,
263  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
264 
348 std::unique_ptr<column> grouped_time_range_rolling_window(
349  table_view const& group_keys,
350  column_view const& timestamp_column,
351  cudf::order const& timestamp_order,
352  column_view const& input,
353  size_type preceding_window_in_days,
354  size_type following_window_in_days,
355  size_type min_periods,
356  std::unique_ptr<aggregation> const& aggr,
357  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
358 
371 std::unique_ptr<column> grouped_time_range_rolling_window(
372  table_view const& group_keys,
373  column_view const& timestamp_column,
374  cudf::order const& timestamp_order,
375  column_view const& input,
376  window_bounds preceding_window_in_days,
377  window_bounds following_window_in_days,
378  size_type min_periods,
379  std::unique_ptr<aggregation> const& aggr,
380  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
381 
416 std::unique_ptr<column> rolling_window(
417  column_view const& input,
418  column_view const& preceding_window,
419  column_view const& following_window,
420  size_type min_periods,
421  std::unique_ptr<aggregation> const& agg,
422  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
423  // end of group
425 } // namespace cudf
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:294
types.hpp
Type declarations for libcudf.
cudf::window_bounds
Abstraction for window boundary sizes.
Definition: rolling.hpp:89
cudf::table_view
A set of cudf::column_view's of the same size.
Definition: table_view.hpp:154
cudf::window_bounds::get
static window_bounds get(size_type value)
Construct bounded window boundary.
Definition: rolling.hpp:96
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, std::unique_ptr< 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::window_bounds::unbounded
static window_bounds unbounded()
Construct unbounded window boundary.
Definition: rolling.hpp:103
cudf
cuDF interfaces
Definition: aggregation.hpp:34
rmm::mr::device_memory_resource
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, std::unique_ptr< 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::rolling_window
std::unique_ptr< column > rolling_window(column_view const &input, size_type preceding_window, size_type following_window, size_type min_periods, std::unique_ptr< 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::order
order
Indicates the order in which elements should be sorted.
Definition: types.hpp:119