orc.hpp
前往此文件的文档。
1 /*
2  * Copyright (c) 2020-2025, 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/io/detail/orc.hpp>
20 #include <cudf/io/types.hpp>
22 #include <cudf/types.hpp>
23 #include <cudf/utilities/export.hpp>
25 
26 #include <memory>
27 #include <optional>
28 #include <string>
29 #include <unordered_map>
30 #include <utility>
31 #include <vector>
32 
33 namespace CUDF_EXPORT cudf {
34 namespace io {
41 constexpr size_t default_stripe_size_bytes = 64 * 1024 * 1024;
42 constexpr size_type default_stripe_size_rows = 1000000;
44 
48 /**
49  * @brief ORC reader options builder.
50  * @ingroup io_readers
51  */
52 
54  source_info _source;
55 
56  // 要读取的列名;`nullopt` 表示所有列
57  std::optional<std::vector<std::string>> _columns;
58 
59  // 要读取的单独条带列表(如果为空则忽略)
60  std::vector<std::vector<size_type>> _stripes;
61  // 从开头跳过的行数
62  int64_t _skip_rows = 0;
63  // 要读取的行数;`nullopt` 表示所有行
64  std::optional<int64_t> _num_rows;
65 
66  // 是否使用行索引加速读取
67  bool _use_index = true;
68 
69  // 是否使用 numpy 兼容的数据类型
70  bool _use_np_dtypes = true;
71  // 将时间戳列转换为特定类型
72  data_type _timestamp_type{type_id::EMPTY};
73 
74  // 应读取为 Decimal128 的列
75  std::vector<std::string> _decimal128_columns;
76 
78 
84  /// @brief Construct an ORC reader options with a source.
85  /// @param src The source to read from.
86  explicit orc_reader_options(source_info src) : _source{std::move(src)} {}
87 
88  public
92  /// @brief Default constructor.
93  orc_reader_options() = default;
94 
100  /// @brief Return a builder object to create the options.
101  /// @param src The source to read from.
102  /// @return orc_reader_options_builder The builder object.
104 
107  /// @brief Get the source.
108  [[nodiscard]] source_info const& get_source() const { return _source; }
109 
114  /// @brief Get the requested column names.
115  [[nodiscard]] auto const& get_columns() const { return _columns; }
116 
121  /// @brief Get the requested stripe list.
122  [[nodiscard]] auto const& get_stripes() const { return _stripes; }
123 
128  /// @brief Get the number of rows to skip from the start.
129  [[nodiscard]] int64_t get_skip_rows() const { return _skip_rows; }
130 
136  /// @brief Get the number of rows to read.
137  /// nullopt implies reading till the end.
138  [[nodiscard]] std::optional<int64_t> const& get_num_rows() const { return _num_rows; }
139 
143  /// @brief Whether row index is used for speed-up.
144  [[nodiscard]] bool is_enabled_use_index() const { return _use_index; }
145 
150  /// @brief Whether numpy-compatible dtypes are used.
151  /// This option will be removed in a future release.
152  [[nodiscard]] bool is_enabled_use_np_dtypes() const { return _use_np_dtypes; }
153 
157  /// @brief Get the timestamp data type.
158  [[nodiscard]] data_type get_timestamp_type() const { return _timestamp_type; }
159 
164  /// @brief Get the names of columns to be read as Decimal128.
165  {
166  return _decimal128_columns;
167  }
168 
169  // Setters
170 
176  /// @brief Set the names of columns to read; `nullopt` is all.
177  /// @param col_names The list of column names to read.
178  void set_columns(std::vector<std::string> col_names) { _columns = std::move(col_names); }
179 
188  /// @brief Set the list of individual stripes to read (ignored if empty).
189  /// Only one of `set_stripes`, `set_skip_rows`, or `set_num_rows` can be specified.
190  /// @param stripes The list of individual stripes to read.
191  void set_stripes(std::vector<std::vector<size_type>> stripes)
192  {
193  CUDF_EXPECTS(stripes.empty() or (_skip_rows == 0), "无法同时设置条带和跳过的行数");
194  CUDF_EXPECTS(stripes.empty() or not _num_rows.has_value(),
195  "无法同时设置条带和行数");
196  _stripes = std::move(stripes);
197  }
198 
204  /// @brief Set the number of rows to skip from the start.
205  /// @param rows The number of rows to skip.
206  void set_skip_rows(int64_t rows)
207  {
208  CUDF_EXPECTS(rows >= 0, "skip_rows 不能为负");
209  CUDF_EXPECTS(rows == 0 or _stripes.empty(), "无法同时设置 skip_rows 和条带");
210  _skip_rows = rows;
211  }
212 
219  /// @brief Set the number of rows to read.
220  /// `nullopt` implies reading till the end.
221  /// @param nrows The number of rows to read.
222  void set_num_rows(int64_t nrows)
223  {
224  CUDF_EXPECTS(nrows >= 0, "num_rows 不能为负");
225  CUDF_EXPECTS(_stripes.empty(), "无法同时设置 num_rows 和条带");
226  _num_rows = nrows;
227  }
228 
231  /// @brief Enable or disable row index usage.
232  /// @param use Enable if `true`, disable if `false`.
233  void enable_use_index(bool use) { _use_index = use; }
234 
238  /// @brief Enable or disable numpy-compatible dtypes.
239  /// This option will be removed in a future release.
240  void enable_use_np_dtypes(bool use) { _use_np_dtypes = use; }
241 
245  /// @brief Set the timestamp data type.
246  /// @param type The desired timestamp type.
247  void set_timestamp_type(data_type type) { _timestamp_type = type; }
248 
252  /// @brief Set the names of columns to be read as Decimal128.
253  /// @param val The list of column names.
254  void set_decimal128_columns(std::vector<std::string> val)
255  {
256  _decimal128_columns = std::move(val);
257  }
258 };
259 
262  orc_reader_options options;
263 
264  public
270  /// @brief Default constructor.
271  explicit orc_reader_options_builder() = default;
272 
277  /// @brief Construct with a source.
278  /// @param src The source to read from.
279  explicit orc_reader_options_builder(source_info src) : options{std::move(src)} {}
280 
285  /// @brief Set the names of columns to read.
286  /// @param col_names The list of column names to read.
287  orc_reader_options_builder& columns(std::vector<std::string> col_names)
288  {
289  options._columns = std::move(col_names);
290  return *this;
291  }
292 
297  /// @brief Set the list of individual stripes to read (ignored if empty).
298  /// @param stripes The list of individual stripes to read.
299  orc_reader_options_builder& stripes(std::vector<std::vector<size_type>> stripes)
300  {
301  options.set_stripes(std::move(stripes));
302  return *this;
303  }
304 
309  /// @brief Set the number of rows to skip from the start.
310  /// @param rows The number of rows to skip.
312  {
313  options.set_skip_rows(rows);
314  return *this;
315  }
316 
321  /// @brief Set the number of rows to read.
322  /// @param nrows The number of rows to read.
323  orc_reader_options_builder& num_rows(int64_t nrows)
324  {
325  options.set_num_rows(nrows);
326  return *this;
327  }
328 
333  /// @brief Enable or disable row index usage.
334  /// @param use Enable if `true`, disable if `false`.
336  {
337  options._use_index = use;
338  return *this;
339  }
340 
345  /// @brief Enable or disable numpy-compatible dtypes.
346  /// This option will be removed in a future release.
347  /// @param use Enable if `true`, disable if `false`.
349  {
350  options._use_np_dtypes = use;
351  return *this;
352  }
353 
357  /// @brief Set the timestamp data type.
358  /// @param type The desired timestamp type.
360  {
361  options._timestamp_type = type;
362  return *this;
363  }
364 
369  /// @brief Set the names of columns to be read as Decimal128.
370  /// @param val The list of column names.
371  orc_reader_options_builder& decimal128_columns(std::vector<std::string> val)
372  {
373  options._decimal128_columns = std::move(val);
374  return *this;
375  }
376 
378  /// @brief Implicit conversion to orc_reader_options.
379  operator orc_reader_options&&() { return std::move(options); }
380 
387  /// @brief Explicit conversion to orc_reader_options.
388  /// @return The orc reader options object.
389  orc_reader_options&& build() { return std::move(options); }
390 };
391 
407 /// @brief Read a dataset from an ORC file/buffer into a cudf table.
408 ///
409 /// @param options Settings for the read operation.
410 /// @param stream CUDA stream used for device memory operations and kernel launches.
411 /// @param mr Device memory resource to use for device memory allocation.
412 /// @return The table and any metadata.
414  orc_reader_options const& options,
417 
421 /// @brief ORC chunked reader class.
422 class chunked_orc_reader {
423  public
428  /// @brief Default constructor (disabled).
429  chunked_orc_reader() = delete;
430 
474  /// @brief Constructor for chunked ORC reader.
475  ///
476  /// @param chunk_read_limit Minimum size, in bytes, of dataset chunk to be read at once.
477  /// Actual chunks can be larger due to minimum stripe/rowgroup size.
478  /// @param pass_read_limit Minimum size, in bytes, of dataset part to be read in one pass.
479  /// @param output_row_granularity Number of rows to read as a single unit (row group).
480  /// Has to be multiple of 1024 or 10000 rows typically. Default is 10000.
481  /// @param options Settings for the read operation.
482  /// @param stream CUDA stream used for device memory operations and kernel launches.
483  /// @param mr Device memory resource to use for device memory allocation.
484  explicit chunked_orc_reader(
485  std::size_t chunk_read_limit,
486  std::size_t pass_read_limit,
487  size_type output_row_granularity,
488  orc_reader_options const& options,
491 
496  /// @brief Constructor for chunked ORC reader with default output row granularity.
497  ///
498  /// @param chunk_read_limit Minimum size, in bytes, of dataset chunk to be read at once.
499  /// Actual chunks can be larger due to minimum stripe/rowgroup size.
500  /// @param pass_read_limit Minimum size, in bytes, of dataset part to be read in one pass.
501  /// @param options Settings for the read operation.
502  /// @param stream CUDA stream used for device memory operations and kernel launches.
503  /// @param mr Device memory resource to use for device memory allocation.
504  explicit chunked_orc_reader(
505  std::size_t chunk_read_limit,
506  std::size_t pass_read_limit,
507  orc_reader_options const& options,
510 
515  /// @brief Constructor for chunked ORC reader with default pass read limit and output row
516  /// granularity.
517  /// @param chunk_read_limit Minimum size, in bytes, of dataset chunk to be read at once.
518  /// Actual chunks can be larger due to minimum stripe/rowgroup size.
519  /// @param options Settings for the read operation.
520  /// @param stream CUDA stream used for device memory operations and kernel launches.
521  /// @param mr Device memory resource to use for device memory allocation.
522  explicit chunked_orc_reader(
523  std::size_t chunk_read_limit,
524  orc_reader_options const& options,
527 
528  /// @brief Destructor for chunked ORC reader.
529 
530  /// @brief Check if there is more data to read.
532 
538  /// @return bool True if there is more data to read, false otherwise.
539  [[nodiscard]] bool has_next() const;
540 
544  /// @brief Read the next chunk from the dataset.
545  /// @return The table and any metadata for the next chunk.
546  [[nodiscard]] table_with_metadata read_chunk() const;
547 
548  private
549  std::unique_ptr<cudf::io::orc::detail::chunked_reader> reader;
550 };
551  // end of group
552 
560 /**
561  * @brief ORC writer options builder.
562  * @ingroup io_writers
563  */
564 
571 /// @brief Statistics granularity values for ORC writers.
572 /// These are deprecated in favor of the general `statistics_freq`.
573 static constexpr statistics_freq ORC_STATISTICS_STRIPE = statistics_freq::STATISTICS_ROWGROUP;
574 static constexpr statistics_freq ORC_STATISTICS_ROW_GROUP = statistics_freq::STATISTICS_PAGE;
575 
577 /// @brief ORC writer options.
578 class orc_writer_options {
579  // 指定写入器输出使用的接收器
580  sink_info _sink;
581  // 指定要使用的压缩格式
582  compression_type _compression = compression_type::SNAPPY;
583  // 指定统计信息收集的频率
584  statistics_freq _stats_freq = ORC_STATISTICS_ROW_GROUP;
585  // 每个条带的最大大小(除非小于单个行组)
586  size_t _stripe_size_bytes = default_stripe_size_bytes;
587  // 条带中的最大行数(除非小于单个行组)
588  size_type _stripe_size_rows = default_stripe_size_rows;
589  // 行索引步长(每个行组中的最大行数)
590  size_type _row_index_stride = default_row_index_stride;
591  // 要输出的列集
592  table_view _table;
593  // 可选的关联元数据
594  std::optional<table_input_metadata> _metadata;
595  // 可选的页脚 key_value_metadata
596  std::map<std::string, std::string> _user_data;
597  // 可选的压缩统计信息
598  std::shared_ptr<writer_compression_statistics> _compression_stats;
599  // 指定字符串字典是否应按字母顺序排序
600  bool _enable_dictionary_sort = true;
601 
603 
609  /// @brief Construct an ORC writer options with a sink and table.
610  /// @param sink The sink to write to.
611  /// @param table The table to write.
613  : _sink(std::move(sink)), _table(std::move(table))
614  {
615  }
616 
617  public
620  /// @brief Default constructor.
621  explicit orc_writer_options() = default;
622 
630  /// @brief Return a builder object to create the options.
631  /// @param sink The sink to write to.
632  /// @param table The table to write.
633  /// @return orc_writer_options_builder The builder object.
634  static orc_writer_options_builder builder(sink_info const& sink, table_view const& table);
635 
637  /// @brief Get the sink.
638  [[nodiscard]] sink_info const& get_sink() const { return _sink; }
639 
644  /// @brief Get the compression type.
645  [[nodiscard]] compression_type get_compression() const { return _compression; }
646 
651  /// @brief Whether statistics collection is enabled.
652  {
653  return _stats_freq != statistics_freq::STATISTICS_NONE;
654  }
655 
661  /// @brief Get the frequency of statistics collection.
662  [[nodiscard]] statistics_freq get_statistics_freq() const { return _stats_freq; }
663 
668  /// @brief Get the maximum size of each stripe (unless smaller than a single row group).
669  [[nodiscard]] auto get_stripe_size_bytes() const { return _stripe_size_bytes; }
670 
675  /// @brief Get the maximum number of rows in stripe (unless smaller than a single row group).
676  [[nodiscard]] auto get_stripe_size_rows() const { return _stripe_size_rows; }
677 
682  /// @brief Get the row index stride (maximum number of rows in each row group).
683  {
684  auto const unaligned_stride = std::min(_row_index_stride, get_stripe_size_rows());
685  return unaligned_stride - unaligned_stride % 8;
686  }
687 
693  /// @brief Get the table to write.
694  [[nodiscard]] table_view get_table() const { return _table; }
695 
700  /// @brief Get the optional associated metadata.
701  [[nodiscard]] auto const& get_metadata() const { return _metadata; }
702 
707  /// @brief Get optional key_value_metadata.
708  {
709  return _user_data;
710  }
711 
717  /// @brief Get the optional compression statistics.
718  {
719  return _compression_stats;
720  }
721 
727  /// @brief Get whether string dictionaries should be alphabetically sorted.
728  [[nodiscard]] bool get_enable_dictionary_sort() const { return _enable_dictionary_sort; }
729 
730  // Setters
731 
736  /// @brief Set the compression type.
737  /// @param comp The compression type.
739  {
740  _compression = comp;
741  if (comp == compression_type::AUTO) { _compression = compression_type::SNAPPY; }
742  }
743 
752  /// @brief Enable or disable statistics collection and set frequency.
753  /// @param val Statistics collection frequency.
754  void enable_statistics(statistics_freq val) { _stats_freq = val; }
755 
1039  size_type _stripe_size_rows = default_stripe_size_rows;
1040  // 行索引步长(每个行组中的最大行数)
1041  size_type _row_index_stride = default_row_index_stride;
1042  // 可选的相关元数据
1043  std::optional<table_input_metadata> _metadata;
1044  // 可选的页脚键值元数据
1045  std::map<std::string, std::string> _user_data;
1046  // 可选的压缩统计信息
1047  std::shared_ptr<writer_compression_statistics> _compression_stats;
1048  // 指定字符串字典是否应按字母排序
1049  bool _enable_dictionary_sort = true;
1050 
1052 
1058  chunked_orc_writer_options(sink_info sink) : _sink(std::move(sink)) {}
1059 
1060  public
1066  explicit chunked_orc_writer_options() = default;
1067 
1076 
1082  [[nodiscard]] sink_info const& get_sink() const { return _sink; }
1083 
1089  [[nodiscard]] compression_type get_compression() const { return _compression; }
1090 
1096  [[nodiscard]] statistics_freq get_statistics_freq() const { return _stats_freq; }
1097 
1103  [[nodiscard]] auto get_stripe_size_bytes() const { return _stripe_size_bytes; }
1104 
1110  [[nodiscard]] auto get_stripe_size_rows() const { return _stripe_size_rows; }
1111 
1117  [[nodiscard]] auto get_row_index_stride() const
1118  {
1119  auto const unaligned_stride = std::min(_row_index_stride, get_stripe_size_rows());
1120  return unaligned_stride - unaligned_stride % 8;
1121  }
1122 
1128  [[nodiscard]] auto const& get_metadata() const { return _metadata; }
1129 
1135  [[nodiscard]] std::map<std::string, std::string> const& get_key_value_metadata() const
1136  {
1137  return _user_data;
1138  }
1139 
1145  [[nodiscard]] std::shared_ptr<writer_compression_statistics> get_compression_statistics() const
1146  {
1147  return _compression_stats;
1148  }
1149 
1155  [[nodiscard]] bool get_enable_dictionary_sort() const { return _enable_dictionary_sort; }
1156 
1157  // Setter 方法
1158 
1165  {
1166  _compression = comp;
1167  if (comp == compression_type::AUTO) { _compression = compression_type::SNAPPY; }
1168  }
1169 
1180  void enable_statistics(statistics_freq val) { _stats_freq = val; }
1181 
1189  void set_stripe_size_bytes(size_t size_bytes)
1190  {
1191  CUDF_EXPECTS(size_bytes >= 64 << 10, "最小条带大小为 64KB");
1192  _stripe_size_bytes = size_bytes;
1193  }
1194 
1206  {
1207  CUDF_EXPECTS(size_rows >= 512, "最大条带大小不能小于 512");
1208  _stripe_size_rows = size_rows;
1209  }
1210 
1221  {
1222  CUDF_EXPECTS(stride >= 512, "行索引步长不能小于 512");
1223  _row_index_stride = stride;
1224  }
1225 
1231  void metadata(table_input_metadata meta) { _metadata = std::move(meta); }
1232 
1238  void set_key_value_metadata(std::map<std::string, std::string> metadata)
1239  {
1240  _user_data = std::move(metadata);
1241  }
1242 
1248  void set_compression_statistics(std::shared_ptr<writer_compression_statistics> comp_stats)
1249  {
1250  _compression_stats = std::move(comp_stats);
1251  }
1252 
1258  void set_enable_dictionary_sort(bool val) { _enable_dictionary_sort = val; }
1259 };
1260 
1266 
1267  public
1274 
1280  explicit chunked_orc_writer_options_builder(sink_info const& sink) : options{sink} {}
1281 
1289  {
1290  options.set_compression(comp);
1291  return *this;
1292  }
1293 
1306  {
1307  options._stats_freq = val;
1308  return *this;
1309  }
1310 
1318  {
1319  options.set_stripe_size_bytes(val);
1320  return *this;
1321  }
1322 
1330  {
1331  options.set_stripe_size_rows(val);
1332  return *this;
1333  }
1334 
1342  {
1343  options.set_row_index_stride(val);
1344  return *this;
1345  }
1346 
1354  {
1355  options._metadata = std::move(meta);
1356  return *this;
1357  }
1358 
1366  std::map<std::string, std::string> metadata)
1367  {
1368  options._user_data = std::move(metadata);
1369  return *this;
1370  }
1371 
1379  std::shared_ptr<writer_compression_statistics> const& comp_stats)
1380  {
1381  options._compression_stats = comp_stats;
1382  return *this;
1383  }
1384 
1392  {
1393  options._enable_dictionary_sort = val;
1394  return *this;
1395  }
1396 
1400  operator chunked_orc_writer_options&&() { return std::move(options); }
1401 
1409  chunked_orc_writer_options&& build() { return std::move(options); }
1410 };
1411 
1434  public
1440 
1445 
1454 
1462 
1466  void close();
1467 
1469  std::unique_ptr<orc::detail::writer> writer;
1470 };
1471  // 组结束
1473 } // 命名空间 io
1474 } // 命名空间 CUDF_EXPORT cudf
列中元素的逻辑数据类型指示符。
定义于: types.hpp:243
用于将 ORC 文件迭代读取到一系列表中的分块 ORC 读取器类,...
定义于: orc.hpp:421
chunked_orc_reader(std::size_t chunk_read_limit, orc_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())
根据输出大小限制以及其他 ORC 读取器选项构造读取器。
bool has_next() const
检查给定数据源中是否有尚未读取的数据。
chunked_orc_reader(std::size_t chunk_read_limit, std::size_t pass_read_limit, orc_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())
根据输入/输出大小限制以及其他 ORC 读取器选项构造读取器。
~chunked_orc_reader()
析构函数,销毁内部读取器实例。
table_with_metadata read_chunk() const
读取给定数据源中的一行数据块。
chunked_orc_reader(std::size_t chunk_read_limit, std::size_t pass_read_limit, size_type output_row_granularity, orc_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())
根据输入/输出大小限制、输出行粒度以及其他 ORC 读取...
chunked_orc_reader()
默认构造函数,不应使用。
构建用于 write_orc_chunked() 的设置。
定义于: orc.hpp:1264
chunked_orc_writer_options_builder & enable_dictionary_sort(bool val)
设置字符串字典是否应排序。
定义于: orc.hpp:1391
chunked_orc_writer_options && build()
构建完成后移动 chunked_orc_writer_options 成员。
定义于: orc.hpp:1409
chunked_orc_writer_options_builder & stripe_size_bytes(size_t val)
设置最大条带大小(以字节为单位)。
定义于: orc.hpp:1317
chunked_orc_writer_options_builder()=default
默认构造函数。
chunked_orc_writer_options_builder & stripe_size_rows(size_type val)
设置输出条带中的最大行数。
定义于: orc.hpp:1329
chunked_orc_writer_options_builder & compression_statistics(std::shared_ptr< writer_compression_statistics > const &comp_stats)
设置指向输出压缩统计信息的指针。
定义于: orc.hpp:1378
chunked_orc_writer_options_builder & key_value_metadata(std::map< std::string, std::string > metadata)
设置键值页脚元数据。
定义于: orc.hpp:1365
chunked_orc_writer_options_builder & compression(compression_type comp)
设置压缩类型。
定义于: orc.hpp:1288
chunked_orc_writer_options_builder & metadata(table_input_metadata meta)
设置相关元数据。
定义于: orc.hpp:1353
chunked_orc_writer_options_builder(sink_info const &sink)
从 sink 和表构造。
定义于: orc.hpp:1280
chunked_orc_writer_options_builder & enable_statistics(statistics_freq val)
选择统计信息收集的粒度。
定义于: orc.hpp:1305
chunked_orc_writer_options_builder & row_index_stride(size_type val)
设置行索引步长。
定义于: orc.hpp:1341
用于 write_orc_chunked() 的设置。
定义于: orc.hpp:1029
void set_stripe_size_bytes(size_t size_bytes)
设置最大条带大小(以字节为单位)。
定义于: orc.hpp:1189
chunked_orc_writer_options()=default
默认构造函数。
void metadata(table_input_metadata meta)
设置相关元数据。
定义于: orc.hpp:1231
void set_key_value_metadata(std::map< std::string, std::string > metadata)
设置键值页脚元数据。
定义于: orc.hpp:1238
void set_compression_statistics(std::shared_ptr< writer_compression_statistics > comp_stats)
设置指向输出压缩统计信息的指针。
定义于: orc.hpp:1248
sink_info const & get_sink() const
返回 sink info。
定义于: orc.hpp:1082
auto get_stripe_size_rows() const
返回最大条带大小(以行为单位)。
定义于: orc.hpp:1110
auto get_row_index_stride() const
返回行索引步长。
定义于: orc.hpp:1117
void set_row_index_stride(size_type stride)
设置行索引步长。
定义于: orc.hpp:1220
statistics_freq get_statistics_freq() const
返回统计信息收集的粒度。
定义于: orc.hpp:1096
void set_compression(compression_type comp)
设置压缩类型。
定义于: orc.hpp:1164
std::map< std::string, std::string > const & get_key_value_metadata() const
返回键值页脚元信息。
定义于: orc.hpp:1135
void set_enable_dictionary_sort(bool val)
设置字符串字典是否应排序。
定义于: orc.hpp:1258
auto const & get_metadata() const
返回相关元数据。
定义于: orc.hpp:1128
bool get_enable_dictionary_sort() const
返回字符串字典是否应排序。
定义于: orc.hpp:1155
compression_type get_compression() const
返回压缩类型。
定义于: orc.hpp:1089
void set_stripe_size_rows(size_type size_rows)
设置最大条带大小(以行为单位)。
定义于: orc.hpp:1205
std::shared_ptr< writer_compression_statistics > get_compression_statistics() const
返回指向用户提供的压缩统计信息的 shared pointer。
定义于: orc.hpp:1145
auto get_stripe_size_bytes() const
返回最大条带大小(以字节为单位)。
定义于: orc.hpp:1103
void enable_statistics(statistics_freq val)
选择统计信息收集的粒度。
定义于: orc.hpp:1180
static chunked_orc_writer_options_builder builder(sink_info const &sink)
创建用于创建 chunked_orc_writer_options 的构建器。
分块 ORC 写入器类以分块/流形式写入 ORC 文件。
定义于: orc.hpp:1433
~orc_chunked_writer()
虚析构函数,添加此函数是为了防止细节类型泄露。
orc_chunked_writer()
默认构造函数,不应使用。添加此函数仅为了满足 cython。
orc_chunked_writer(chunked_orc_writer_options const &options, rmm::cuda_stream_view stream=cudf::get_default_stream())
使用分块写入器选项的构造函数。
std::unique_ptr< orc::detail::writer > writer
指向 impl 写入器类的唯一指针。
定义于: orc.hpp:1469
orc_chunked_writer & write(table_view const &table)
将表写入输出。
void close()
完成分块/流式写入过程。
构建用于 read_orc() 的设置。
定义于: orc.hpp:261
orc_reader_options_builder & use_index(bool use)
启用/禁用使用行索引来加速读取。
定义于: orc.hpp:333
orc_reader_options_builder & decimal128_columns(std::vector< std::string > val)
应读取为 128 位 Decimal 的列。
定义于: orc.hpp:369
orc_reader_options_builder & use_np_dtypes(bool use)
启用/禁用使用与 numpy 兼容的 dtype。
定义于: orc.hpp:345
orc_reader_options_builder & skip_rows(int64_t rows)
设置从开头跳过的行数。
定义于: orc.hpp:309
orc_reader_options_builder()=default
默认构造函数。
orc_reader_options_builder(source_info src)
从 source info 构造。
定义于: orc.hpp:277
orc_reader_options_builder & stripes(std::vector< std::vector< size_type >> stripes)
设置每个源要读取的各个条带列表。
定义于: orc.hpp:297
orc_reader_options_builder & num_rows(int64_t nrows)
设置要读取的行数。
定义于: orc.hpp:321
orc_reader_options_builder & columns(std::vector< std::string > col_names)
设置要读取的列的名称。
定义于: orc.hpp:285
orc_reader_options && build()
构建完成后移动 orc_reader_options 成员。
定义于: orc.hpp:387
orc_reader_options_builder & timestamp_type(data_type type)
设置时间戳列将被转换为的时间戳类型。
定义于: orc.hpp:357
用于 read_orc() 的设置。
定义于: orc.hpp:53
int64_t get_skip_rows() const
返回从开头跳过的行数。
定义于: orc.hpp:128
orc_reader_options()=default
默认构造函数。
void enable_use_np_dtypes(bool use)
启用/禁用使用与 numpy 兼容的 dtype。
定义于: orc.hpp:238
void set_num_rows(int64_t nrows)
设置要读取的行数。
定义于: orc.hpp:219
auto const & get_stripes() const
返回向量的向量,即每个输入源要读取的条带。
定义于: orc.hpp:121
void set_decimal128_columns(std::vector< std::string > val)
设置应读取为 128 位 Decimal 的列。
定义于: orc.hpp:252
void set_skip_rows(int64_t rows)
设置从开头跳过的行数。
定义于: orc.hpp:204
void enable_use_index(bool use)
启用/禁用使用行索引来加速读取。
定义于: orc.hpp:231
void set_columns(std::vector< std::string > col_names)
设置要读取的列的名称。
定义于: orc.hpp:176
void set_stripes(std::vector< std::vector< size_type >> stripes)
设置每个输入源要读取的条带列表。
定义于: orc.hpp:188
data_type get_timestamp_type() const
返回时间戳列将被转换为的时间戳类型。
定义于: orc.hpp:157
auto const & get_columns() const
返回要读取的列的名称(如果已设置)。
定义于: orc.hpp:114
static orc_reader_options_builder builder(source_info src)
创建将构建 orc_reader_options 的 orc_reader_options_builder。
std::optional< int64_t > const & get_num_rows() const
返回要读取的行数。
定义于: orc.hpp:136
source_info const & get_source() const
返回 source info。
定义于: orc.hpp:107
bool is_enabled_use_np_dtypes() const
是否使用与 numpy 兼容的 dtype。
定义于: orc.hpp:150
bool is_enabled_use_index() const
是否使用行索引来加速读取。
定义于: orc.hpp:143
std::vector< std::string > const & get_decimal128_columns() const
返回应读取为 128 位 Decimal 的列的完全限定名称。
定义于: orc.hpp:164
void set_timestamp_type(data_type type)
设置时间戳列将被转换为的时间戳类型。
定义于: orc.hpp:245
构建用于 write_orc() 的设置。
定义于: orc.hpp:843
orc_writer_options_builder & table(table_view tbl)
设置要写入输出的表。
定义于: orc.hpp:935
orc_writer_options_builder & row_index_stride(size_type val)
设置行索引步长。
定义于: orc.hpp:923
orc_writer_options_builder & enable_statistics(statistics_freq val)
选择要写入的列统计信息的粒度。
定义于: orc.hpp:887
orc_writer_options_builder & metadata(table_input_metadata meta)
设置相关元数据。
定义于: orc.hpp:947
orc_writer_options_builder(sink_info const &sink, table_view const &table)
从 sink 和表构造。
定义于: orc.hpp:860
orc_writer_options && build()
构建完成后移动 orc_writer_options 成员。
定义于: orc.hpp:1002
orc_writer_options_builder()=default
默认构造函数。
orc_writer_options_builder & key_value_metadata(std::map< std::string, std::string > metadata)
设置键值页脚元数据。
定义于: orc.hpp:959
orc_writer_options_builder & compression_statistics(std::shared_ptr< writer_compression_statistics > const &comp_stats)
设置指向输出压缩统计信息的指针。
定义于: orc.hpp:971
orc_writer_options_builder & stripe_size_rows(size_type val)
设置输出条带中的最大行数。
定义于: orc.hpp:911
orc_writer_options_builder & enable_dictionary_sort(bool val)
设置字符串字典是否应排序。
定义于: orc.hpp:984
orc_writer_options_builder & compression(compression_type comp)
设置压缩类型。
定义于: orc.hpp:870
orc_writer_options_builder & stripe_size_bytes(size_t val)
设置最大条带大小(以字节为单位)。
定义于: orc.hpp:899
用于 write_orc() 的设置。
定义于: orc.hpp:577
void enable_statistics(statistics_freq val)
选择统计信息收集的粒度。
定义于: orc.hpp:752
auto const & get_metadata() const
返回相关元数据。
定义于: orc.hpp:700
std::map< std::string, std::string > const & get_key_value_metadata() const
返回键值页脚元信息。
定义于: orc.hpp:707
std::shared_ptr< writer_compression_statistics > get_compression_statistics() const
返回指向用户提供的压缩统计信息的 shared pointer。
定义于: orc.hpp:717
bool is_enabled_statistics() const
是否启用/禁用写入列统计信息。
定义于: orc.hpp:651
auto get_stripe_size_bytes() const
返回最大条带大小(以字节为单位)。
定义于: orc.hpp:668
void set_stripe_size_rows(size_type size_rows)
设置最大条带大小(以行为单位)。
定义于: orc.hpp:777
void set_key_value_metadata(std::map< std::string, std::string > metadata)
设置元数据。
定义于: orc.hpp:817
auto get_stripe_size_rows() const
返回最大条带大小(以行为单位)。
定义于: orc.hpp:675
table_view get_table() const
返回要写入输出的表。
定义于: orc.hpp:693
void set_metadata(table_input_metadata meta)
设置相关元数据。
定义于: orc.hpp:810
statistics_freq get_statistics_freq() const
返回统计信息收集的频率。
定义于: orc.hpp:661
void set_compression_statistics(std::shared_ptr< writer_compression_statistics > comp_stats)
设置指向输出压缩统计信息的指针。
定义于: orc.hpp:827
auto get_row_index_stride() const
返回行索引步长。
定义于: orc.hpp:682
void set_table(table_view tbl)
设置要写入输出的表。
定义于: orc.hpp:803
orc_writer_options()=default
默认构造函数。
void set_compression(compression_type comp)
设置压缩类型。
定义于: orc.hpp:736
void set_enable_dictionary_sort(bool val)
设置字符串字典是否应排序。
定义于: orc.hpp:837
void set_row_index_stride(size_type stride)
设置行索引步长。
定义于: orc.hpp:792
compression_type get_compression() const
返回压缩类型。
定义于: orc.hpp:644
static orc_writer_options_builder builder(sink_info const &sink, table_view const &table)
创建用于创建 orc_writer_options 的构建器。
bool get_enable_dictionary_sort() const
返回字符串字典是否应排序。
定义于: orc.hpp:727
void set_stripe_size_bytes(size_t size_bytes)
设置最大条带大小(以字节为单位)。
定义于: orc.hpp:761
sink_info const & get_sink() const
返回 sink info。
定义于: orc.hpp:637
表的元数据。
定义于: io/types.hpp:945
一组大小相同的 cudf::column_view。
定义于: table_view.hpp:200
一组大小相同的 cudf::column。
定义于: table.hpp:40
rmm::cuda_stream_view const get_default_stream()
获取当前默认流。
constexpr size_type default_stripe_size_rows
默认 ORC 条带行数为 100 万行
定义于: orc.hpp:42
constexpr size_type default_row_index_stride
默认 ORC 行索引步长为 1 万行
定义于: orc.hpp:43
table_with_metadata read_orc(orc_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())
将 ORC 数据集读取到一组列中。
constexpr size_t default_stripe_size_bytes
默认 ORC 条带大小为 64MB
定义于: orc.hpp:41
statistics_freq
parquet/orc 写入器的列统计信息粒度类型。
定义于: io/types.hpp:96
compression_type
压缩算法。
定义于: io/types.hpp:57
@ STATISTICS_ROWGROUP
每行组的列统计信息。
定义于: io/types.hpp:98
@ STATISTICS_NONE
无列统计信息。
定义于: io/types.hpp:97
@ STATISTICS_PAGE
每页的列统计信息。
定义于: io/types.hpp:99
void write_orc(orc_writer_options const &options, rmm::cuda_stream_view stream=cudf::get_default_stream())
将一组列写入 ORC 格式。
rmm::device_async_resource_ref get_current_device_resource_ref()
获取当前设备内存资源的引用。
cuda::mr::async_resource_ref< cuda::mr::device_accessible > device_async_resource_ref
#define CUDF_EXPECTS(...)
用于检查(前置)条件的宏,当条件被违反时抛出异常。
定义于: error.hpp:178
int32_t size_type
列和表的行索引类型。
定义于: types.hpp:95
cuDF-IO API 类型定义
cuDF 接口
定义于: host_udf.hpp:37
写入接口的目标信息。
定义于: io/types.hpp:523
读取接口的源信息。
定义于: io/types.hpp:348
io 读取器用于按值返回元数据的表及其元数据。
定义于: io/types.hpp:303
(mutable)_table_view 的类定义
libcudf 的类型声明。