lists_column_device_view.cuh
1 /*
2  * Copyright (c) 2020-2022, 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 
18 #include <cuda_runtime.h>
21 #include <cudf/types.hpp>
22 
23 namespace cudf {
24 
25 namespace detail {
26 
33  public:
34  lists_column_device_view() = delete;
35  ~lists_column_device_view() = default;
38 
50 
56  CUDF_HOST_DEVICE lists_column_device_view(column_device_view const& underlying_)
57  : column_device_view(underlying_)
58  {
59 #ifdef __CUDA_ARCH__
60  cudf_assert(underlying_.type().id() == type_id::LIST and
61  "lists_column_device_view only supports lists");
62 #else
63  CUDF_EXPECTS(underlying_.type().id() == type_id::LIST,
64  "lists_column_device_view only supports lists");
65 #endif
66  }
67 
72 
78  [[nodiscard]] __device__ inline column_device_view offsets() const
79  {
81  }
82 
90  [[nodiscard]] __device__ inline size_type offset_at(size_type idx) const
91  {
92  return offsets().size() > 0 ? offsets().element<size_type>(offset() + idx) : 0;
93  }
94 
100  [[nodiscard]] __device__ inline column_device_view child() const
101  {
103  }
104 
110  [[nodiscard]] __device__ inline column_device_view get_sliced_child() const
111  {
112  auto start = offset_at(0);
113  auto end = offset_at(size());
114  return child().slice(start, end - start);
115  }
116 };
117 
118 } // namespace detail
119 
120 } // namespace cudf
cudf::detail::lists_column_device_view::offsets
column_device_view offsets() const
Fetches the offsets column of the underlying list column.
Definition: lists_column_device_view.cuh:78
cudf::data_type::id
constexpr type_id id() const noexcept
Returns the type identifier.
Definition: types.hpp:280
cudf::size_type
int32_t size_type
Row index type for columns and tables.
Definition: types.hpp:80
cudf::column_device_view
An immutable, non-owning view of device data as a column of elements that is trivially copyable and u...
Definition: column_device_view.cuh:353
types.hpp
Type declarations for libcudf.
cudf::lists_column_view::offsets_column_index
static constexpr size_type offsets_column_index
The index of the offsets column.
Definition: lists_column_view.hpp:63
cudf::detail::lists_column_device_view
Given a column_device_view, an instance of this class provides a wrapper on this compound column for ...
Definition: lists_column_device_view.cuh:32
column_device_view.cuh
Column device view class definitions.
cudf::detail::lists_column_device_view::lists_column_device_view
lists_column_device_view(lists_column_device_view &&)=default
Move constructor.
cudf::column_device_view::slice
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.
Definition: column_device_view.cuh:399
cudf::detail::column_device_view_base::offset
CUDF_HOST_DEVICE size_type offset() const noexcept
Returns the index of the first element relative to the base memory allocation, i.e....
Definition: column_device_view.cuh:207
cudf::detail::lists_column_device_view::get_sliced_child
column_device_view get_sliced_child() const
Fetches the child column of the underlying list column with offset and size applied.
Definition: lists_column_device_view.cuh:110
cudf::detail::column_device_view_base::is_null
bool is_null(size_type element_index) const noexcept
Returns whether the specified element is null.
Definition: column_device_view.cuh:258
cudf::detail::lists_column_device_view::operator=
lists_column_device_view & operator=(lists_column_device_view &&)=default
Move assignment operator.
cudf::detail::column_device_view_base::nullable
CUDF_HOST_DEVICE bool nullable() const noexcept
Indicates whether the column can contain null elements, i.e., if it has an allocated bitmask.
Definition: column_device_view.cuh:185
cudf
cuDF interfaces
Definition: aggregation.hpp:34
cudf::column_device_view::end
const_iterator< T > end() const
Returns an iterator to the element following the last element of the column.
Definition: column_device_view.cuh:586
cudf::column_device_view::child
column_device_view child(size_type child_index) const noexcept
Returns the specified child.
Definition: column_device_view.cuh:849
cudf::detail::column_device_view_base::type
CUDF_HOST_DEVICE data_type type() const noexcept
Returns the element type.
Definition: column_device_view.cuh:174
cudf::lists_column_view::child_column_index
static constexpr size_type child_column_index
The index of the child column.
Definition: lists_column_view.hpp:64
cudf::detail::lists_column_device_view::child
column_device_view child() const
Fetches the child column of the underlying list column.
Definition: lists_column_device_view.cuh:100
cudf::detail::lists_column_device_view::operator=
lists_column_device_view & operator=(lists_column_device_view const &)=default
Copy assignment operator.
cudf::detail::column_device_view_base::size
CUDF_HOST_DEVICE size_type size() const noexcept
Returns the number of elements in the column.
Definition: column_device_view.cuh:167
cudf::detail::lists_column_device_view::lists_column_device_view
lists_column_device_view(lists_column_device_view const &)=default
Copy constructor.
CUDF_EXPECTS
#define CUDF_EXPECTS(...)
Macro for checking (pre-)conditions that throws an exception when a condition is violated.
Definition: error.hpp:123
lists_column_view.hpp
Class definition for cudf::lists_column_view.
cudf::column_device_view::element
T element(size_type element_index) const noexcept
Returns reference to element at the specified index.
Definition: column_device_view.cuh:429
cudf::detail::lists_column_device_view::offset_at
size_type offset_at(size_type idx) const
Fetches the list offset value at a given row index while taking column offset into account.
Definition: lists_column_device_view.cuh:90