libcudf  24.02.00
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cudf::scalar Class Reference

An owning class to represent a singular value. More...

#include <scalar.hpp>

Inheritance diagram for cudf::scalar:
cudf::detail::fixed_width_scalar< T > cudf::fixed_point_scalar< T > cudf::list_scalar cudf::string_scalar cudf::struct_scalar cudf::chrono_scalar< T > cudf::numeric_scalar< T > cudf::duration_scalar< T > cudf::timestamp_scalar< T >

Public Member Functions

scalaroperator= (scalar const &other)=delete
 
scalaroperator= (scalar &&other)=delete
 
data_type type () const noexcept
 Returns the scalar's logical value type. More...
 
void set_valid_async (bool is_valid, rmm::cuda_stream_view stream=cudf::get_default_stream())
 Updates the validity of the value. More...
 
bool is_valid (rmm::cuda_stream_view stream=cudf::get_default_stream()) const
 Indicates whether the scalar contains a valid value. More...
 
bool * validity_data ()
 Returns a raw pointer to the validity bool in device memory. More...
 
bool const * validity_data () const
 Return a const raw pointer to the validity bool in device memory. More...
 

Protected Member Functions

 scalar (scalar &&other)=default
 Move constructor for scalar. More...
 
 scalar (scalar const &other, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
 Construct a new scalar object by deep copying another. More...
 
 scalar (data_type type, bool is_valid=false, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
 Construct a new scalar object. More...
 

Protected Attributes

data_type _type {type_id::EMPTY}
 Logical type of value in the scalar.
 
rmm::device_scalar< bool > _is_valid
 Device bool signifying validity.
 

Detailed Description

An owning class to represent a singular value.

A scalar is a singular value of any of the supported datatypes in cudf. Classes derived from this class are used to represent a scalar. Objects of derived classes should be upcasted to this class while passing to an external libcudf API.

Definition at line 48 of file scalar.hpp.

Constructor & Destructor Documentation

◆ scalar() [1/3]

cudf::scalar::scalar ( scalar &&  other)
protecteddefault

Move constructor for scalar.

Parameters
otherThe other scalar to move from.

◆ scalar() [2/3]

cudf::scalar::scalar ( scalar const &  other,
rmm::cuda_stream_view  stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource mr = rmm::mr::get_current_device_resource() 
)
protected

Construct a new scalar object by deep copying another.

Parameters
otherThe scalar to copy.
streamCUDA stream used for device memory operations.
mrDevice memory resource to use for device memory allocation.

◆ scalar() [3/3]

cudf::scalar::scalar ( data_type  type,
bool  is_valid = false,
rmm::cuda_stream_view  stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource mr = rmm::mr::get_current_device_resource() 
)
protected

Construct a new scalar object.

Note
Do not use this constructor directly. Instead, use a factory method like make_numeric_scalar or make_string_scalar
Parameters
typeData type of the scalar.
is_validWhether the value held by the scalar is valid.
streamCUDA stream used for device memory operations.
mrDevice memory resource to use for device memory allocation.

Member Function Documentation

◆ is_valid()

bool cudf::scalar::is_valid ( rmm::cuda_stream_view  stream = cudf::get_default_stream()) const

Indicates whether the scalar contains a valid value.

Note
Using the value when is_valid() == false is undefined behavior. In addition, this function does a stream synchronization.
Parameters
streamCUDA stream used for device memory operations.
Returns
true Value is valid
false Value is invalid/null

◆ set_valid_async()

void cudf::scalar::set_valid_async ( bool  is_valid,
rmm::cuda_stream_view  stream = cudf::get_default_stream() 
)

Updates the validity of the value.

Parameters
is_validtrue: set the value to valid. false: set it to null.
streamCUDA stream used for device memory operations.

◆ type()

data_type cudf::scalar::type ( ) const
noexcept

Returns the scalar's logical value type.

Returns
The scalar's logical value type

◆ validity_data() [1/2]

bool* cudf::scalar::validity_data ( )

Returns a raw pointer to the validity bool in device memory.

Returns
Raw pointer to the validity bool in device memory

◆ validity_data() [2/2]

bool const* cudf::scalar::validity_data ( ) const

Return a const raw pointer to the validity bool in device memory.

Returns
Raw pointer to the validity bool in device memory

The documentation for this class was generated from the following file: