Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cudf::detail::column_device_view_base Class Reference

An immutable, non-owning view of device data as a column of elements that is trivially copyable and usable in CUDA device code. More...

Inheritance diagram for cudf::detail::column_device_view_base:
cudf::column_device_view cudf::mutable_column_device_view cudf::detail::lists_column_device_view cudf::detail::structs_column_device_view

Classes

struct  has_element_accessor_impl
 
struct  has_element_accessor_impl< C, T, void_t< decltype(std::declval< C >().template element< T >(std::declval< size_type >()))> >
 

Public Member Functions

 column_device_view_base (column_device_view_base const &)=default
 Copy constructor.
 
 column_device_view_base (column_device_view_base &&)=default
 Move constructor.
 
column_device_view_baseoperator= (column_device_view_base const &)=default
 Copy assignment operator. More...
 
column_device_view_baseoperator= (column_device_view_base &&)=default
 Move assignment operator. More...
 
template<typename T = void, CUDF_ENABLE_IF(std::is_same_v< T, void > or is_rep_layout_compatible< T >()) >
CUDF_HOST_DEVICE T const * head () const noexcept
 Returns pointer to the base device memory allocation casted to the specified type. More...
 
template<typename T , CUDF_ENABLE_IF(is_rep_layout_compatible< T >()) >
CUDF_HOST_DEVICE T const * data () const noexcept
 Returns the underlying data casted to the specified type, plus the offset. More...
 
CUDF_HOST_DEVICE size_type size () const noexcept
 Returns the number of elements in the column. More...
 
CUDF_HOST_DEVICE data_type type () const noexcept
 Returns the element type. More...
 
CUDF_HOST_DEVICE bool nullable () const noexcept
 Indicates whether the column can contain null elements, i.e., if it has an allocated bitmask. More...
 
CUDF_HOST_DEVICE bitmask_type const * null_mask () const noexcept
 Returns raw pointer to the underlying bitmask allocation. More...
 
CUDF_HOST_DEVICE size_type offset () const noexcept
 Returns the index of the first element relative to the base memory allocation, i.e., what is returned from head<T>(). More...
 
bool is_valid (size_type element_index) const noexcept
 Returns whether the specified element holds a valid value (i.e., not null). More...
 
bool is_valid_nocheck (size_type element_index) const noexcept
 Returns whether the specified element holds a valid value (i.e., not null) More...
 
bool is_null (size_type element_index) const noexcept
 Returns whether the specified element is null. More...
 
bool is_null_nocheck (size_type element_index) const noexcept
 Returns whether the specified element is null. More...
 
bitmask_type get_mask_word (size_type word_index) const noexcept
 Returns the specified bitmask word from the null_mask(). More...
 

Protected Member Functions

CUDF_HOST_DEVICE column_device_view_base (data_type type, size_type size, void const *data, bitmask_type const *null_mask, size_type offset)
 Constructs a column with the specified type, size, data, nullmask and offset. More...
 

Protected Attributes

data_type _type {type_id::EMPTY}
 Element type.
 
cudf::size_type _size {}
 Number of elements.
 
void const * _data {}
 Pointer to device memory containing elements.
 
bitmask_type const * _null_mask {}
 
size_type _offset {}
 

Detailed Description

An immutable, non-owning view of device data as a column of elements that is trivially copyable and usable in CUDA device code.

column_device_view_base and derived classes do not support has_nulls() or null_count(). The primary reason for this is that creation of column_device_views from column_views that have UNKNOWN null counts would require an on-the-spot, and not-obvious computation of null count, which could lead to undesirable performance issues. This information is also generally not needed in device code, and on the host-side is easily accessible from the associated column_view.

Definition at line 100 of file column_device_view.cuh.

Constructor & Destructor Documentation

◆ column_device_view_base()

CUDF_HOST_DEVICE cudf::detail::column_device_view_base::column_device_view_base ( data_type  type,
size_type  size,
void const *  data,
bitmask_type const *  null_mask,
size_type  offset 
)
inlineprotected

Constructs a column with the specified type, size, data, nullmask and offset.

Parameters
typeThe type of the column
sizeThe number of elements in the column
dataPointer to device memory containing elements
null_maskPointer to device memory containing bitmask representing valid elements
offsetIndex position of the first element

Definition at line 312 of file column_device_view.cuh.

Member Function Documentation

◆ data()

template<typename T , CUDF_ENABLE_IF(is_rep_layout_compatible< T >()) >
CUDF_HOST_DEVICE T const* cudf::detail::column_device_view_base::data ( ) const
inlinenoexcept

Returns the underlying data casted to the specified type, plus the offset.

Note
If offset() == 0, then head<T>() == data<T>()

For columns with children, the pointer returned is undefined and should not be used.

This function does not participate in overload resolution if is_rep_layout_compatible<T> is false.

Template Parameters
TThe type to cast to
Returns
Typed pointer to underlying data, including the offset

Definition at line 158 of file column_device_view.cuh.

◆ get_mask_word()

bitmask_type cudf::detail::column_device_view_base::get_mask_word ( size_type  word_index) const
inlinenoexcept

Returns the specified bitmask word from the null_mask().

Note
It is undefined behavior to call this function if nullable() == false.
Parameters
word_indexThe index of the word to get
Returns
bitmask word for the given word_index

Definition at line 289 of file column_device_view.cuh.

◆ head()

template<typename T = void, CUDF_ENABLE_IF(std::is_same_v< T, void > or is_rep_layout_compatible< T >()) >
CUDF_HOST_DEVICE T const* cudf::detail::column_device_view_base::head ( ) const
inlinenoexcept

Returns pointer to the base device memory allocation casted to the specified type.

Note
If offset() == 0, then head<T>() == data<T>()
It should be rare to need to access the head<T>() allocation of a column, and instead, accessing the elements should be done via data<T>().

This function will only participate in overload resolution if is_rep_layout_compatible<T>() or std::is_same_v<T,void> are true.

Template Parameters
Thetype to cast to
Returns
Typed pointer to underlying data

Definition at line 137 of file column_device_view.cuh.

◆ is_null()

bool cudf::detail::column_device_view_base::is_null ( size_type  element_index) const
inlinenoexcept

Returns whether the specified element is null.

Checks first for the existence of the null bitmask. If nullable() == false, this function always returns false.

Note
If nullable() == true can be guaranteed, then it is more performant to use is_null_nocheck().
Parameters
element_indexThe index of the element to query
Returns
true The element is null
false The element is valid

Definition at line 259 of file column_device_view.cuh.

◆ is_null_nocheck()

bool cudf::detail::column_device_view_base::is_null_nocheck ( size_type  element_index) const
inlinenoexcept

Returns whether the specified element is null.

This function does not verify the existence of the bitmask before attempting to read it. Therefore, it is undefined behavior to call this function if nullable() == false.

Parameters
element_indexThe index of the element to query
Returns
true The element is null
false The element is valid

Definition at line 275 of file column_device_view.cuh.

◆ is_valid()

bool cudf::detail::column_device_view_base::is_valid ( size_type  element_index) const
inlinenoexcept

Returns whether the specified element holds a valid value (i.e., not null).

Checks first for the existence of the null bitmask. If nullable() == false, this function always returns true.

Note
If nullable() == true can be guaranteed, then it is more performant to use is_valid_nocheck().
Parameters
element_indexThe index of the element to query
Returns
true The element is valid
false The element is null

Definition at line 224 of file column_device_view.cuh.

◆ is_valid_nocheck()

bool cudf::detail::column_device_view_base::is_valid_nocheck ( size_type  element_index) const
inlinenoexcept

Returns whether the specified element holds a valid value (i.e., not null)

This function does not verify the existence of the bitmask before attempting to read it. Therefore, it is undefined behavior to call this function if nullable() == false.

Parameters
element_indexThe index of the element to query
Returns
true The element is valid
false The element is null

Definition at line 241 of file column_device_view.cuh.

◆ null_mask()

CUDF_HOST_DEVICE bitmask_type const* cudf::detail::column_device_view_base::null_mask ( ) const
inlinenoexcept

Returns raw pointer to the underlying bitmask allocation.

Note
This function does not account for the offset().
If null_count() == 0, this may return nullptr.
Returns
Raw pointer to the underlying bitmask allocation

Definition at line 197 of file column_device_view.cuh.

◆ nullable()

CUDF_HOST_DEVICE bool cudf::detail::column_device_view_base::nullable ( ) const
inlinenoexcept

Indicates whether the column can contain null elements, i.e., if it has an allocated bitmask.

Note
If null_count() > 0, this function must always return true.
Returns
true The bitmask is allocated
false The bitmask is not allocated

Definition at line 186 of file column_device_view.cuh.

◆ offset()

CUDF_HOST_DEVICE size_type cudf::detail::column_device_view_base::offset ( ) const
inlinenoexcept

Returns the index of the first element relative to the base memory allocation, i.e., what is returned from head<T>().

Returns
The index of the first element relative to the head<T>()

Definition at line 208 of file column_device_view.cuh.

◆ operator=() [1/2]

column_device_view_base& cudf::detail::column_device_view_base::operator= ( column_device_view_base &&  )
default

Move assignment operator.

Returns
Reference to this object (after transferring ownership)

◆ operator=() [2/2]

column_device_view_base& cudf::detail::column_device_view_base::operator= ( column_device_view_base const &  )
default

Copy assignment operator.

Returns
Reference to this object

◆ size()

CUDF_HOST_DEVICE size_type cudf::detail::column_device_view_base::size ( ) const
inlinenoexcept

Returns the number of elements in the column.

Returns
The number of elements in the column

Definition at line 168 of file column_device_view.cuh.

◆ type()

CUDF_HOST_DEVICE data_type cudf::detail::column_device_view_base::type ( ) const
inlinenoexcept

Returns the element type.

Returns
The element type

Definition at line 175 of file column_device_view.cuh.

Member Data Documentation

◆ _null_mask

bitmask_type const* cudf::detail::column_device_view_base::_null_mask {}
protected

Pointer to device memory containing bitmask representing null elements.

Definition at line 298 of file column_device_view.cuh.

◆ _offset

size_type cudf::detail::column_device_view_base::_offset {}
protected

Index position of the first element. Enables zero-copy slicing

Definition at line 300 of file column_device_view.cuh.


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