structs_column_device_view.cuh
1 /*
2  * Copyright (c) 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 
19 #include <cudf/types.hpp>
20 
21 namespace cudf {
22 
23 namespace detail {
24 
31  public:
32  structs_column_device_view() = delete;
33  ~structs_column_device_view() = default;
42 
49 
56  : column_device_view(underlying_)
57  {
58 #ifdef __CUDA_ARCH__
59  cudf_assert(underlying_.type().id() == type_id::STRUCT and
60  "structs_column_device_view only supports structs");
61 #else
62  CUDF_EXPECTS(underlying_.type().id() == type_id::STRUCT,
63  "structs_column_device_view only supports structs");
64 #endif
65  }
66 
72 
79  [[nodiscard]] __device__ inline column_device_view get_sliced_child(size_type idx) const
80  {
81  return child(idx).slice(offset(), size());
82  }
83 };
84 
85 } // namespace detail
86 
87 } // namespace cudf
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.
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.
constexpr type_id id() const noexcept
Returns the type identifier.
Definition: types.hpp:285
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 get_sliced_child(size_type idx) const
Fetches the child column of the underlying struct column.
column_device_view child(size_type child_index) const noexcept
Returns the specified child.
structs_column_device_view & operator=(structs_column_device_view const &)=default
Copy assignment operator.
structs_column_device_view(structs_column_device_view const &)=default
Copy constructor.
structs_column_device_view & operator=(structs_column_device_view &&)=default
Move assignment operator.
CUDF_HOST_DEVICE structs_column_device_view(column_device_view const &underlying_)
Construct a new structs column device view object from a column device view.
structs_column_device_view(structs_column_device_view &&)=default
Move constructor.
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:176
int32_t size_type
Row index type for columns and tables.
Definition: types.hpp:93
@ STRUCT
Struct elements.
cuDF interfaces
Definition: aggregation.hpp:34
Type declarations for libcudf.
#define CUDF_HOST_DEVICE
Indicates that the function or method is usable on host and device.
Definition: types.hpp:32