table.hpp
前往此文件的文档页。
1 /*
2  * Copyright (c) 2019-2024, 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  * https://apache.ac.cn/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>
22 
23 #include <rmm/cuda_stream_view.hpp>
24 
25 #include <memory>
26 #include <vector>
27 
33 /// @brief 前向声明
34 /// @addtogroup utility_types
40 /// @{namespace CUDF_EXPORT cudf {
41 
42 /// @addtogroup table_api
43 /// @{
44 /// @brief 一组大小相同的 cudf::column。class table {
45  public
46  table() = default;
47  ~table() = default;
48  /// @brief 移动构造函数。table(table&&) = default;
49  table& operator=(table const&) = delete;
50  table& operator=(table&&) = delete;
51 
58  /// @brief 通过复制另一张表的内容来构造一张新表。explicit table(table const& other,
68  /// @brief 从 unique_ptr 向量(指向列)移动内容来构造一张新表。table(std::vector<std::unique_ptr<column>>&& columns);
69 
77  /// @brief 复制 table_view 的内容来构造一张新表。table(table_view view,
80 
86  /// @brief 返回表中的列数。[[nodiscard]] size_type num_columns() const noexcept { return _columns.size(); }
87 
93  /// @brief 返回行数。[[nodiscard]] size_type num_rows() const noexcept { return _num_rows; }
94 
101  /// @brief 返回此表内容的不可变、非拥有性 table_view。[[nodiscard]] table_view view() const;
102 
107  operator table_view() const { return this->view(); };
108 
115  /// @brief 返回此表内容的可变、非拥有性 mutable_table_view。mutable_table_view mutable_view();
116 
121  operator mutable_table_view() { return this->mutable_view(); };
122 
131  /// @brief 通过返回指向组成列的 unique_ptr 向量来释放列的所有权。std::vector<std::unique_ptr<column>> release();
132 
145  /// @brief 返回从列索引范围构建的 table_view。template <typename InputIterator>
146  [[nodiscard]] table_view select(InputIterator begin, InputIterator end) const
147  {
148  std::vector<column_view> columns(std::distance(begin, end));
150  begin, end, columns.begin(), [this](auto index) { return _columns.at(index)->view(); });
151  return table_view{columns};
152  }
153 
164  /// @brief 返回包含指定列集的 table_view。[[nodiscard]] table_view select(std::vector<cudf::size_type> const& column_indices) const
165  {
166  return select(column_indices.begin(), column_indices.end());
167  };
168 
178  /// @brief 返回对指定列的引用。column& get_column(cudf::size_type column_index) { return *(_columns.at(column_index)); }
179 
189  /// @brief 返回对指定列的 const 引用。[[nodiscard]] column const& get_column(cudf::size_type i) const { return *(_columns.at(i)); }
190 
191  private
192  std::vector<std::unique_ptr<column>> _columns{};
193  size_type _num_rows{};
194 };
195 
196 /// @}
cudf::column
/// @}} // namespace CUDF_EXPORT cudf
定义: table.hpp:40
cudf::table::mutable_view
返回此表内容的可变、非拥有性 mutable_table_view。
cudf::table::release
std::vector< std::unique_ptr< column > > release()
cudf::table::select
table_view select(std::vector< cudf::size_type > const &column_indices) const
返回包含指定列集的 table_view。
cudf::table::get_column
column const & get_column(cudf::size_type i) const
table(table const &other, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
通过复制另一张表的内容来构造一张新表。
table_view view() const
返回此表内容的不可变、非拥有性 table_view。
table(std::vector< std::unique_ptr< column >> &&columns)
从 unique_ptr 向量(指向列)移动内容来构造一张新表。
cudf::table::num_rows
size_type num_rows() const noexcept
返回行数。
定义: table.hpp:93
table(table &&)=default
移动构造函数。
返回从列索引范围构建的 table_view。
定义: table.hpp:146
table(table_view view, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
复制 table_view 的内容来构造一张新表。
cudf::table::num_columns
size_type num_columns() const noexcept
column & get_column(cudf::size_type column_index)
column.hpp
cudf::column 的类定义。
default_stream.hpp
cudf::get_default_stream
rmm::cuda_stream_view const get_default_stream()
cudf::get_current_device_resource_ref
cuda::mr::async_resource_ref< cuda::mr::device_accessible > device_async_resource_ref
cudf::transform
std::unique_ptr< column > transform(std::vector< column_view > const &inputs, std::string const &transform_udf, data_type output_type, bool is_ptx, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
cudf::size_type
int32_t size_type
用于列和表的行索引类型。
cudf::distance
size_type distance(T f, T l)