lists_column_device_view.cuh
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2020-2024, NVIDIA CORPORATION.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 #pragma once
6 
9 #include <cudf/types.hpp>
10 
11 #include <cuda_runtime.h>
12 
13 namespace cudf::detail {
14 
21  public:
22  lists_column_device_view() = delete;
23  ~lists_column_device_view() = default;
38 
45  : column_device_view(underlying_)
46  {
47 #ifdef __CUDA_ARCH__
48  cudf_assert(underlying_.type().id() == type_id::LIST and
49  "lists_column_device_view only supports lists");
50 #else
51  CUDF_EXPECTS(underlying_.type().id() == type_id::LIST,
52  "lists_column_device_view only supports lists");
53 #endif
54  }
55 
60 
66  [[nodiscard]] __device__ inline column_device_view offsets() const
67  {
69  }
70 
78  [[nodiscard]] __device__ inline size_type offset_at(size_type idx) const
79  {
80  return offsets().size() > 0 ? offsets().element<size_type>(offset() + idx) : 0;
81  }
82 
88  [[nodiscard]] __device__ inline column_device_view child() const
89  {
91  }
92 
98  [[nodiscard]] __device__ inline column_device_view get_sliced_child() const
99  {
100  auto start = offset_at(0);
101  auto end = offset_at(size());
102  return child().slice(start, end - start);
103  }
104 };
105 
106 } // namespace cudf::detail
An immutable, non-owning view of device data as a column of elements that is trivially copyable and u...
column_device_view child(size_type child_index) const noexcept
Returns the specified child.
T element(size_type element_index) const noexcept
Returns a copy of the element at the specified index.
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.
const_iterator< T > end() const
Returns an iterator to the element following the last element of the column.
constexpr CUDF_HOST_DEVICE type_id id() const noexcept
Returns the type identifier.
Definition: types.hpp:282
CUDF_HOST_DEVICE data_type type() const noexcept
Returns the element type.
CUDF_HOST_DEVICE size_type size() const noexcept
Returns the number of elements in the column.
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....
CUDF_HOST_DEVICE bool nullable() const noexcept
Indicates whether the column can contain null elements, i.e., if it has an allocated bitmask.
Given a column_device_view, an instance of this class provides a wrapper on this compound column for ...
column_device_view offsets() const
Fetches the offsets column of the underlying list column.
CUDF_HOST_DEVICE lists_column_device_view(column_device_view const &underlying_)
Construct a new lists column device view object from a column device view.
lists_column_device_view(lists_column_device_view &&)=default
Move constructor.
column_device_view get_sliced_child() const
Fetches the child column of the underlying list column with offset and size applied.
lists_column_device_view & operator=(lists_column_device_view const &)=default
Copy assignment operator.
lists_column_device_view & operator=(lists_column_device_view &&)=default
Move assignment operator.
size_type offset_at(size_type idx) const
Fetches the list offset value at a given row index while taking column offset into account.
lists_column_device_view(lists_column_device_view const &)=default
Copy constructor.
column_device_view child() const
Fetches the child column of the underlying list column.
static constexpr size_type child_column_index
The index of the child column.
static constexpr size_type offsets_column_index
The index of the offsets column.
Column device view class definitions.
#define CUDF_EXPECTS(...)
Macro for checking (pre-)conditions that throws an exception when a condition is violated.
Definition: error.hpp:143
int32_t size_type
Row index type for columns and tables.
Definition: types.hpp:84
@ LIST
List elements.
Class definition for cudf::lists_column_view.
Type declarations for libcudf.
#define CUDF_HOST_DEVICE
Indicates that the function or method is usable on host and device.
Definition: types.hpp:21