range_window_bounds.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021-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 
19 #include <cudf/scalar/scalar.hpp>
20 #include <cudf/utilities/export.hpp>
21 
22 namespace CUDF_EXPORT cudf {
45  public:
49  enum class extent_type : int32_t {
50  CURRENT_ROW = 0,
51  BOUNDED,
53  UNBOUNDED
54  };
55 
63  static range_window_bounds get(scalar const& boundary,
65 
76 
83  [[nodiscard]] bool is_current_row() const { return _extent == extent_type::CURRENT_ROW; }
84 
94 
101  [[nodiscard]] bool is_unbounded() const { return _extent == extent_type::UNBOUNDED; }
102 
108  [[nodiscard]] scalar const& range_scalar() const { return *_range_scalar; }
109 
111  range_window_bounds() = default; // Required for use as return types from dispatch functors.
112 
113  private:
114  extent_type _extent{extent_type::UNBOUNDED};
115  std::shared_ptr<scalar> _range_scalar{nullptr}; // To enable copy construction/assignment.
116 
117  range_window_bounds(extent_type extent_,
118  std::unique_ptr<scalar> range_scalar_,
120 };
121  // end of group
123 } // namespace CUDF_EXPORT cudf
Indicator for the logical data type of an element in a column.
Definition: types.hpp:243
An owning class to represent a singular value.
Definition: scalar.hpp:48
rmm::cuda_stream_view const get_default_stream()
Get the current default stream.
cuDF interfaces
Definition: aggregation.hpp:35
Class definitions for cudf::scalar.
Abstraction for window boundary sizes, to be used with grouped_range_rolling_window().
scalar const & range_scalar() const
Returns the underlying scalar value for the bounds.
static range_window_bounds unbounded(data_type type, rmm::cuda_stream_view stream=cudf::get_default_stream())
Factory method to construct an unbounded window boundary.
static range_window_bounds get(scalar const &boundary, rmm::cuda_stream_view stream=cudf::get_default_stream())
Factory method to construct a bounded window boundary.
bool is_current_row() const
Whether or not the window is bounded to the current row.
range_window_bounds(range_window_bounds const &)=default
Copy constructor.
extent_type
The type of range_window_bounds.
static range_window_bounds current_row(data_type type, rmm::cuda_stream_view stream=cudf::get_default_stream())
Factory method to construct a window boundary limited to the value of the current row.
bool is_unbounded() const
Whether or not the window is unbounded.