scalar_factories.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 #pragma once
6 
7 #include <cudf/scalar/scalar.hpp>
10 
11 #include <rmm/cuda_stream_view.hpp>
12 
13 #include <span>
14 
15 namespace CUDF_EXPORT cudf {
35 std::unique_ptr<scalar> make_numeric_scalar(
36  data_type type,
39 
52 std::unique_ptr<scalar> make_timestamp_scalar(
53  data_type type,
56 
69 std::unique_ptr<scalar> make_duration_scalar(
70  data_type type,
73 
86 std::unique_ptr<scalar> make_fixed_width_scalar(
87  data_type type,
90 
103 std::unique_ptr<scalar> make_string_scalar(
104  std::string const& string,
107 
118 std::unique_ptr<scalar> make_default_constructed_scalar(
119  data_type type,
122 
133 std::unique_ptr<scalar> make_empty_scalar_like(
134  column_view const& input,
137 
147 template <typename T>
148 std::unique_ptr<scalar> make_fixed_width_scalar(
149  T value,
152 {
153  return std::make_unique<scalar_type_t<T>>(value, true, stream, mr);
154 }
155 
166 template <typename T>
167 std::unique_ptr<scalar> make_fixed_point_scalar(
168  typename T::rep value,
169  numeric::scale_type scale,
172 {
173  return std::make_unique<scalar_type_t<T>>(value, scale, true, stream, mr);
174 }
175 
184 std::unique_ptr<scalar> make_list_scalar(
185  column_view elements,
188 
199 std::unique_ptr<scalar> make_struct_scalar(
200  table_view const& data,
203 
214 std::unique_ptr<scalar> make_struct_scalar(
215  std::span<column_view const> data,
218  // end of group
220 } // 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...
Indicator for the logical data type of an element in a column.
Definition: types.hpp:278
A set of cudf::column_view's of the same size.
Definition: table_view.hpp:189
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:35
rmm::device_async_resource_ref get_current_device_resource_ref()
Get the current device memory resource reference.
cuda::mr::resource_ref< cuda::mr::device_accessible > device_async_resource_ref
std::unique_ptr< scalar > make_duration_scalar(data_type type, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Construct scalar with uninitialized storage to hold a value of the specified duration data_type.
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::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
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::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Construct scalar using the given column of elements.
std::unique_ptr< scalar > make_empty_scalar_like(column_view const &input, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Creates an empty (invalid) scalar of the same type as the input column_view.
std::unique_ptr< scalar > make_struct_scalar(std::span< column_view const > data, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Construct a struct scalar using the given span of column views.
std::unique_ptr< scalar > make_numeric_scalar(data_type type, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Construct scalar with uninitialized storage to hold a value of the specified numeric data_type.
std::unique_ptr< scalar > make_fixed_width_scalar(T value, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Construct scalar using the given value of fixed width type.
std::unique_ptr< scalar > make_default_constructed_scalar(data_type type, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Constructs default constructed scalar of type type
std::unique_ptr< scalar > make_string_scalar(std::string const &string, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Construct STRING type scalar given a std::string. The size of the std::string must not exceed the max...
std::unique_ptr< scalar > make_timestamp_scalar(data_type type, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Construct scalar with uninitialized storage to hold a value of the specified timestamp data_type.
cuDF interfaces
Definition: host_udf.hpp:26
Class definitions for cudf::scalar.