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 
20 namespace CUDF_EXPORT cudf {
38 std::unique_ptr<scalar> make_numeric_scalar(
39  data_type type,
42 
55 std::unique_ptr<scalar> make_timestamp_scalar(
56  data_type type,
59 
72 std::unique_ptr<scalar> make_duration_scalar(
73  data_type type,
76 
89 std::unique_ptr<scalar> make_fixed_width_scalar(
90  data_type type,
93 
106 std::unique_ptr<scalar> make_string_scalar(
107  std::string const& string,
110 
121 std::unique_ptr<scalar> make_default_constructed_scalar(
122  data_type type,
125 
136 std::unique_ptr<scalar> make_empty_scalar_like(
137  column_view const& input,
140 
150 template <typename T>
151 std::unique_ptr<scalar> make_fixed_width_scalar(
152  T value,
155 {
156  return std::make_unique<scalar_type_t<T>>(value, true, stream, mr);
157 }
158 
169 template <typename T>
170 std::unique_ptr<scalar> make_fixed_point_scalar(
171  typename T::rep value,
172  numeric::scale_type scale,
175 {
176  return std::make_unique<scalar_type_t<T>>(value, scale, true, stream, mr);
177 }
178 
187 std::unique_ptr<scalar> make_list_scalar(
188  column_view elements,
191 
202 std::unique_ptr<scalar> make_struct_scalar(
203  table_view const& data,
206 
217 std::unique_ptr<scalar> make_struct_scalar(
218  std::span<column_view const> data,
221  // end of group
223 } // 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:286
A set of cudf::column_view's of the same size.
Definition: table_view.hpp:206
APIs for querying the default CUDA stream and per-thread default stream status.
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:38
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.
APIs for getting and setting the current device memory resource.
cuDF interfaces
Definition: host_udf.hpp:26
Class definitions for cudf::scalar.