parquet.hpp
转到此文件的文档。
1 /*
2  * Copyright (c) 2020-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 
17 #pragma once
18 
19 #include <cudf/ast/expressions.hpp>
20 #include <cudf/io/detail/parquet.hpp>
21 #include <cudf/io/types.hpp>
23 #include <cudf/types.hpp>
24 #include <cudf/utilities/export.hpp>
26 
27 #include <iostream>
28 #include <memory>
29 #include <optional>
30 #include <string>
31 #include <utility>
32 #include <vector>
33 
34 namespace CUDF_EXPORT cudf {
35 namespace io {
42 constexpr size_t default_row_group_size_bytes =
43  std::numeric_limits<size_t>::max();
44 constexpr size_type default_row_group_size_rows = 1'000'000;
45 constexpr size_t default_max_page_size_bytes = 512 * 1024;
47 constexpr int32_t default_column_index_truncate_length = 64;
48 constexpr size_t default_max_dictionary_size = 1024 * 1024;
50 
52 
56 /*! \brief Parquet 读取器选项
57  * \param src 数据源
58  */
60  source_info _source;
61 
62  // 要读取的列在 schema 中的路径;`nullopt` 表示全部
63  std::optional<std::vector<std::string>> _columns;
64 
65  // 要读取的行组列表(如果为空则忽略)
66  std::vector<std::vector<size_type>> _row_groups;
67  // 从开头跳过的行数;Parquet 将行数存储为 int64_t
68  int64_t _skip_rows = 0;
69  // 要读取的行数;`nullopt` 表示全部
70  std::optional<size_type> _num_rows;
71 
72  // 用作抽象语法树 (AST) 的谓词过滤器,用于过滤输出行。
73  std::optional<std::reference_wrapper<ast::expression const>> _filter;
74 
75  // 是否将字符串数据存储为分类类型
76  bool _convert_strings_to_categories = false;
77  // 是否使用 PANDAS 元数据加载列
78  bool _use_pandas_metadata = true;
79  // 是否读取并使用 ARROW schema
80  bool _use_arrow_schema = true;
81  // 是否允许从不匹配的 Parquet 文件中读取匹配的选中列。
82  bool _allow_mismatched_pq_schemas = false;
83  // 将时间戳列转换为特定类型
84  data_type _timestamp_type{type_id::EMPTY};
85 
86  std::optional<std::vector<reader_column_schema>> _reader_column_schema;
87 
90  /*! \brief Parquet reader options
91  * \param src Data source
92  */
93  explicit parquet_reader_options(source_info src) : _source{std::move(src)} {}
94 
96 
97  public
100  /*! \brief 默认构造函数 */
101  explicit parquet_reader_options() = default;
102 
108  /*! \brief 创建 builder 的工厂函数
109  * \param src 源
110  */
112 
115  /*! \brief 返回数据源
116  * \return 源
117  */
118  [[nodiscard]] source_info const& get_source() const { return _source; }
119 
123  /*! \brief 返回是否将字符串转换为分类类型
124  * \return 如果启用则为 true
125  */
126  [[nodiscard]] bool is_enabled_convert_strings_to_categories() const
127  {
128  return _convert_strings_to_categories;
129  }
130 
133  /*! \brief 返回是否使用 PANDAS 元数据
134  * \return 如果启用则为 true
135  */
136  [[nodiscard]] bool is_enabled_use_pandas_metadata() const { return _use_pandas_metadata; }
137 
140  /*! \brief 返回是否使用 ARROW schema
141  * \return 如果启用则为 true
142  */
143  [[nodiscard]] bool is_enabled_use_arrow_schema() const { return _use_arrow_schema; }
144 
149  /*! \brief 返回是否允许从不匹配的 Parquet 文件中读取匹配的选中列。
150  * \return 如果启用则为 true
151  */
152  [[nodiscard]] bool is_enabled_allow_mismatched_pq_schemas() const
153  {
154  return _allow_mismatched_pq_schemas;
155  }
156 
159  /*! \brief 返回请求的列 schema
160  * \return 请求的列 schema
161  */
162  [[nodiscard]] std::optional<std::vector<reader_column_schema>> get_column_schema() const
163  {
164  return _reader_column_schema;
165  }
166 
169  /*! \brief 返回要跳过的起始行数
170  * \return 行数
171  */
172  [[nodiscard]] int64_t get_skip_rows() const { return _skip_rows; }
173 
177  /*! \brief 返回要读取的行数
178  * \return 行数
179  */
180  [[nodiscard]] std::optional<size_type> const& get_num_rows() const { return _num_rows; }
181 
184  /*! \brief 返回要读取的列列表
185  * \return 列名列表
186  */
187  [[nodiscard]] auto const& get_columns() const { return _columns; }
188 
191  /*! \brief 返回要读取的行组列表
192  * \return 行组索引列表
193  */
194  [[nodiscard]] auto const& get_row_groups() const { return _row_groups; }
195 
198  /*! \brief 返回谓词过滤器
199  * \return 谓词过滤器
200  */
201  [[nodiscard]] auto const& get_filter() const { return _filter; }
202 
205  /*! \brief 返回时间戳类型
206  * \return 时间戳类型
207  */
208  [[nodiscard]] data_type get_timestamp_type() const { return _timestamp_type; }
209 
212  /*! \brief 设置要读取的列
213  * \param col_names 列名列表
214  */
215  void set_columns(std::vector<std::string> col_names) { _columns = std::move(col_names); }
216 
219  /*! \brief 设置要读取的单个行组
220  * \param row_groups 行组索引列表
221  */
222  void set_row_groups(std::vector<std::vector<size_type>> row_groups);
223 
251  /*! \brief 设置应用于输出行的过滤器
252  * \param filter 作为 AST 的谓词过滤器
253  */
254  void set_filter(ast::expression const& filter) { _filter = filter; }
255 
258  /*! \brief 启用/禁用将字符串转换为分类类型
259  * \param val true 为启用,false 为禁用
260  */
261  void enable_convert_strings_to_categories(bool val) { _convert_strings_to_categories = val; }
262 
265  /*! \brief 启用/禁用使用 PANDAS 元数据
266  * \param val true 为启用,false 为禁用
267  */
268  void enable_use_pandas_metadata(bool val) { _use_pandas_metadata = val; }
269 
272  /*! \brief 启用/禁用使用 ARROW schema
273  * \param val true 为启用,false 为禁用
274  */
275  void enable_use_arrow_schema(bool val) { _use_arrow_schema = val; }
276 
281  /*! \brief 启用/禁用允许从不匹配的 Parquet 文件中读取匹配的选中列。
282  * \param val true 为启用,false 为禁用
283  */
284  void enable_allow_mismatched_pq_schemas(bool val) { _allow_mismatched_pq_schemas = val; }
285 
289  /*! \brief 设置自定义列 schema
290  * \param val 自定义列 schema
291  */
292  void set_column_schema(std::vector<reader_column_schema> val)
293  {
294  _reader_column_schema = std::move(val);
295  }
296 
299  /*! \brief 设置要跳过的起始行数
300  * \param val 行数
301  */
302  void set_skip_rows(int64_t val);
303 
306  /*! \brief 设置要读取的行数
307  * \param val 行数
308  */
310 
313  /*! \brief 设置时间戳类型
314  * \param type 时间戳类型
315  */
316  void set_timestamp_type(data_type type) { _timestamp_type = type; }
317 };
318 
319 /*! \brief Parquet 读取器选项 builder */
321  parquet_reader_options options;
322 
323  public
328  /*! \brief 默认构造函数 */
330 
335  /*! \brief 带源的构造函数
336  * \param src 数据源
337  */
338  explicit parquet_reader_options_builder(source_info src) : options{std::move(src)} {}
339 
343  /*! \brief 设置要读取的列
344  * \param col_names 列名列表
345  * \return 此 builder 对象
346  */
347  parquet_reader_options_builder& columns(std::vector<std::string> col_names)
348  {
349  options._columns = std::move(col_names);
350  return *this;
351  }
352 
355  /*! \brief 设置要读取的单个行组
356  * \param row_groups 行组索引列表
357  * \return 此 builder 对象
358  */
359  parquet_reader_options_builder& row_groups(std::vector<std::vector<size_type>> row_groups)
360  {
361  options.set_row_groups(std::move(row_groups));
362  return *this;
363  }
364 
365  /*! \brief 设置应用于输出行的过滤器
366  * \param filter 作为 AST 的谓词过滤器
367  * \return 此 builder 对象
368  */
370  {
371  options.set_filter(filter);
372  return *this;
373  }
374 
377  /*! \brief 启用/禁用将字符串转换为分类类型
378  * \param val true 为启用,false 为禁用
379  * \return 此 builder 对象
380  */
382  {
383  options._convert_strings_to_categories = val;
384  return *this;
385  }
386 
389  /*! \brief 启用/禁用使用 PANDAS 元数据
390  * \param val true 为启用,false 为禁用
391  * \return 此 builder 对象
392  */
394  {
395  options._use_pandas_metadata = val;
396  return *this;
397  }
398 
401  /*! \brief 启用/禁用使用 ARROW schema
402  * \param val true 为启用,false 为禁用
403  * \return 此 builder 对象
404  */
406  {
407  options._use_arrow_schema = val;
408  return *this;
409  }
410 
416  /*! \brief 启用/禁用允许从不匹配的 Parquet 文件中读取匹配的选中列。
417  * \param val true 为启用,false 为禁用
418  * \return 此 builder 对象
419  */
421  {
422  options._allow_mismatched_pq_schemas = val;
423  return *this;
424  }
425 
428  /*! \brief 设置自定义列 schema
429  * \param val 自定义列 schema
430  * \return This builder object
431  */
432  parquet_reader_options_builder& set_column_schema(std::vector<reader_column_schema> val)
433  {
434  options._reader_column_schema = std::move(val);
435  return *this;
436  }
437 
440  /*! \brief 设置要跳过的起始行数
441  * \param val 行数
442  * \return 此 builder 对象
443  */
445  {
446  options.set_skip_rows(val);
447  return *this;
448  }
449 
452  /*! \brief 设置要读取的行数
453  * \param val 行数
454  * \return 此 builder 对象
455  */
457  {
458  options.set_num_rows(val);
459  return *this;
460  }
461 
464  /*! \brief 设置时间戳类型
465  * \param type 时间戳类型
466  * \return 此 builder 对象
467  */
469  {
470  options._timestamp_type = type;
471  return *this;
472  }
473 
473  /*! \brief 转换为 options 对象
474  * \return parquet_reader_options 对象
475  */
476  operator parquet_reader_options&&() { return std::move(options); }
477 
482  /*! \brief 构建 options 对象
483  * \return parquet_reader_options 对象
484  */
485  parquet_reader_options&& build() { return std::move(options); }
486 };
487 
502  /*! \brief 读取 Parquet 数据集并返回带元数据的表。
503  *
504  * \param options 控制读取行为的设置。
505  * \param stream 用于设备内存操作和内核启动的 CUDA 流。
506  * \param mr 用于分配返回的表及其列的设备内存资源。
507  * \return 表和元数据
508  */
510  parquet_reader_options const& options,
513 
516  /*! \brief 分块读取 Parquet 数据集。
517  */
519  public
524  /*! \brief 默认构造函数 */
526 
539  /*! \brief 带分块读取限制的构造函数。
540  *
541  * \param chunk_read_limit 每块要读取的最大字节数。
542  * \param options 控制读取行为的设置。
543  * \param stream 用于设备内存操作和内核启动的 CUDA 流。
544  * \param mr 用于分配返回的表及其列的设备内存资源。
545  */
547  std::size_t chunk_read_limit,
548  parquet_reader_options const& options,
551 
564  /*! \brief 带分块读取限制和 pass 读取限制的构造函数。
565  *
566  * \param chunk_read_limit 每块要读取的最大字节数。
567  * \param pass_read_limit 每列每 pass 要读取的最大字节数。如果在 pass 内达到 chunk_read_limit,将使用 chunk_read_limit。否则,将使用 pass_read_limit。
568  * \param options 控制读取行为的设置。
569  * \param stream 用于设备内存操作和内核启动的 CUDA 流。
570  * \param mr 用于分配返回的表及其列的设备内存资源。
571  */
573  std::size_t chunk_read_limit,
574  std::size_t pass_read_limit,
575  parquet_reader_options const& options,
578 
578  /*! \brief 析构函数 */
580 
585  /*! \brief 如果还有更多块可读,则返回 true。
586  * \return 如果还有更多块可读,则为 true。
587  */
588  [[nodiscard]] bool has_next() const;
589 
598  /*! \brief 从 Parquet 数据集中读取下一块。
599  * \return 带元数据的表
600  */
601  [[nodiscard]] table_with_metadata read_chunk() const;
602 
603  private
604  std::unique_ptr<cudf::io::parquet::detail::chunked_reader> reader;
605 };
606  // group 结束
614 /*! \brief 用于排序的列的描述 */
616  int column_idx{};
617  bool is_descending{false};
618  bool is_nulls_first{true};
619 };
620 
623 /*! \brief Parquet writer 选项 */
625  // 指定用于 writer 输出的 sink
626  sink_info _sink;
627  // 指定要使用的压缩格式
628  compression_type _compression = compression_type::SNAPPY;
629  // 指定输出文件中的统计信息级别
631  // 可选的关联元数据
632  std::optional<table_input_metadata> _metadata;
633  // 可选的页脚 key_value_metadata
634  std::vector<std::map<std::string, std::string>> _user_data;
635  // Parquet writer 可以写入 INT96 或 TIMESTAMP_MICROS。默认为 TIMESTAMP_MICROS。
636  // 如果为 true,则覆盖 _metadata 中的任何按列设置。
637  bool _write_timestamps_as_int96 = false;
638  // Parquet writer 可以将时间戳写入为 UTC
639  // 默认为 true,因为 libcudf 时间戳隐式为 UTC
640  bool _write_timestamps_as_UTC = true;
1166  BuilderT& sorting_columns(std::vector<sorting_column> sorting_columns);
1167 
1171  operator OptionsT&&();
1172 
1180  OptionsT&& build();
1181 };
1182 
1184 
1189  // Sets of columns to output
1190  table_view _table;
1191  // Partitions described as {start_row, num_rows} pairs
1192  std::vector<partition_info> _partitions;
1193  // Column chunks file paths to be set in the raw output metadata. One per output file
1194  std::vector<std::string> _column_chunks_file_paths;
1195 
1197 
1204  explicit parquet_writer_options(sink_info const& sink, table_view table);
1205 
1206  public
1213 
1223 
1230 
1236  [[nodiscard]] table_view get_table() const { return _table; }
1237 
1243  [[nodiscard]] std::vector<partition_info> const& get_partitions() const { return _partitions; }
1244 
1250  [[nodiscard]] std::vector<std::string> const& get_column_chunks_file_paths() const
1251  {
1252  return _column_chunks_file_paths;
1253  }
1254 
1261  void set_partitions(std::vector<partition_info> partitions);
1262 
1269  void set_column_chunks_file_paths(std::vector<std::string> file_paths);
1270 };
1271 
1276  : public parquet_writer_options_builder_base<parquet_writer_options_builder,
1277  parquet_writer_options> {
1278  public
1284  explicit parquet_writer_options_builder() = default;
1285 
1293 
1301  parquet_writer_options_builder& partitions(std::vector<partition_info> partitions);
1302 
1310  parquet_writer_options_builder& column_chunks_file_paths(std::vector<std::string> file_paths);
1311 };
1312 
1329 std::unique_ptr<std::vector<uint8_t>> write_parquet(
1331 
1341 std::unique_ptr<std::vector<uint8_t>> merge_row_group_metadata(
1342  std::vector<std::unique_ptr<std::vector<uint8_t>>> const& metadata_list);
1343 
1345 
1356 
1358 
1359  public
1366 
1375 };
1376 
1381  : public parquet_writer_options_builder_base<chunked_parquet_writer_options_builder,
1382  chunked_parquet_writer_options> {
1383  public
1390 
1397 };
1398 
1419  public
1426 
1440 
1453  std::vector<partition_info> const& partitions = {});
1454 
1463  std::unique_ptr<std::vector<uint8_t>> close(
1464  std::vector<std::string> const& column_chunks_file_paths = {});
1465 
1467  std::unique_ptr<parquet::detail::writer> writer;
1468 };
1469  // end of group
1471 
1472 } // namespace io
1473 } // namespace CUDF_EXPORT cudf
列中元素的逻辑数据类型的指示符。
用于将 Parquet 文件迭代读取到一系列表格的 chunked parquet reader 类,...
table_with_metadata read_chunk() const
读取给定 Parquet 文件中的行块。
bool has_next() const
检查给定文件中是否有尚未读取的数据。
chunked_parquet_reader(std::size_t chunk_read_limit, std::size_t pass_read_limit, parquet_reader_options const &options, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
分块读取器构造函数。
chunked_parquet_reader(std::size_t chunk_read_limit, parquet_reader_options const &options, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
分块读取器构造函数。
~chunked_parquet_reader()
析构函数,销毁内部读取器实例。
chunked_parquet_reader()
默认构造函数,不应使用。
用于构建 chunked_parquet_writer_options 的类。
chunked_parquet_writer_options_builder()=default
默认构造函数。
chunked_parquet_writer_options_builder(sink_info const &sink)
从 sink 构造。
parquet_chunked_writer 的设置。
static chunked_parquet_writer_options_builder builder(sink_info const &sink)
创建用于构建 chunked_parquet_writer_options 的构建器。
chunked_parquet_writer_options()=default
默认构造函数。
分块 parquet 写入器类,用于处理选项并分块写入表格。
std::unique_ptr< std::vector< uint8_t > > close(std::vector< std::string > const &column_chunks_file_paths={})
完成分块/流式写入过程。
parquet_chunked_writer()
默认构造函数,不应使用。添加此构造函数仅为满足 cython。...。
~parquet_chunked_writer()
默认析构函数。添加此析构函数是为了不泄露 detail API。
std::unique_ptr< parquet::detail::writer > writer
指向 impl writer 类的唯一指针。
parquet_chunked_writer & write(table_view const &table, std::vector< partition_info > const &partitions={})
将表格写入输出。
parquet_chunked_writer(chunked_parquet_writer_options const &options, rmm::cuda_stream_view stream=cudf::get_default_stream())
带有分块写入器选项的构造函数。
构建用于 read_parquet() 的 parquet_reader_options。
parquet_reader_options_builder & use_arrow_schema(bool val)
设置是否启用/禁用使用 arrow schema 进行读取。
parquet_reader_options_builder(source_info src)
从 source info 构造。
parquet_reader_options_builder & skip_rows(int64_t val)
设置要跳过的行数。
parquet_reader_options_builder & allow_mismatched_pq_schemas(bool val)
设置是否启用/禁用从不匹配的 Parquet 源读取匹配的投影列和过滤列...。
parquet_reader_options_builder & columns(std::vector< std::string > col_names)
设置要读取的列的名称。
parquet_reader_options_builder & timestamp_type(data_type type)
用于转换时间戳列的 timestamp_type。
parquet_reader_options_builder & use_pandas_metadata(bool val)
设置是否启用/禁用使用 pandas metadata 进行读取。
parquet_reader_options_builder()=default
默认构造函数。
parquet_reader_options_builder & row_groups(std::vector< std::vector< size_type >> row_groups)
设置要读取的单个行组向量。
parquet_reader_options_builder & set_column_schema(std::vector< reader_column_schema > val)
设置读取器元数据。
parquet_reader_options && build()
构建完成后移动 parquet_reader_options 成员。
parquet_reader_options_builder & filter(ast::expression const &filter)
设置基于 AST 的过滤器用于谓词下推。
parquet_reader_options_builder & num_rows(size_type val)
设置要读取的行数。
parquet_reader_options_builder & convert_strings_to_categories(bool val)
设置是否启用/禁用将字符串转换为 categorical 类型。
read_parquet() 的设置。
data_type get_timestamp_type() const
返回用于转换时间戳列的时间戳类型。
parquet_reader_options()=default
默认构造函数。
static parquet_reader_options_builder builder(source_info src)
创建将构建 parquet_reader_options 的 parquet_reader_options_builder。
void enable_allow_mismatched_pq_schemas(bool val)
设置是否启用/禁用从不匹配的 Parquet 源读取匹配的投影列和过滤列...。
void set_skip_rows(int64_t val)
设置要跳过的行数。
void set_columns(std::vector< std::string > col_names)
设置要读取的列的名称。
void enable_convert_strings_to_categories(bool val)
设置是否启用/禁用将字符串转换为 categorical 类型。
std::optional< std::vector< reader_column_schema > > get_column_schema() const
返回可选的元数据树。
source_info const & get_source() const
返回 source info。
auto const & get_row_groups() const
返回要读取的单个行组列表。
std::optional< size_type > const & get_num_rows() const
返回要读取的行数。
void set_row_groups(std::vector< std::vector< size_type >> row_groups)
设置要读取的单个行组向量。
void set_num_rows(size_type val)
设置要读取的行数。
auto const & get_columns() const
如果已设置,则返回要读取的列的名称。
void set_timestamp_type(data_type type)
设置用于转换时间戳列的 timestamp_type。
bool is_enabled_convert_strings_to_categories() const
根据是否应将字符串转换为 categorical 类型返回 true/false。
void enable_use_pandas_metadata(bool val)
设置是否启用/禁用使用 pandas metadata 进行读取。
void enable_use_arrow_schema(bool val)
设置是否启用/禁用使用 arrow schema 进行读取。
bool is_enabled_use_pandas_metadata() const
根据读取时是否使用 pandas metadata 返回 true/false。
bool is_enabled_allow_mismatched_pq_schemas() const
根据是否从不匹配的源 Parquet 文件读取匹配的投影列和过滤列返回 true/false...。
void set_column_schema(std::vector< reader_column_schema > val)
设置读取器列 schema。
bool is_enabled_use_arrow_schema() const
根据读取时是否使用 arrow schema 返回 true/false。
void set_filter(ast::expression const &filter)
设置基于 AST 的过滤器用于谓词下推。
auto const & get_filter() const
返回基于 AST 的过滤器用于谓词下推。
int64_t get_skip_rows() const
返回从开始跳过的行数。
write_parquet() 和 parquet_chunked_writer 的基础设置。
void enable_utc_timestamps(bool val)
设置将时间戳写入为 UTC 的偏好。如果设置为 true,则将时间戳写入为 UTC。
void enable_write_v2_headers(bool val)
设置 V2 页头偏好。如果设置为 true,则写入 V2 页头。
auto const & get_sorting_columns() const
返回 sorting_columns。
auto get_row_group_size_bytes() const
返回最大行组大小(字节)。
bool is_enabled_int96_timestamps() const
如果时间戳将写入为 INT96,则返回 true。
void set_metadata(table_input_metadata metadata)
设置元数据。
void set_row_group_size_rows(size_type size_rows)
设置最大行组大小(行数)。
parquet_writer_options_base(sink_info sink)
从 sink 构造。
void set_stats_level(statistics_freq sf)
设置统计级别。
auto get_row_group_size_rows() const
返回最大行组大小(行数)。
parquet_writer_options_base()=default
默认构造函数。
void set_max_page_size_bytes(size_t size_bytes)
设置最大未压缩页大小(字节)。
void set_sorting_columns(std::vector< sorting_column > sorting_columns)
设置排序列。
auto is_enabled_write_arrow_schema() const
如果将写入 arrow schema,则返回 true。
auto is_enabled_write_v2_headers() const
如果应写入 V2 页头,则返回 true。
void set_dictionary_policy(dictionary_policy policy)
设置字典使用策略。
auto get_max_page_size_bytes() const
返回最大未压缩页大小(字节)。
void set_max_dictionary_size(size_t size_bytes)
设置最大字典大小(字节)。
compression_type get_compression() const
返回使用的压缩格式。
auto get_max_dictionary_size() const
返回最大字典大小(字节)。
void set_compression(compression_type compression)
设置压缩类型。
dictionary_policy get_dictionary_policy() const
返回字典使用策略。
void set_compression_statistics(std::shared_ptr< writer_compression_statistics > comp_stats)
设置指向输出压缩统计信息的指针。
std::shared_ptr< writer_compression_statistics > get_compression_statistics() const
返回指向用户提供的压缩统计信息的共享指针。
void set_max_page_size_rows(size_type size_rows)
设置最大页大小(行数)。
auto get_max_page_fragment_size() const
返回最大页片段大小(行数)。
void set_key_value_metadata(std::vector< std::map< std::string, std::string >> metadata)
设置元数据。
void set_max_page_fragment_size(size_type size_rows)
设置最大页片段大小(行数)。
void enable_write_arrow_schema(bool val)
设置写入 arrow schema 的偏好。如果设置为 true,则写入 arrow schema。
auto is_enabled_utc_timestamps() const
如果时间戳将写入为 UTC,则返回 true。
void set_row_group_size_bytes(size_t size_bytes)
设置最大行组大小(字节)。
void enable_int96_timestamps(bool req)
设置时间戳写入偏好。如果为 true,则写入 INT96 时间戳;如果...。
statistics_freq get_stats_level() const
返回输出文件中请求的统计信息级别。
std::vector< std::map< std::string, std::string > > const & get_key_value_metadata() const
返回键值 footer 元数据信息。
auto const & get_metadata() const
返回关联的元数据。
auto get_max_page_size_rows() const
返回最大页大小(行数)。
auto get_column_index_truncate_length() const
返回列索引中 min 或 max 值的最大长度(字节)。
void set_column_index_truncate_length(int32_t size_bytes)
设置列索引中 min 或 max 值的最大长度(字节)。
sink_info const & get_sink() const
返回 sink info。
Parquet options 构建器的基类。
BuilderT & compression(compression_type compression)
设置压缩类型。
BuilderT & key_value_metadata(std::vector< std::map< std::string, std::string >> metadata)
设置键值 footer 元数据。
OptionsT & get_options()
返回正在构建的 options 对象的引用。
BuilderT & utc_timestamps(bool enabled)
如果时间戳要写入为 UTC,则设置为 true。
BuilderT & max_dictionary_size(size_t val)
设置最大字典大小(字节)。
BuilderT & max_page_size_bytes(size_t val)
设置最大未压缩页大小(字节)。
OptionsT && build()
构建完成后移动 options 成员。
BuilderT & stats_level(statistics_freq sf)
设置统计级别。
BuilderT & column_index_truncate_length(int32_t val)
设置列索引中 min 和 max 值的所需最大大小(字节)。
BuilderT & compression_statistics(std::shared_ptr< writer_compression_statistics > const &comp_stats)
设置指向输出压缩统计信息的指针。
BuilderT & metadata(table_input_metadata metadata)
设置元数据。
BuilderT & dictionary_policy(enum dictionary_policy val)
设置字典使用策略。
parquet_writer_options_builder_base(OptionsT options)
从 options 构造。
BuilderT & int96_timestamps(bool enabled)
设置是否写入 int96 时间戳。
BuilderT & row_group_size_bytes(size_t val)
设置最大行组大小(字节)。
BuilderT & sorting_columns(std::vector< sorting_column > sorting_columns)
设置列排序元数据。
BuilderT & write_arrow_schema(bool enabled)
如果要写入 arrow schema,则设置为 true。
parquet_writer_options_builder_base()=default
默认构造函数。
BuilderT & write_v2_headers(bool enabled)
如果要写入 V2 页头,则设置为 true。
BuilderT & max_page_fragment_size(size_type val)
设置最大页片段大小(行数)。
BuilderT & row_group_size_rows(size_type val)
设置输出行组中的最大行数。
BuilderT & max_page_size_rows(size_type val)
设置最大页大小(行数)。仅计算顶层行,忽略任何嵌套。...。
用于构建 parquet_writer_options 的类。
parquet_writer_options_builder(sink_info const &sink, table_view const &table)
从 sink 和 table 构造。
parquet_writer_options_builder()=default
默认构造函数。
parquet_writer_options_builder & partitions(std::vector< partition_info > partitions)
在 parquet_writer_options 中设置分区。
parquet_writer_options_builder & column_chunks_file_paths(std::vector< std::string > file_paths)
设置要在原始输出元数据中设置的列块文件路径。
write_parquet() 的设置。
void set_partitions(std::vector< partition_info > partitions)
设置分区。
static parquet_writer_options_builder builder(sink_info const &sink, table_view const &table)
创建用于创建 parquet_writer_options 的构建器。
parquet_writer_options()=default
默认构造函数。
std::vector< std::string > const & get_column_chunks_file_paths() const
返回要在原始输出元数据中设置的列块文件路径。
table_view get_table() const
返回 table_view。
void set_column_chunks_file_paths(std::vector< std::string > file_paths)
设置要在原始输出元数据中设置的列块文件路径。
static parquet_writer_options_builder builder()
创建用于创建 parquet_writer_options 的构建器。
std::vector< partition_info > const & get_partitions() const
返回分区。
一组大小相同的 cudf::column_view。
一组大小相同的 cudf::column。
定义: table.hpp:40
rmm::cuda_stream_view const get_default_stream()
获取当前默认流。
constexpr size_type default_row_group_size_rows
每行组 1 百万行
constexpr int32_t default_column_index_truncate_length
截断为 64 字节
constexpr size_t default_row_group_size_bytes
每行组无限字节。
constexpr size_type default_max_page_fragment_size
每页片段 5000 行
constexpr size_t default_max_dictionary_size
1MB 字典大小
table_with_metadata read_parquet(parquet_reader_options const &options, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
将 Parquet 数据集读取到一组列中。
constexpr size_t default_max_page_size_bytes
每页 512KB
constexpr size_type default_max_page_size_rows
每页 20k 行
statistics_freq
parquet/orc 写入器的列统计信息粒度类型。
dictionary_policy
控制 parquet 写入器是否使用字典编码。
compression_type
压缩算法。
@ STATISTICS_ROWGROUP
每行组列统计信息。
@ ADAPTIVE
在不影响压缩时使用字典。
std::unique_ptr< std::vector< uint8_t > > merge_row_group_metadata(std::vector< std::unique_ptr< std::vector< uint8_t >>> const &metadata_list)
合并之前由 write_parquet 创建的多个原始元数据 blob 到一个元数据中...。
std::unique_ptr< std::vector< uint8_t > > write_parquet(parquet_writer_options const &options, rmm::cuda_stream_view stream=cudf::get_default_stream())
将一组列写入 parquet 格式。
rmm::device_async_resource_ref get_current_device_resource_ref()
获取当前设备内存资源引用。
cuda::mr::async_resource_ref< cuda::mr::device_accessible > device_async_resource_ref
int32_t size_type
列和表的行索引类型。
定义: types.hpp:95
cuDF-IO API 类型定义
cuDF 接口
可以求值以返回值的一般表达式。
写入接口的目标信息。
用于描述列排序元数据的结构体。
读取接口的源信息。
io 读取器用于按值返回元数据的带表格元数据的表格。
(mutable)_table_view 的类定义
libcudf 的类型声明。