column_device_view.cuh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2023, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 
19 #include <cudf/detail/utilities/alignment.hpp>
21 #include <cudf/lists/list_view.hpp>
22 #include <cudf/strings/string_view.cuh>
25 #include <cudf/types.hpp>
26 #include <cudf/utilities/bit.hpp>
27 #include <cudf/utilities/default_stream.hpp>
28 #include <cudf/utilities/span.hpp>
31 
32 #include <rmm/cuda_stream_view.hpp>
33 
34 #include <thrust/iterator/counting_iterator.h>
35 #include <thrust/iterator/transform_iterator.h>
36 #include <thrust/optional.h>
37 #include <thrust/pair.h>
38 
39 #include <algorithm>
40 
46 namespace cudf {
47 
55 struct nullate {
56  struct YES : std::bool_constant<true> {};
57  struct NO : std::bool_constant<false> {};
63  struct DYNAMIC {
64  DYNAMIC() = delete;
73  constexpr explicit DYNAMIC(bool b) noexcept : value{b} {}
80  constexpr operator bool() const noexcept { return value; }
81  bool value;
82  };
83 };
84 
85 namespace detail {
97 class alignas(16) column_device_view_base {
98  public:
99  column_device_view_base() = delete;
100  ~column_device_view_base() = default;
115 
132  template <typename T = void,
133  CUDF_ENABLE_IF(std::is_same_v<T, void> or is_rep_layout_compatible<T>())>
134  [[nodiscard]] CUDF_HOST_DEVICE T const* head() const noexcept
135  {
136  return static_cast<T const*>(_data);
137  }
138 
154  template <typename T, CUDF_ENABLE_IF(is_rep_layout_compatible<T>())>
155  [[nodiscard]] CUDF_HOST_DEVICE T const* data() const noexcept
156  {
157  return head<T>() + _offset;
158  }
159 
165  [[nodiscard]] CUDF_HOST_DEVICE size_type size() const noexcept { return _size; }
166 
172  [[nodiscard]] CUDF_HOST_DEVICE data_type type() const noexcept { return _type; }
173 
183  [[nodiscard]] CUDF_HOST_DEVICE bool nullable() const noexcept { return nullptr != _null_mask; }
184 
194  [[nodiscard]] CUDF_HOST_DEVICE bitmask_type const* null_mask() const noexcept
195  {
196  return _null_mask;
197  }
198 
205  [[nodiscard]] CUDF_HOST_DEVICE size_type offset() const noexcept { return _offset; }
206 
221  [[nodiscard]] __device__ bool is_valid(size_type element_index) const noexcept
222  {
223  return not nullable() or is_valid_nocheck(element_index);
224  }
225 
238  [[nodiscard]] __device__ bool is_valid_nocheck(size_type element_index) const noexcept
239  {
240  return bit_is_set(_null_mask, offset() + element_index);
241  }
242 
256  [[nodiscard]] __device__ bool is_null(size_type element_index) const noexcept
257  {
258  return not is_valid(element_index);
259  }
260 
272  [[nodiscard]] __device__ bool is_null_nocheck(size_type element_index) const noexcept
273  {
274  return not is_valid_nocheck(element_index);
275  }
276 
286  [[nodiscard]] __device__ bitmask_type get_mask_word(size_type word_index) const noexcept
287  {
288  return null_mask()[word_index];
289  }
290 
291  protected:
294  void const* _data{};
299 
310  size_type size,
311  void const* data,
312  bitmask_type const* null_mask,
315  {
316  }
317 
318  template <typename C, typename T, typename = void>
319  struct has_element_accessor_impl : std::false_type {};
320 
321  template <typename C, typename T>
322  struct has_element_accessor_impl<
323  C,
324  T,
325  void_t<decltype(std::declval<C>().template element<T>(std::declval<size_type>()))>>
326  : std::true_type {};
327 };
328 // @cond
329 // Forward declaration
330 template <typename T>
331 struct value_accessor;
332 template <typename T, typename Nullate>
333 struct optional_accessor;
334 template <typename T, bool has_nulls>
335 struct pair_accessor;
336 template <typename T, bool has_nulls>
337 struct pair_rep_accessor;
338 template <typename T>
339 struct mutable_value_accessor;
340 // @endcond
341 } // namespace detail
342 
350  public:
351  column_device_view() = delete;
352  ~column_device_view() = default;
367 
377  column_device_view(column_view column, void* h_ptr, void* d_ptr);
378 
395  [[nodiscard]] CUDF_HOST_DEVICE column_device_view slice(size_type offset,
396  size_type size) const noexcept
397  {
398  return column_device_view{this->type(),
399  size,
400  this->head(),
401  this->null_mask(),
402  this->offset() + offset,
403  d_children,
404  this->num_child_columns()};
405  }
406 
424  template <typename T, CUDF_ENABLE_IF(is_rep_layout_compatible<T>())>
425  [[nodiscard]] __device__ T element(size_type element_index) const noexcept
426  {
427  return data<T>()[element_index];
428  }
429 
441  template <typename T, CUDF_ENABLE_IF(std::is_same_v<T, string_view>)>
442  __device__ T element(size_type element_index) const noexcept
443  {
444  size_type index = element_index + offset(); // account for this view's _offset
445  auto const* d_offsets = d_children[strings_column_view::offsets_column_index].data<int32_t>();
446  char const* d_strings = d_children[strings_column_view::chars_column_index].data<char>();
447  size_type offset = d_offsets[index];
448  return string_view{d_strings + offset, d_offsets[index + 1] - offset};
449  }
450 
451  private:
457  struct index_element_fn {
458  template <typename IndexType,
459  CUDF_ENABLE_IF(is_index_type<IndexType>() and std::is_unsigned_v<IndexType>)>
460  __device__ size_type operator()(column_device_view const& indices, size_type index)
461  {
462  return static_cast<size_type>(indices.element<IndexType>(index));
463  }
464 
465  template <typename IndexType,
466  typename... Args,
467  CUDF_ENABLE_IF(not(is_index_type<IndexType>() and std::is_unsigned_v<IndexType>))>
468  __device__ size_type operator()(Args&&... args)
469  {
470  CUDF_UNREACHABLE("dictionary indices must be an unsigned integral type");
471  }
472  };
473 
474  public:
499  template <typename T, CUDF_ENABLE_IF(std::is_same_v<T, dictionary32>)>
500  __device__ T element(size_type element_index) const noexcept
501  {
502  size_type index = element_index + offset(); // account for this view's _offset
503  auto const indices = d_children[0];
504  return dictionary32{type_dispatcher(indices.type(), index_element_fn{}, indices, index)};
505  }
506 
517  template <typename T, CUDF_ENABLE_IF(cudf::is_fixed_point<T>())>
518  __device__ T element(size_type element_index) const noexcept
519  {
520  using namespace numeric;
521  using rep = typename T::rep;
522  auto const scale = scale_type{_type.scale()};
523  return T{scaled_integer<rep>{data<rep>()[element_index], scale}};
524  }
525 
532  template <typename T>
533  static constexpr bool has_element_accessor()
534  {
535  return has_element_accessor_impl<column_device_view, T>::value;
536  }
537 
539  using count_it = thrust::counting_iterator<size_type>;
543  template <typename T>
544  using const_iterator = thrust::transform_iterator<detail::value_accessor<T>, count_it>;
545 
561  template <typename T, CUDF_ENABLE_IF(column_device_view::has_element_accessor<T>())>
562  [[nodiscard]] const_iterator<T> begin() const
563  {
565  }
566 
581  template <typename T, CUDF_ENABLE_IF(column_device_view::has_element_accessor<T>())>
582  [[nodiscard]] const_iterator<T> end() const
583  {
585  }
586 
590  template <typename T, typename Nullate>
592  thrust::transform_iterator<detail::optional_accessor<T, Nullate>, count_it>;
593 
597  template <typename T, bool has_nulls>
599  thrust::transform_iterator<detail::pair_accessor<T, has_nulls>, count_it>;
600 
606  template <typename T, bool has_nulls>
608  thrust::transform_iterator<detail::pair_rep_accessor<T, has_nulls>, count_it>;
609 
664  template <typename T,
665  typename Nullate,
666  CUDF_ENABLE_IF(column_device_view::has_element_accessor<T>())>
667  auto optional_begin(Nullate has_nulls) const
668  {
671  }
672 
694  template <typename T,
695  bool has_nulls,
696  CUDF_ENABLE_IF(column_device_view::has_element_accessor<T>())>
698  {
701  }
702 
726  template <typename T,
727  bool has_nulls,
728  CUDF_ENABLE_IF(column_device_view::has_element_accessor<T>())>
730  {
733  }
734 
751  template <typename T,
752  typename Nullate,
753  CUDF_ENABLE_IF(column_device_view::has_element_accessor<T>())>
754  auto optional_end(Nullate has_nulls) const
755  {
758  }
759 
771  template <typename T,
772  bool has_nulls,
773  CUDF_ENABLE_IF(column_device_view::has_element_accessor<T>())>
775  {
778  }
779 
792  template <typename T,
793  bool has_nulls,
794  CUDF_ENABLE_IF(column_device_view::has_element_accessor<T>())>
796  {
799  }
800 
819  static std::unique_ptr<column_device_view, std::function<void(column_device_view*)>> create(
821 
828  void destroy();
829 
837  static std::size_t extent(column_view const& source_view);
838 
845  [[nodiscard]] __device__ column_device_view child(size_type child_index) const noexcept
846  {
847  return d_children[child_index];
848  }
849 
855  [[nodiscard]] __device__ device_span<column_device_view const> children() const noexcept
856  {
858  }
859 
865  [[nodiscard]] CUDF_HOST_DEVICE size_type num_child_columns() const noexcept
866  {
867  return _num_children;
868  }
869 
870  private:
883  CUDF_HOST_DEVICE column_device_view(data_type type,
884  size_type size,
885  void const* data,
886  bitmask_type const* null_mask,
889  size_type num_children)
890  : column_device_view_base(type, size, data, null_mask, offset),
892  _num_children(num_children)
893  {
894  }
895 
896  protected:
902 
914 };
915 
923  public:
924  mutable_column_device_view() = delete;
925  ~mutable_column_device_view() = default;
940 
951 
970  static std::unique_ptr<mutable_column_device_view,
971  std::function<void(mutable_column_device_view*)>>
974 
991  template <typename T = void,
992  CUDF_ENABLE_IF(std::is_same_v<T, void> or is_rep_layout_compatible<T>())>
993  CUDF_HOST_DEVICE T* head() const noexcept
994  {
995  return const_cast<T*>(detail::column_device_view_base::head<T>());
996  }
997 
1010  template <typename T, CUDF_ENABLE_IF(is_rep_layout_compatible<T>())>
1011  CUDF_HOST_DEVICE T* data() const noexcept
1012  {
1013  return const_cast<T*>(detail::column_device_view_base::data<T>());
1014  }
1015 
1030  template <typename T, CUDF_ENABLE_IF(is_rep_layout_compatible<T>())>
1031  __device__ T& element(size_type element_index) const noexcept
1032  {
1033  return data<T>()[element_index];
1034  }
1035 
1042  template <typename T>
1043  static constexpr bool has_element_accessor()
1044  {
1045  return has_element_accessor_impl<mutable_column_device_view, T>::value;
1046  }
1047 
1056  [[nodiscard]] CUDF_HOST_DEVICE bitmask_type* null_mask() const noexcept
1057  {
1059  }
1060 
1062  using count_it = thrust::counting_iterator<size_type>;
1066  template <typename T>
1067  using iterator = thrust::transform_iterator<detail::mutable_value_accessor<T>, count_it>;
1068 
1079  template <typename T, CUDF_ENABLE_IF(mutable_column_device_view::has_element_accessor<T>())>
1081  {
1083  }
1084 
1095  template <typename T, CUDF_ENABLE_IF(mutable_column_device_view::has_element_accessor<T>())>
1097  {
1099  }
1100 
1107  [[nodiscard]] __device__ mutable_column_device_view child(size_type child_index) const noexcept
1108  {
1109  return d_children[child_index];
1110  }
1111 
1112 #ifdef __CUDACC__ // because set_bit in bit.hpp is wrapped with __CUDACC__
1127  __device__ void set_valid(size_type element_index) const noexcept
1128  {
1129  return set_bit(null_mask(), element_index);
1130  }
1131 
1145  __device__ void set_null(size_type element_index) const noexcept
1146  {
1147  return clear_bit(null_mask(), element_index);
1148  }
1149 
1150 #endif
1151 
1162  __device__ void set_mask_word(size_type word_index, bitmask_type new_word) const noexcept
1163  {
1164  null_mask()[word_index] = new_word;
1165  }
1166 
1175  static std::size_t extent(mutable_column_view source_view);
1176 
1183  void destroy();
1184 
1185  private:
1191 
1200  mutable_column_device_view(mutable_column_view source);
1201 };
1202 
1203 namespace detail {
1204 
1205 #ifdef __CUDACC__ // because set_bit in bit.hpp is wrapped with __CUDACC__
1206 
1213 __device__ inline bitmask_type get_mask_offset_word(bitmask_type const* __restrict__ source,
1214  size_type destination_word_index,
1215  size_type source_begin_bit,
1216  size_type source_end_bit)
1217 {
1218  size_type source_word_index = destination_word_index + word_index(source_begin_bit);
1219  bitmask_type curr_word = source[source_word_index];
1220  bitmask_type next_word = 0;
1221  if (word_index(source_end_bit - 1) >
1222  word_index(source_begin_bit +
1223  destination_word_index * detail::size_in_bits<bitmask_type>())) {
1224  next_word = source[source_word_index + 1];
1225  }
1226  return __funnelshift_r(curr_word, next_word, source_begin_bit);
1227 }
1228 
1229 #endif
1230 
1245 template <typename T>
1248 
1254  value_accessor(column_device_view const& _col) : col{_col}
1255  {
1256  CUDF_EXPECTS(type_id_matches_device_storage_type<T>(col.type().id()), "the data type mismatch");
1257  }
1258 
1264  __device__ T operator()(cudf::size_type i) const { return col.element<T>(i); }
1265 };
1266 
1293 template <typename T, typename Nullate>
1296 
1303  optional_accessor(column_device_view const& _col, Nullate with_nulls)
1304  : col{_col}, has_nulls{with_nulls}
1305  {
1306  CUDF_EXPECTS(type_id_matches_device_storage_type<T>(col.type().id()), "the data type mismatch");
1307  if (with_nulls) { CUDF_EXPECTS(_col.nullable(), "Unexpected non-nullable column."); }
1308  }
1309 
1317  __device__ inline thrust::optional<T> operator()(cudf::size_type i) const
1318  {
1319  if (has_nulls) {
1320  return (col.is_valid_nocheck(i)) ? thrust::optional<T>{col.element<T>(i)}
1321  : thrust::optional<T>{thrust::nullopt};
1322  }
1323  return thrust::optional<T>{col.element<T>(i)};
1324  }
1325 
1326  Nullate has_nulls{};
1327 };
1328 
1348 template <typename T, bool has_nulls = false>
1351 
1357  pair_accessor(column_device_view const& _col) : col{_col}
1358  {
1359  CUDF_EXPECTS(type_id_matches_device_storage_type<T>(col.type().id()), "the data type mismatch");
1360  if (has_nulls) { CUDF_EXPECTS(_col.nullable(), "Unexpected non-nullable column."); }
1361  }
1362 
1369  __device__ inline thrust::pair<T, bool> operator()(cudf::size_type i) const
1370  {
1371  return {col.element<T>(i), (has_nulls ? col.is_valid_nocheck(i) : true)};
1372  }
1373 };
1374 
1394 template <typename T, bool has_nulls = false>
1397 
1399 
1405  pair_rep_accessor(column_device_view const& _col) : col{_col}
1406  {
1407  CUDF_EXPECTS(type_id_matches_device_storage_type<T>(col.type().id()), "the data type mismatch");
1408  if (has_nulls) { CUDF_EXPECTS(_col.nullable(), "Unexpected non-nullable column."); }
1409  }
1410 
1417  __device__ inline thrust::pair<rep_type, bool> operator()(cudf::size_type i) const
1418  {
1419  return {get_rep<T>(i), (has_nulls ? col.is_valid_nocheck(i) : true)};
1420  }
1421 
1422  private:
1423  template <typename R, std::enable_if_t<std::is_same_v<R, rep_type>, void>* = nullptr>
1424  __device__ inline auto get_rep(cudf::size_type i) const
1425  {
1426  return col.element<R>(i);
1427  }
1428 
1429  template <typename R, std::enable_if_t<not std::is_same_v<R, rep_type>, void>* = nullptr>
1430  __device__ inline auto get_rep(cudf::size_type i) const
1431  {
1432  return col.element<R>(i).value();
1433  }
1434 };
1435 
1447 template <typename T>
1450 
1457  {
1458  CUDF_EXPECTS(type_id_matches_device_storage_type<T>(col.type().id()), "the data type mismatch");
1459  }
1460 
1467  __device__ T& operator()(cudf::size_type i) { return col.element<T>(i); }
1468 };
1469 
1495 template <typename ColumnDeviceView, typename ColumnViewIterator>
1496 ColumnDeviceView* child_columns_to_device_array(ColumnViewIterator child_begin,
1497  ColumnViewIterator child_end,
1498  void* h_ptr,
1499  void* d_ptr)
1500 {
1501  ColumnDeviceView* d_children = detail::align_ptr_for_type<ColumnDeviceView>(d_ptr);
1502  auto num_children = std::distance(child_begin, child_end);
1503  if (num_children > 0) {
1504  // The beginning of the memory must be the fixed-sized ColumnDeviceView
1505  // struct objects in order for d_children to be used as an array.
1506  auto h_column = detail::align_ptr_for_type<ColumnDeviceView>(h_ptr);
1507  auto d_column = d_children;
1508 
1509  // Any child data is assigned past the end of this array: h_end and d_end.
1510  auto h_end = reinterpret_cast<int8_t*>(h_column + num_children);
1511  auto d_end = reinterpret_cast<int8_t*>(d_column + num_children);
1512  std::for_each(child_begin, child_end, [&](auto const& col) {
1513  // inplace-new each child into host memory
1514  new (h_column) ColumnDeviceView(col, h_end, d_end);
1515  h_column++; // advance to next child
1516  // update the pointers for holding this child column's child data
1517  auto col_child_data_size = ColumnDeviceView::extent(col) - sizeof(ColumnDeviceView);
1518  h_end += col_child_data_size;
1519  d_end += col_child_data_size;
1520  });
1521  }
1522  return d_children;
1523 }
1524 
1525 } // namespace detail
1526 } // namespace cudf
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...
static std::unique_ptr< column_device_view, std::function< void(column_device_view *)> > create(column_view source_view, rmm::cuda_stream_view stream=cudf::get_default_stream())
Factory to construct a column view that is usable in device memory.
column_device_view(column_view source)
Construct's a column_device_view from a column_view populating all but the children.
column_device_view child(size_type child_index) const noexcept
Returns the specified child.
void destroy()
Destroy the column_device_view object.
column_device_view & operator=(column_device_view &&)=default
Move assignment operator.
thrust::counting_iterator< size_type > count_it
Counting iterator.
const_pair_iterator< T, has_nulls > pair_end() const
Return a pair iterator to the element following the last element of the column.
const_pair_rep_iterator< T, has_nulls > pair_rep_end() const
Return a pair iterator to the element following the last element of the column.
const_pair_iterator< T, has_nulls > pair_begin() const
Return a pair iterator to the first element of the column.
T element(size_type element_index) const noexcept
Returns reference to element at the specified index.
static constexpr bool has_element_accessor()
For a given T, indicates if column_device_view::element<T>() has a valid overload.
column_device_view & operator=(column_device_view const &)=default
Copy assignment operator.
CUDF_HOST_DEVICE column_device_view slice(size_type offset, size_type size) const noexcept
Get a new column_device_view which is a slice of this column.
thrust::transform_iterator< detail::value_accessor< T >, count_it > const_iterator
Iterator for navigating this column.
auto optional_end(Nullate has_nulls) const
Return an optional iterator to the element following the last element of the column.
thrust::transform_iterator< detail::pair_accessor< T, has_nulls >, count_it > const_pair_iterator
Pair iterator for navigating this column.
size_type _num_children
The number of child columns.
const_pair_rep_iterator< T, has_nulls > pair_rep_begin() const
Return a pair iterator to the first element of the column.
thrust::transform_iterator< detail::optional_accessor< T, Nullate >, count_it > const_optional_iterator
Optional iterator for navigating this column.
column_device_view * d_children
CUDF_HOST_DEVICE size_type num_child_columns() const noexcept
Returns the number of child columns.
auto optional_begin(Nullate has_nulls) const
Return an optional iterator to the first element of the column.
column_device_view(column_device_view const &)=default
Copy constructor.
column_device_view(column_device_view &&)=default
Move constructor.
const_iterator< T > begin() const
Return an iterator to the first element of the column.
thrust::transform_iterator< detail::pair_rep_accessor< T, has_nulls >, count_it > const_pair_rep_iterator
Pair rep iterator for navigating this column.
static std::size_t extent(column_view const &source_view)
Return the size in bytes of the amount of memory needed to hold a device view of the specified column...
column_device_view(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...
const_iterator< T > end() const
Returns an iterator to the element following the last element of the column.
device_span< column_device_view const > children() const noexcept
Returns a span containing the children of this column.
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.
Definition: column.hpp:48
Indicator for the logical data type of an element in a column.
Definition: types.hpp:227
constexpr int32_t scale() const noexcept
Returns the scale (for fixed_point types)
Definition: types.hpp:278
constexpr type_id id() const noexcept
Returns the type identifier.
Definition: types.hpp:271
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.
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.
void const * _data
Pointer to device memory containing elements.
CUDF_HOST_DEVICE bitmask_type const * null_mask() const noexcept
Returns raw pointer to the underlying bitmask allocation.
cudf::size_type _size
Number of elements.
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...
void destroy()
Destroy the mutable_column_device_view object.
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.
mutable_column_device_view(mutable_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...
static std::size_t extent(mutable_column_view source_view)
Return the size in bytes of the amount of memory needed to hold a device view of the specified column...
thrust::counting_iterator< size_type > count_it
Counting iterator.
static constexpr bool has_element_accessor()
For a given T, indicates if mutable_column_device_view::element<T>() has a valid overload.
mutable_column_device_view child(size_type child_index) const noexcept
Returns the specified child.
mutable_column_device_view(mutable_column_device_view const &)=default
Copy constructor.
T & element(size_type element_index) const noexcept
Returns reference to element at the specified index.
iterator< T > end()
Return one past the last element after underlying data is casted to the specified type.
mutable_column_device_view & operator=(mutable_column_device_view &&)=default
Move assignment operator.
mutable_column_device_view(mutable_column_device_view &&)=default
Move constructor.
mutable_column_device_view & operator=(mutable_column_device_view const &)=default
Copy assignment operator.
static std::unique_ptr< mutable_column_device_view, std::function< void(mutable_column_device_view *)> > create(mutable_column_view source_view, rmm::cuda_stream_view stream=cudf::get_default_stream())
Factory to construct a column view that is usable in device memory.
thrust::transform_iterator< detail::mutable_value_accessor< T >, count_it > iterator
Iterator for navigating this column.
iterator< T > begin()
Return first element (accounting for offset) after underlying data is casted to the specified type.
A non-owning, mutable view of device data as a column of elements, some of which may be null as indic...
A non-owning, immutable view of device data that is a variable length char array representing a UTF-8...
Definition: string_view.hpp:44
static constexpr size_type chars_column_index
Child index of the characters column.
static constexpr size_type offsets_column_index
Child index of the offsets column.
ColumnDeviceView * child_columns_to_device_array(ColumnViewIterator child_begin, ColumnViewIterator child_end, void *h_ptr, void *d_ptr)
Helper function for use by column_device_view and mutable_column_device_view constructors to build de...
column view class definitions
Class definition for fixed point data type.
constexpr CUDF_HOST_DEVICE size_type word_index(size_type bit_index)
Returns the index of the word containing the specified bit.
Definition: bit.hpp:72
CUDF_HOST_DEVICE bool bit_is_set(bitmask_type const *bitmask, size_type bit_index)
Indicates whether the specified bit is set to 1
Definition: bit.hpp:126
CUDF_HOST_DEVICE constexpr decltype(auto) __forceinline__ type_dispatcher(cudf::data_type dtype, Functor f, Ts &&... args)
Invokes an operator() template with the type instantiation based on the specified cudf::data_type's i...
std::conditional_t< std::is_same_v< numeric::decimal32, T >, int32_t, std::conditional_t< std::is_same_v< numeric::decimal64, T >, int64_t, std::conditional_t< std::is_same_v< numeric::decimal128, T >, __int128_t, T > >> device_storage_type_t
"Returns" the corresponding type that is stored on the device when using cudf::column
#define CUDF_EXPECTS(...)
Macro for checking (pre-)conditions that throws an exception when a condition is violated.
Definition: error.hpp:170
int32_t size_type
Row index type for columns and tables.
Definition: types.hpp:80
uint32_t bitmask_type
Bitmask type stored as 32-bit unsigned integer.
Definition: types.hpp:81
size_type distance(T f, T l)
Similar to std::distance but returns cudf::size_type and performs static_cast
Definition: types.hpp:94
void void_t
Utility metafunction that maps a sequence of any types to the type void.
Definition: traits.hpp:37
#define CUDF_ENABLE_IF(...)
Convenience macro for SFINAE as an unnamed template parameter.
Definition: traits.hpp:50
@ EMPTY
Always null with no underlying data.
Class definition for cudf::list_view.
cuDF interfaces
Definition: aggregation.hpp:34
rmm::cuda_stream_view const get_default_stream()
Get the current default stream.
bool has_nulls(table_view const &view)
Returns True if the table has nulls in any of its columns.
Definition: table_view.hpp:318
fixed_point and supporting types
Definition: fixed_point.hpp:32
scale_type
The scale type for fixed_point.
Definition: fixed_point.hpp:35
Class definition for cudf::strings_column_view.
Class definition for cudf::struct_view.
Mutable value accessor of column without null bitmask.
T & operator()(cudf::size_type i)
Accessor.
mutable_value_accessor(mutable_column_device_view &_col)
Constructor.
mutable_column_device_view col
mutable column view of column in device
optional accessor of a column
thrust::optional< T > operator()(cudf::size_type i) const
Returns a thrust::optional of column[i].
column_device_view const col
column view of column in device
optional_accessor(column_device_view const &_col, Nullate with_nulls)
Constructor.
pair accessor of column with/without null bitmask
column_device_view const col
column view of column in device
thrust::pair< T, bool > operator()(cudf::size_type i) const
Pair accessor.
pair_accessor(column_device_view const &_col)
constructor
pair accessor of column with/without null bitmask
thrust::pair< rep_type, bool > operator()(cudf::size_type i) const
Pair accessor.
column_device_view const col
column view of column in device
device_storage_type_t< T > rep_type
representation type
pair_rep_accessor(column_device_view const &_col)
constructor
value accessor of column without null bitmask
column_device_view const col
column view of column in device
value_accessor(column_device_view const &_col)
constructor
T operator()(cudf::size_type i) const
Returns the value of element at index i
Device version of C++20 std::span with reduced feature set.
Definition: span.hpp:277
A strongly typed wrapper for indices in a DICTIONARY type column.
Definition: dictionary.hpp:48
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.
Defines the mapping between cudf::type_id runtime type information and concrete C++ types.
Type declarations for libcudf.