lists_column_view.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020-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 
18 #include <cudf/column/column.hpp>
20 
21 #include <rmm/cuda_stream_view.hpp>
22 
28 namespace cudf {
29 
39 class lists_column_view : private column_view {
40  public:
46  lists_column_view(column_view const& lists_column);
49  ~lists_column_view() = default;
62 
63  static constexpr size_type offsets_column_index{0};
64  static constexpr size_type child_column_index{1};
65 
72  using column_view::offset;
73  using column_view::size;
74  static_assert(std::is_same_v<offset_type, size_type>,
75  "offset_type is expected to be the same as size_type.");
76  using offset_iterator = offset_type const*;
77 
83  [[nodiscard]] column_view parent() const;
84 
91  [[nodiscard]] column_view offsets() const;
92 
99  [[nodiscard]] column_view child() const;
100 
114 
120  [[nodiscard]] offset_iterator offsets_begin() const noexcept
121  {
122  return offsets().begin<offset_type>() + offset();
123  }
124 
135  [[nodiscard]] offset_iterator offsets_end() const noexcept
136  {
137  return offsets_begin() + size() + 1;
138  }
139 }; // end of group
141 } // namespace cudf
cudf::lists_column_view::offsets_begin
offset_iterator offsets_begin() const noexcept
Return first offset (accounting for column offset)
Definition: lists_column_view.hpp:120
cudf::lists_column_view::parent
column_view parent() const
Returns the parent column.
cudf::column_view::child_begin
auto child_begin() const noexcept
Returns iterator to the beginning of the ordered sequence of child column-views.
Definition: column_view.hpp:402
cudf::size_type
int32_t size_type
Row index type for columns and tables.
Definition: types.hpp:80
column.hpp
Class definition for cudf::column.
cudf::column_view
A non-owning, immutable view of device data as a column of elements, some of which may be null as ind...
Definition: column_view.hpp:313
cudf::detail::column_view_base::offset
size_type offset() const noexcept
Returns the index of the first element relative to the base memory allocation, i.e....
Definition: column_view.hpp:225
cudf::lists_column_view::get_sliced_child
column_view get_sliced_child(rmm::cuda_stream_view stream) const
Returns the internal child column, applying any offset from the root.
cudf::lists_column_view::operator=
lists_column_view & operator=(lists_column_view const &)=default
Copy assignment operator.
rmm::cuda_stream_view
cudf::lists_column_view::child
column_view child() const
Returns the internal child column.
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::column_view::child_end
auto child_end() const noexcept
Returns iterator to the end of the ordered sequence of child column-views.
Definition: column_view.hpp:409
cudf::lists_column_view::operator=
lists_column_view & operator=(lists_column_view &&)=default
Move assignment operator.
cudf::detail::column_view_base::null_count
size_type null_count() const
Returns the count of null elements.
Definition: column_view.hpp:165
cudf::offset_type
int32_t offset_type
Offset type for column offsets.
Definition: types.hpp:83
cudf::lists_column_view::offsets
column_view offsets() const
Returns the internal column of offsets.
cudf::lists_column_view::offset_iterator
offset_type const * offset_iterator
Iterator type for offsets.
Definition: lists_column_view.hpp:76
cudf::lists_column_view::offsets_end
offset_iterator offsets_end() const noexcept
Return pointer to the position that is one past the last offset.
Definition: lists_column_view.hpp:135
cudf::detail::column_view_base::has_nulls
bool has_nulls() const
Indicates if the column contains null elements, i.e., null_count() > 0
Definition: column_view.hpp:190
cudf
cuDF interfaces
Definition: aggregation.hpp:34
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::column_view_base::begin
T const * begin() const noexcept
Return first element (accounting for offset) after underlying data is casted to the specified type.
Definition: column_view.hpp:107
cudf::lists_column_view
Given a column-view of lists type, an instance of this class provides a wrapper on this compound colu...
Definition: lists_column_view.hpp:39
cudf::lists_column_view::lists_column_view
lists_column_view(lists_column_view const &)=default
Copy constructor.
cudf::detail::column_view_base::size
size_type size() const noexcept
Returns the number of elements in the column.
Definition: column_view.hpp:133
cudf::lists_column_view::lists_column_view
lists_column_view(lists_column_view &&)=default
Move constructor.
cudf::lists_column_view::lists_column_view
lists_column_view(column_view const &lists_column)
Construct a new lists column view object from a column view.
column_view.hpp
column view class definitions
cudf::detail::column_view_base::is_empty
bool is_empty() const noexcept
Returns true if size() returns zero, or false otherwise.
Definition: column_view.hpp:140
cudf::detail::column_view_base::null_mask
bitmask_type const * null_mask() const noexcept
Returns raw pointer to the underlying bitmask allocation.
Definition: column_view.hpp:217