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>
Public Member Functions | |
column_view (column_view const &)=default | |
Copy constructor. | |
column_view (column_view &&)=default | |
Move constructor. | |
column_view & | operator= (column_view const &)=default |
Copy assignment operator. More... | |
column_view & | operator= (column_view &&)=default |
Move assignment operator. More... | |
column_view (data_type type, size_type size, void const *data, bitmask_type const *null_mask, size_type null_count, size_type offset=0, std::vector< column_view > const &children={}) | |
Construct a column_view from pointers to device memory for the elements and bitmask of the column. More... | |
column_view | child (size_type child_index) const noexcept |
Returns the specified child. More... | |
size_type | num_children () const noexcept |
Returns the number of child columns. More... | |
auto | child_begin () const noexcept |
Returns iterator to the beginning of the ordered sequence of child column-views. More... | |
auto | child_end () const noexcept |
Returns iterator to the end of the ordered sequence of child column-views. More... | |
template<typename T , CUDF_ENABLE_IF(cudf::is_numeric< T >() or cudf::is_chrono< T >()) > | |
column_view (device_span< T const > data) | |
Construct a column view from a device_span<T>. More... | |
template<typename T , CUDF_ENABLE_IF(cudf::is_numeric< T >() or cudf::is_chrono< T >()) > | |
operator device_span< T const > () const | |
Converts a column view into a device span. More... | |
Public Member Functions inherited from cudf::detail::column_view_base | |
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 | |
void const * | get_data () const noexcept override |
Returns pointer to the base device memory allocation. More... | |
Protected Member Functions inherited from cudf::detail::column_view_base | |
column_view_base (column_view_base const &)=default | |
Copy constructor. | |
column_view_base (column_view_base &&)=default | |
Move constructor. | |
column_view_base & | operator= (column_view_base const &)=default |
Copy assignment operator. More... | |
column_view_base & | operator= (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... | |
Friends | |
column_view | bit_cast (column_view const &input, data_type type) |
Zero-copy cast between types with the same size and compatible underlying representations. More... | |
Additional Inherited Members | |
Protected Attributes inherited from cudf::detail::column_view_base | |
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 {} |
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
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
'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
is non-owning, no device memory is allocated nor freed when column_view
objects are created or destroyed.
To enable zero-copy slicing, a column_view
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 320 of file column_view.hpp.
cudf::column_view::column_view | ( | data_type | type, |
size_type | size, | ||
void const * | data, | ||
bitmask_type const * | null_mask, | ||
size_type | null_count, | ||
size_type | offset = 0 , |
||
std::vector< column_view > const & | children = {} |
||
) |
Construct a column_view
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()
cudf::logic_error | if size < 0 |
cudf::logic_error | if size > 0 but data == nullptr |
cudf::logic_error | if type.id() == EMPTY but data != nullptr or null_mask != nullptr |
cudf::logic_error | if null_count > 0 , but null_mask == nullptr |
cudf::logic_error | if offset < 0 |
type | The element type |
size | The number of elements |
data | Pointer to device memory containing the column elements |
null_mask | Pointer to device memory containing the null indicator bitmask |
null_count | The number of null elements. |
offset | Optional, index of the first element |
children | Optional, depending on the element type, child columns may contain additional data |
|
inline |
Construct a column view from a device_span<T>.
Only numeric and chrono types are supported.
T | The device span type. Must be const and match the column view's type. |
data | A typed device span containing the column view's data. |
Definition at line 427 of file column_view.hpp.
|
inlinenoexcept |
Returns the specified child.
child_index | The index of the desired child |
column_view
Definition at line 392 of file column_view.hpp.
|
inlinenoexcept |
Returns iterator to the beginning of the ordered sequence of child column-views.
column_view
referencing the first child column Definition at line 409 of file column_view.hpp.
|
inlinenoexcept |
Returns iterator to the end of the ordered sequence of child column-views.
column_view
one past the end of the child columns Definition at line 416 of file column_view.hpp.
|
overrideprotectedvirtualnoexcept |
Returns pointer to the base device memory allocation.
The primary purpose of this function is to allow derived classes to override the fundamental properties of memory accesses without needing to change all of the different accessors for the underlying pointer.
Reimplemented from cudf::detail::column_view_base.
|
inlinenoexcept |
Returns the number of child columns.
Definition at line 402 of file column_view.hpp.
|
inline |
Converts a column view into a device span.
Only numeric and chrono data types are supported. The column view must not be nullable.
T | The device span type. Must be const and match the column view's type. |
cudf::logic_error | if the column view type does not match the span type. |
cudf::logic_error | if the column view is nullable. |
Definition at line 449 of file column_view.hpp.
|
default |
Move assignment operator.
|
default |
Copy assignment operator.
|
friend |
Zero-copy cast between types with the same size and compatible underlying representations.
This is similar to reinterpret_cast
or bit_cast
in that it gives a view of the same raw bits as a different type. Unlike reinterpret_cast
however, this cast is only allowed on types that have the same width and compatible representations. For example, the way timestamp types are laid out in memory is equivalent to an integer representing a duration since a fixed epoch; bit-casting to the same integer type (INT32 for days, INT64 for others) results in a raw view of the duration count. A FLOAT32 can also be bit-casted into INT32 and treated as an integer value. However, an INT32 column cannot be bit-casted to INT64 as the sizes differ, nor can a string_view column be casted into a numeric type column as their data representations are not compatible.
The validity of the conversion can be checked with cudf::is_bit_castable()
.
cudf::logic_error | if the specified cast is not possible, i.e., is_bit_castable(input.type(), type) is false. |
input | The column_view to cast from |
type | The data_type to cast to |
column_view
wrapping the same data as input
but cast to type