7 #include <cudf/detail/offsets_iterator.cuh>
9 #include <cudf/strings/string_view.cuh>
14 #include <cuda/std/optional>
15 #include <cuda/std/type_traits>
18 #include <type_traits>
25 namespace CUDF_EXPORT
cudf {
37 struct YES : cuda::std::true_type {};
38 struct NO : cuda::std::false_type {};
54 constexpr
explicit DYNAMIC(
bool b) noexcept : value{b} {}
109 template <
typename T = void,
110 CUDF_ENABLE_IF(cuda::std::is_same_v<T, void> or is_rep_layout_compatible<T>())>
113 return static_cast<T const*
>(_data);
131 template <typename T, CUDF_ENABLE_IF(is_rep_layout_compatible<T>())>
134 return head<T>() + _offset;
200 return not
nullable() or is_valid_nocheck(element_index);
217 return bit_is_set(_null_mask, offset() + element_index);
251 return not is_valid_nocheck(element_index);
291 : _type{type}, _size{size}, _data{data}, _null_mask{null_mask}, _offset{offset}
295 template <
typename C,
typename T,
typename =
void>
296 struct has_element_accessor_impl : cuda::std::false_type {};
298 template <
typename C,
typename T>
299 struct has_element_accessor_impl<
302 void_t<decltype(cuda::std::declval<C>().template element<T>(cuda::std::declval<size_type>()))>>
303 : cuda::std::true_type {};
307 template <
typename T>
308 struct value_accessor;
309 template <
typename T,
typename Nullate>
310 struct optional_accessor;
311 template <
typename T,
bool has_nulls>
312 struct pair_accessor;
313 template <
typename T,
bool has_nulls>
314 struct pair_rep_accessor;
315 template <
typename T>
316 struct mutable_value_accessor;
380 this->offset() + offset,
382 this->num_child_columns()};
402 template <typename T, CUDF_ENABLE_IF(is_rep_layout_compatible<T>())>
405 return data<T>()[element_index];
419 template <
typename T, CUDF_ENABLE_IF(cuda::std::is_same_v<T,
string_view>)>
422 size_type index = element_index + offset();
423 char const* d_strings =
static_cast<char const*
>(_data);
424 auto const offsets = child(offsets_column_index);
425 auto const itr = cudf::detail::input_offsetalator(offsets.head(), offsets.type());
426 auto const offset = itr[index];
441 template <typename T, CUDF_ENABLE_IF(cudf::is_fixed_point<T>())>
445 using rep =
typename T::rep;
458 return d_children[child_index];
468 return _num_children;
500 : column_device_view_base(type, size, data, null_mask, offset),
501 d_children(children),
502 _num_children(num_children),
559 template <
typename T = void,
560 CUDF_ENABLE_IF(cuda::std::is_same_v<T, void> or is_rep_layout_compatible<T>())>
563 return const_cast<T*
>(detail::column_device_view_base::head<T>());
578 template <typename T, CUDF_ENABLE_IF(is_rep_layout_compatible<T>())>
581 return const_cast<T*
>(detail::column_device_view_base::data<T>());
598 template <typename T, CUDF_ENABLE_IF(is_rep_layout_compatible<T>())>
601 return data<T>()[element_index];
611 template <typename T, CUDF_ENABLE_IF(is_rep_layout_compatible<T>())>
614 data<T>()[element_index] = value;
625 template <typename T, CUDF_ENABLE_IF(is_fixed_point<T>())>
630 using rep =
typename T::rep;
631 data<rep>()[element_index] = value.value();
644 return const_cast<bitmask_type*
>(detail::column_device_view_base::null_mask());
656 return d_children[child_index];
674 __device__ void set_valid(size_type element_index) const noexcept
676 return set_bit(null_mask(), element_index);
692 __device__
void set_null(
size_type element_index)
const noexcept
694 return clear_bit(null_mask(), element_index);
734 : column_device_view_base(type, size, data, null_mask, offset),
735 d_children(children),
736 _num_children(num_children)
Utilities for bit and bitmask operations.
An immutable, non-owning view of device data as a column of elements that is trivially copyable and u...
column_device_view_core(column_device_view_core const &)=default
Copy constructor.
CUDF_HOST_DEVICE column_device_view_core(data_type type, size_type size, void const *data, size_type null_count, bitmask_type const *null_mask, size_type offset, column_device_view_core *children, size_type num_children)
Creates an instance of this class using pre-existing device memory pointers to data,...
CUDF_HOST_DEVICE size_type num_child_columns() const noexcept
Returns the number of child columns.
T element(size_type element_index) const noexcept
Returns a copy of the element at the specified index.
column_device_view_core & operator=(column_device_view_core const &)=default
Copy assignment operator.
CUDF_HOST_DEVICE size_type null_count() const noexcept
Returns the number of nulls in this column.
column_device_view_core(column_device_view_core &&)=default
Move constructor.
CUDF_HOST_DEVICE column_device_view_core slice(size_type offset, size_type size) const noexcept
Get a new raw_column_device_view which is a slice of this column.
column_device_view_core & operator=(column_device_view_core &&)=default
Move assignment operator.
column_device_view_core(column_view column, void *h_ptr, void *d_ptr)
Creates an instance of this class using the specified host memory pointer (h_ptr) to store child obje...
column_device_view_core child(size_type child_index) const noexcept
Returns the specified child.
A non-owning, immutable view of device data as a column of elements, some of which may be null as ind...
A container of nullable device data as a column of elements.
Indicator for the logical data type of an element in a column.
An immutable, non-owning view of device data as a column of elements that is trivially copyable and u...
CUDF_HOST_DEVICE T const * head() const noexcept
Returns pointer to the base device memory allocation casted to the specified type.
CUDF_HOST_DEVICE data_type type() const noexcept
Returns the element type.
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.
column_device_view_base & operator=(column_device_view_base &&)=default
Move assignment operator.
CUDF_HOST_DEVICE size_type size() const noexcept
Returns the number of elements in the column.
bitmask_type get_mask_word(size_type word_index) const noexcept
Returns the specified bitmask word from the null_mask().
column_device_view_base(column_device_view_base &&)=default
Move constructor.
column_device_view_base(column_device_view_base const &)=default
Copy constructor.
CUDF_HOST_DEVICE bitmask_type const * null_mask() const noexcept
Returns raw pointer to the underlying bitmask allocation.
bool is_valid_nocheck(size_type element_index) const noexcept
Returns whether the specified element holds a valid value (i.e., not null)
CUDF_HOST_DEVICE T const * data() const noexcept
Returns the underlying data casted to the specified type, plus the offset.
column_device_view_base & operator=(column_device_view_base const &)=default
Copy assignment operator.
bool is_null(size_type element_index) const noexcept
Returns whether the specified element is null.
CUDF_HOST_DEVICE size_type offset() const noexcept
Returns the index of the first element relative to the base memory allocation, i.e....
bool is_null_nocheck(size_type element_index) const noexcept
Returns whether the specified element is null.
CUDF_HOST_DEVICE bool nullable() const noexcept
Indicates whether the column can contain null elements, i.e., if it has an allocated bitmask.
bool is_valid(size_type element_index) const noexcept
Returns whether the specified element holds a valid value (i.e., not null).
A mutable, non-owning view of device data as a column of elements that is trivially copyable and usab...
mutable_column_device_view_core(mutable_column_device_view_core const &)=default
Copy constructor.
mutable_column_device_view_core child(size_type child_index) const noexcept
Returns the specified child.
void assign(size_type element_index, T value) const noexcept
Assigns value to the element at element_index
CUDF_HOST_DEVICE T * data() const noexcept
Returns the underlying data casted to the specified type, plus the offset.
CUDF_HOST_DEVICE mutable_column_device_view_core(data_type type, size_type size, void const *data, bitmask_type const *null_mask, size_type offset, mutable_column_device_view_core *children, size_type num_children)
Creates an instance of this class using pre-existing device memory pointers to data,...
void set_mask_word(size_type word_index, bitmask_type new_word) const noexcept
Updates the specified bitmask word in the null_mask() with a new word.
T & element(size_type element_index) const noexcept
Returns reference to element at the specified index.
CUDF_HOST_DEVICE T * head() const noexcept
Returns pointer to the base device memory allocation casted to the specified type.
mutable_column_device_view_core & operator=(mutable_column_device_view_core const &)=default
Copy assignment operator.
mutable_column_device_view_core & operator=(mutable_column_device_view_core &&)=default
Move assignment operator.
mutable_column_device_view_core(mutable_column_device_view_core &&)=default
Move constructor.
CUDF_HOST_DEVICE bitmask_type * null_mask() const noexcept
Returns raw pointer to the underlying bitmask allocation.
A non-owning, immutable view of device data that is a variable length char array representing a UTF-8...
Class definition for fixed point data type.
size_type null_count(bitmask_type const *bitmask, size_type start, size_type stop, rmm::cuda_stream_view stream=cudf::get_default_stream())
Given a validity bitmask, counts the number of null elements (unset bits) in the range [start,...
scale_type
The scale type for fixed_point.
constexpr CUDF_HOST_DEVICE size_type word_index(size_type bit_index)
Returns the index of the word containing the specified bit.
CUDF_HOST_DEVICE bool bit_is_set(bitmask_type const *bitmask, size_type bit_index)
Indicates whether the specified bit is set to 1
int32_t size_type
Row index type for columns and tables.
uint32_t bitmask_type
Bitmask type stored as 32-bit unsigned integer.
void void_t
Utility metafunction that maps a sequence of any types to the type void.
#define CUDF_ENABLE_IF(...)
Convenience macro for SFINAE as an unnamed template parameter.
bool nullable(table_view const &view)
Returns True if any of the columns in the table is nullable. (not entire hierarchy)
fixed_point and supporting types
nullate::DYNAMIC defers the determination of nullability to run time rather than compile time....
bool value
True if nulls are expected.
constexpr DYNAMIC(bool b) noexcept
Create a runtime nullate object.
Indicates the presence of nulls at compile-time or runtime.
Helper struct for constructing fixed_point when value is already shifted.
Type declarations for libcudf.
#define CUDF_HOST_DEVICE
Indicates that the function or method is usable on host and device.