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

A non-owning, immutable view of device data as a column of elements, some of which may be null as indicated by a bitmask. More...

#include <column_view.hpp>

Inheritance diagram for cudf::detail::column_view_base:
cudf::column_view cudf::detail::mutable_column_view_base cudf::mutable_column_view cudf::dictionary_column_view cudf::lists_column_view cudf::strings_column_view cudf::structs_column_view cudf::tdigest::tdigest_column_view

Public Member Functions

template<typename T = void, CUDF_ENABLE_IF(std::is_same_v< T, void > or is_rep_layout_compatible< T >()) >
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 >()) >
T const * data () const noexcept
 Returns the underlying data casted to the specified type, plus the offset. More...
 
template<typename T , CUDF_ENABLE_IF(is_rep_layout_compatible< T >()) >
T const * begin () const noexcept
 Return first element (accounting for offset) after underlying data is casted to the specified type. More...
 
template<typename T , CUDF_ENABLE_IF(is_rep_layout_compatible< T >()) >
T const * end () const noexcept
 Return one past the last element after underlying data is casted to the specified type. More...
 
size_type size () const noexcept
 Returns the number of elements in the column. More...
 
bool is_empty () const noexcept
 Returns true if size() returns zero, or false otherwise. More...
 
data_type type () const noexcept
 Returns the element data_type More...
 
bool nullable () const noexcept
 Indicates if the column can contain null elements, i.e., if it has an allocated bitmask. More...
 
size_type null_count () const
 Returns the count of null elements. More...
 
size_type null_count (size_type begin, size_type end) const
 Returns the count of null elements in the range [begin, end) More...
 
bool has_nulls () const
 Indicates if the column contains null elements, i.e., null_count() > 0 More...
 
bool has_nulls (size_type begin, size_type end) const
 Indicates if the column contains null elements in the range [begin, end), i.e., null_count(begin, end) > 0 More...
 
bitmask_type const * null_mask () const noexcept
 Returns raw pointer to the underlying bitmask allocation. More...
 
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...
 

Protected Member Functions

 column_view_base (column_view_base const &)=default
 Copy constructor.
 
 column_view_base (column_view_base &&)=default
 Move constructor.
 
column_view_baseoperator= (column_view_base const &)=default
 Copy assignment operator. More...
 
column_view_baseoperator= (column_view_base &&)=default
 Move assignment operator. More...
 
 column_view_base (data_type type, size_type size, void const *data, bitmask_type const *null_mask, size_type null_count, size_type offset=0)
 Construct a column_view_base from pointers to device memory for the elements and bitmask of the column. More...
 

Protected Attributes

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

Detailed Description

A non-owning, immutable view of device data as a column of elements, some of which may be null as indicated by a bitmask.

A column_view_base can be constructed implicitly from a cudf::column, or may be constructed explicitly from a pointer to pre-existing device memory.

Unless otherwise noted, the memory layout of the column_view_base's data and bitmask is expected to adhere to the Arrow Physical Memory Layout Specification: https://arrow.apache.org/docs/memory_layout.html

Because column_view_base is non-owning, no device memory is allocated nor freed when column_view_base objects are created or destroyed.

To enable zero-copy slicing, a column_view_base has an offset that indicates the index of the first element in the column relative to the base device memory allocation. By default, offset() is zero.

Definition at line 53 of file column_view.hpp.

Constructor & Destructor Documentation

◆ column_view_base()

cudf::detail::column_view_base::column_view_base ( data_type  type,
size_type  size,
void const *  data,
bitmask_type const *  null_mask,
size_type  null_count,
size_type  offset = 0 
)
protected

Construct a column_view_base from pointers to device memory for the elements and bitmask of the column.

If null_count() is zero, null_mask is optional.

If type is EMPTY, the specified null_count will be ignored and null_count() will always return the same value as size()

Exceptions
cudf::logic_errorif size < 0
cudf::logic_errorif size > 0 but data == nullptr
cudf::logic_errorif type.id() == EMPTY but data != nullptr or null_mask != nullptr
cudf::logic_errorif null_count > 0, but null_mask == nullptr
cudf::logic_errorif offset < 0
Parameters
typeThe element type
sizeThe number of elements
dataPointer to device memory containing the column elements
null_maskPointer to device memory containing the null indicator bitmask
null_countThe number of null elements.
offsetOptional, index of the first element

Member Function Documentation

◆ begin()

template<typename T , CUDF_ENABLE_IF(is_rep_layout_compatible< T >()) >
T const* cudf::detail::column_view_base::begin ( ) const
inlinenoexcept

Return first element (accounting for offset) after underlying data is casted to the specified type.

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

Template Parameters
TThe desired type
Returns
Pointer to the first element after casting

Definition at line 107 of file column_view.hpp.

◆ data()

template<typename T , CUDF_ENABLE_IF(is_rep_layout_compatible< T >()) >
T const* cudf::detail::column_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>()

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 91 of file column_view.hpp.

◆ end()

template<typename T , CUDF_ENABLE_IF(is_rep_layout_compatible< T >()) >
T const* cudf::detail::column_view_base::end ( ) const
inlinenoexcept

Return one past the last element after underlying data is casted to the specified type.

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

Template Parameters
TThe desired type
Returns
Pointer to one past the last element after casting

Definition at line 123 of file column_view.hpp.

◆ has_nulls() [1/2]

bool cudf::detail::column_view_base::has_nulls ( ) const
inline

Indicates if the column contains null elements, i.e., null_count() > 0

Returns
true One or more elements are null
false All elements are valid

Definition at line 190 of file column_view.hpp.

◆ has_nulls() [2/2]

bool cudf::detail::column_view_base::has_nulls ( size_type  begin,
size_type  end 
) const
inline

Indicates if the column contains null elements in the range [begin, end), i.e., null_count(begin, end) > 0

Exceptions
cudf::logic_errorfor invalid range (if begin < 0, begin > end, begin >= size(), or end > size()).
Parameters
beginThe starting index of the range (inclusive).
endThe index of the last element in the range (exclusive).
Returns
true One or more elements are null in the range [begin, end)
false All elements are valid in the range [begin, end)

Definition at line 204 of file column_view.hpp.

◆ head()

template<typename T = void, CUDF_ENABLE_IF(std::is_same_v< T, void > or is_rep_layout_compatible< T >()) >
T const* cudf::detail::column_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 73 of file column_view.hpp.

◆ is_empty()

bool cudf::detail::column_view_base::is_empty ( ) const
inlinenoexcept

Returns true if size() returns zero, or false otherwise.

Returns
True if size() returns zero, or false otherwise

Definition at line 140 of file column_view.hpp.

◆ null_count() [1/2]

size_type cudf::detail::column_view_base::null_count ( ) const
inline

Returns the count of null elements.

Returns
The count of null elements

Definition at line 165 of file column_view.hpp.

◆ null_count() [2/2]

size_type cudf::detail::column_view_base::null_count ( size_type  begin,
size_type  end 
) const

Returns the count of null elements in the range [begin, end)

Note
If null_count() != 0, every invocation of null_count(begin, end) will recompute the count of null elements indicated by the null_mask in the range [begin, end).
Exceptions
cudf::logic_errorfor invalid range (if begin < 0, begin > end, begin >= size(), or end > size()).
Parameters
[in]beginThe starting index of the range (inclusive).
[in]endThe index of the last element in the range (exclusive).
Returns
The count of null elements in the given range

◆ null_mask()

bitmask_type const* cudf::detail::column_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 bitmask

Definition at line 217 of file column_view.hpp.

◆ nullable()

bool cudf::detail::column_view_base::nullable ( ) const
inlinenoexcept

Indicates if 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 158 of file column_view.hpp.

◆ offset()

size_type cudf::detail::column_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 head<T>()

Definition at line 225 of file column_view.hpp.

◆ operator=() [1/2]

column_view_base& cudf::detail::column_view_base::operator= ( column_view_base &&  )
protecteddefault

Move assignment operator.

Returns
Reference to this object (after transferring ownership)

◆ operator=() [2/2]

column_view_base& cudf::detail::column_view_base::operator= ( column_view_base const &  )
protecteddefault

Copy assignment operator.

Returns
Reference to this object

◆ size()

size_type cudf::detail::column_view_base::size ( ) const
inlinenoexcept

Returns the number of elements in the column.

Returns
The number of elements in the column

Definition at line 133 of file column_view.hpp.

◆ type()

data_type cudf::detail::column_view_base::type ( ) const
inlinenoexcept

Returns the element data_type

Returns
The data_type of the elements in the column

Definition at line 147 of file column_view.hpp.

Member Data Documentation

◆ _null_mask

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

Pointer to device memory containing bitmask representing null elements. Optional if null_count() == 0

Definition at line 231 of file column_view.hpp.

◆ _offset

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

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

Definition at line 235 of file column_view.hpp.


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