libcudf  24.04.00
scalar_factories.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2022, 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 #pragma once
17 
18 #include <cudf/scalar/scalar.hpp>
20 
21 #include <rmm/cuda_stream_view.hpp>
22 #include <rmm/mr/device/per_device_resource.hpp>
23 
24 namespace cudf {
44 std::unique_ptr<scalar> make_numeric_scalar(
45  data_type type,
46  rmm::cuda_stream_view stream = cudf::get_default_stream(),
47  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
48 
61 std::unique_ptr<scalar> make_timestamp_scalar(
62  data_type type,
63  rmm::cuda_stream_view stream = cudf::get_default_stream(),
64  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
65 
78 std::unique_ptr<scalar> make_duration_scalar(
79  data_type type,
80  rmm::cuda_stream_view stream = cudf::get_default_stream(),
81  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
82 
95 std::unique_ptr<scalar> make_fixed_width_scalar(
96  data_type type,
97  rmm::cuda_stream_view stream = cudf::get_default_stream(),
98  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
99 
112 std::unique_ptr<scalar> make_string_scalar(
113  std::string const& string,
114  rmm::cuda_stream_view stream = cudf::get_default_stream(),
115  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
116 
127 std::unique_ptr<scalar> make_default_constructed_scalar(
128  data_type type,
129  rmm::cuda_stream_view stream = cudf::get_default_stream(),
130  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
131 
142 std::unique_ptr<scalar> make_empty_scalar_like(
143  column_view const& input,
144  rmm::cuda_stream_view stream = cudf::get_default_stream(),
145  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
146 
156 template <typename T>
157 std::unique_ptr<scalar> make_fixed_width_scalar(
158  T value,
159  rmm::cuda_stream_view stream = cudf::get_default_stream(),
160  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource())
161 {
162  return std::make_unique<scalar_type_t<T>>(value, true, stream, mr);
163 }
164 
175 template <typename T>
176 std::unique_ptr<scalar> make_fixed_point_scalar(
177  typename T::rep value,
178  numeric::scale_type scale,
179  rmm::cuda_stream_view stream = cudf::get_default_stream(),
180  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource())
181 {
182  return std::make_unique<scalar_type_t<T>>(value, scale, true, stream, mr);
183 }
184 
193 std::unique_ptr<scalar> make_list_scalar(
194  column_view elements,
195  rmm::cuda_stream_view stream = cudf::get_default_stream(),
196  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
197 
208 std::unique_ptr<scalar> make_struct_scalar(
209  table_view const& data,
210  rmm::cuda_stream_view stream = cudf::get_default_stream(),
211  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
212 
223 std::unique_ptr<scalar> make_struct_scalar(
225  rmm::cuda_stream_view stream = cudf::get_default_stream(),
226  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
227  // end of group
229 } // namespace cudf
A non-owning, immutable view of device data as a column of elements, some of which may be null as ind...
Indicator for the logical data type of an element in a column.
Definition: types.hpp:241
A set of cudf::column_view's of the same size.
Definition: table_view.hpp:187
rmm::cuda_stream_view const get_default_stream()
Get the current default stream.
scale_type
The scale type for fixed_point.
Definition: fixed_point.hpp:43
std::unique_ptr< scalar > make_default_constructed_scalar(data_type type, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Constructs default constructed scalar of type type
std::unique_ptr< scalar > make_struct_scalar(table_view const &data, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Construct a struct scalar using the given table_view.
std::unique_ptr< scalar > make_fixed_point_scalar(typename T::rep value, numeric::scale_type scale, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Construct scalar using the given value of fixed_point type.
std::unique_ptr< scalar > make_list_scalar(column_view elements, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Construct scalar using the given column of elements.
std::unique_ptr< scalar > make_string_scalar(std::string const &string, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Construct STRING type scalar given a std::string. The size of the std::string must not exceed the max...
std::unique_ptr< scalar > make_numeric_scalar(data_type type, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Construct scalar with uninitialized storage to hold a value of the specified numeric data_type.
std::unique_ptr< scalar > make_duration_scalar(data_type type, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Construct scalar with uninitialized storage to hold a value of the specified duration data_type.
std::unique_ptr< scalar > make_timestamp_scalar(data_type type, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Construct scalar with uninitialized storage to hold a value of the specified timestamp data_type.
std::unique_ptr< scalar > make_fixed_width_scalar(data_type type, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Construct scalar with uninitialized storage to hold a value of the specified fixed-width data_type.
std::unique_ptr< scalar > make_empty_scalar_like(column_view const &input, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Creates an empty (invalid) scalar of the same type as the input column_view.
cuDF interfaces
Definition: aggregation.hpp:34
Class definitions for cudf::scalar.
C++20 std::span with reduced feature set.
Definition: span.hpp:224