orc_metadata.hpp
转到此文件的文档。
1 /*
2  * Copyright (c) 2019-2025, NVIDIA CORPORATION.
3  *
4  * 根据 Apache 许可证 2.0 版(“许可证”)获得许可;
5  * 除非遵守许可证,否则您不得使用此文件。
6  * 您可以获取许可证的副本,地址如下:
7  *
8  * https://apache.ac.cn/licenses/LICENSE-2.0
9  *
10  * 除非适用法律要求或书面同意,软件
11  * 根据许可证分发时按“原样”分发,
12  * 不附带任何明示或暗示的保证或条件。
13  * 请参阅许可证以了解特定语言的管理权限和
14  * 限制。
15  */
16 
22 #pragma once
23 
24 #include <cudf/io/orc_types.hpp>
25 #include <cudf/io/types.hpp>
26 #include <cudf/utilities/export.hpp>
27 
28 #include <optional>
29 #include <variant>
30 #include <vector>
31 
32 namespace CUDF_EXPORT cudf {
33 namespace io {
50  std::vector<std::string> column_names;
51  std::vector<std::string> file_stats;
52  std::vector<std::vector<std::string>> stripes_stats;
53 };
54 
72  source_info const& src_info, rmm::cuda_stream_view stream = cudf::get_default_stream());
73 
77 using no_statistics = std::monostate;
78 
84 template <typename T>
86  std::optional<T> minimum;
87  std::optional<T> maximum;
88 };
89 
95 template <typename T>
97  std::optional<T> sum;
98 };
99 
103 struct integer_statistics : minmax_statistics<int64_t>, sum_statistics<int64_t> {};
104 
109 
117 struct string_statistics : minmax_statistics<std::string>, sum_statistics<int64_t> {};
118 
125  std::vector<uint64_t> count;
126 };
127 
131 struct decimal_statistics : minmax_statistics<std::string>, sum_statistics<std::string> {};
132 
137 
144 
152  std::optional<int64_t> minimum_utc;
153  std::optional<int64_t> maximum_utc;
154  std::optional<uint32_t> minimum_nanos;
155  std::optional<uint32_t> maximum_nanos;
156 };
157 
163 using statistics_type = std::variant<no_statistics,
172 
174 namespace orc::detail {
175 // 前向声明 protobuf_reader 使用的类型。`cudf::io::column_statistics` 对象,
176 // 从 `read_parsed_orc_statistics` 返回的对象,是从
177 // `protobuf_reader` 初始化的 `cudf::io::orc::detail::column_statistics` 对象构造的。
178 struct column_statistics;
179 } // namespace orc::detail
180 
188  std::optional<uint64_t> number_of_values;
189  std::optional<bool> has_null;
191 
197  column_statistics(orc::detail::column_statistics&& detail_statistics);
198 };
199 
208  std::vector<std::string> column_names;
209  std::vector<column_statistics> file_stats;
210  std::vector<std::vector<column_statistics>> stripes_stats;
211 };
212 
224  source_info const& src_info, rmm::cuda_stream_view stream = cudf::get_default_stream());
225 
230  public
238  orc_column_schema(std::string_view name,
239  orc::TypeKind type,
240  std::vector<orc_column_schema> children)
241  : _name{name}, _type_kind{type}, _children{std::move(children)}
242  {
243  }
244 
250  [[nodiscard]] auto name() const { return _name; }
251 
257  [[nodiscard]] auto type_kind() const { return _type_kind; }
258 
264  [[nodiscard]] auto const& children() const& { return _children; }
265 
270  [[nodiscard]] auto children() && { return std::move(_children); }
271 
279  [[nodiscard]] auto const& child(int idx) const& { return children().at(idx); }
280 
285  [[nodiscard]] auto child(int idx) && { return std::move(children().at(idx)); }
286 
292  [[nodiscard]] auto num_children() const { return children().size(); }
293 
294  private
295  std::string _name;
296  orc::TypeKind _type_kind;
297  std::vector<orc_column_schema> _children;
298 };
299 
303 struct orc_schema {
304  public
310  orc_schema(orc_column_schema root_column_schema) : _root{std::move(root_column_schema)} {}
311 
317  [[nodiscard]] auto const& root() const& { return _root; }
318 
323  [[nodiscard]] auto root() && { return std::move(_root); }
324 
325  private
326  orc_column_schema _root;
327 };
328 
333  public
341  orc_metadata(orc_schema schema, uint64_t num_rows, size_type num_stripes)
342  : _schema{std::move(schema)}, _num_rows{num_rows}, _num_stripes{num_stripes}
343  {
344  }
345 
351  [[nodiscard]] auto const& schema() const { return _schema; }
352 
354 
361  [[nodiscard]] auto num_rows() const { return _num_rows; }
362 
368  [[nodiscard]] auto num_stripes() const { return _num_stripes; }
369 
370  private
371  orc_schema _schema;
372  uint64_t _num_rows;
373  size_type _num_stripes;
374 };
375 
388  // 组结束
390 } // namespace io
391 } // namespace CUDF_EXPORT cudf
关于 ORC 文件内容的信息。
auto num_rows() const
返回根列的行数。
orc_metadata(orc_schema schema, uint64_t num_rows, size_type num_stripes)
构造函数
auto const & schema() const
返回 ORC 模式。
auto num_stripes() const
返回文件中的条带数。
rmm::cuda_stream_view const get_default_stream()
获取当前的默认流。
raw_orc_statistics read_raw_orc_statistics(source_info const &src_info, rmm::cuda_stream_view stream=cudf::get_default_stream())
读取 ORC 数据集的文件级和条带级统计信息。
parsed_orc_statistics read_parsed_orc_statistics(source_info const &src_info, rmm::cuda_stream_view stream=cudf::get_default_stream())
读取 ORC 数据集的文件级和条带级统计信息。
orc_metadata read_orc_metadata(source_info const &src_info, rmm::cuda_stream_view stream=cudf::get_default_stream())
读取 ORC 数据集的元数据。
sum_statistics< int64_t > binary_statistics
二进制列的统计信息。
minmax_statistics< int32_t > date_statistics
日期(时间)列的统计信息。
std::variant< no_statistics, integer_statistics, double_statistics, string_statistics, bucket_statistics, decimal_statistics, date_statistics, binary_statistics, timestamp_statistics > statistics_type
用于 ORC 特定类型列统计信息的变体类型。
std::monostate no_statistics
统计信息变体的 Monostate 类型别名。
TypeKind
标识 ORC 文件中的数据类型。
int32_t size_type
列和表的行索引类型。
定义: types.hpp:95
cuDF-IO API 类型定义
cuDF 接口
定义: host_udf.hpp:37
布尔列的统计信息。
std::vector< uint64_t > count
真值的计数
包含每个列的 ORC 统计信息。
column_statistics(orc::detail::column_statistics &&detail_statistics)
构造一个新的列统计信息对象。
statistics_type type_specific_stats
特定类型统计信息
std::optional< uint64_t > number_of_values
值数量
std::optional< bool > has_null
列是否包含任何 null 值
Decimal 列的统计信息。
浮点列的统计信息。
整型列的统计信息。
包含可选最小值和最大值的列统计信息基类。
std::optional< T > minimum
最小值。
std::optional< T > maximum
最大值。
ORC 列的模式,包括嵌套列。
auto const & children() const &
返回所有子列的模式。
orc_column_schema(std::string_view name, orc::TypeKind type, std::vector< orc_column_schema > children)
构造函数
auto child(int idx) &&
返回给定索引的子列模式。
auto type_kind() const
返回列的 ORC 类型。
auto const & child(int idx) const &
返回给定索引的子列模式。
auto name() const
返回 ORC 列名;可以为空。
auto num_children() const
返回子列的数量。
auto children() &&
返回所有子列的模式。
ORC 文件的模式。
auto root() &&
返回包含所有列作为字段的结构列的模式。
auto const & root() const &
返回包含所有列作为字段的结构列的模式。
orc_schema(orc_column_schema root_column_schema)
构造函数
包含列名以及解析后的文件级和条带级统计信息。
std::vector< std::vector< column_statistics > > stripes_stats
条带级统计信息
std::vector< std::string > column_names
列名
std::vector< column_statistics > file_stats
文件级统计信息
包含列名以及包含原始文件级和条带级统计信息的缓冲区。
std::vector< std::vector< std::string > > stripes_stats
每个列的条带级统计信息。
std::vector< std::string > column_names
列名。
std::vector< std::string > file_stats
每个列的文件级统计信息。
读接口的源信息。
字符串列的统计信息。
包含可选总和的列统计信息基类。
std::optional< T > sum
列中值的总和。
时间戳列的统计信息。
std::optional< uint32_t > minimum_nanos
最小值的纳秒部分
std::optional< uint32_t > maximum_nanos
最大值的纳秒部分
std::optional< int64_t > minimum_utc
最小值的毫秒部分
std::optional< int64_t > maximum_utc
最大值的毫秒部分