orc.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 
6 #pragma once
7 
8 #include <cudf/io/detail/orc.hpp>
9 #include <cudf/io/types.hpp>
11 #include <cudf/types.hpp>
12 #include <cudf/utilities/export.hpp>
14 
15 #include <memory>
16 #include <optional>
17 #include <string>
18 #include <unordered_map>
19 #include <utility>
20 #include <vector>
21 
27 namespace CUDF_EXPORT cudf {
28 namespace io {
34 constexpr size_t default_stripe_size_bytes = 64 * 1024 * 1024;
35 constexpr size_type default_stripe_size_rows = 1000000;
37 
47 [[nodiscard]] bool is_supported_read_orc(compression_type compression);
48 
58 [[nodiscard]] bool is_supported_write_orc(compression_type compression);
59 
64 
69  source_info _source;
70 
71  // Names of column to read; `nullopt` is all
72  std::optional<std::vector<std::string>> _columns;
73 
74  // List of individual stripes to read (ignored if empty)
75  std::vector<std::vector<size_type>> _stripes;
76  // Rows to skip from the start
77  int64_t _skip_rows = 0;
78  // Rows to read; `nullopt` is all
79  std::optional<int64_t> _num_rows;
80 
81  // Whether to use row index to speed-up reading
82  bool _use_index = true;
83 
84  // Whether to use numpy-compatible dtypes
85  bool _use_np_dtypes = true;
86  // Cast timestamp columns to a specific type
87  data_type _timestamp_type{type_id::EMPTY};
88 
89  // Columns that should be read as Decimal128
90  std::vector<std::string> _decimal128_columns;
91 
92  // Ignore writer timezone in the stripe footer, read as UTC timezone
93  bool _ignore_timezone_in_stripe_footer = false;
94 
96 
102  explicit orc_reader_options(source_info src) : _source{std::move(src)} {}
103 
104  public:
110  orc_reader_options() = default;
111 
119 
125  [[nodiscard]] source_info const& get_source() const { return _source; }
126 
132  [[nodiscard]] auto const& get_columns() const { return _columns; }
133 
139  [[nodiscard]] auto const& get_stripes() const { return _stripes; }
140 
146  [[nodiscard]] int64_t get_skip_rows() const { return _skip_rows; }
147 
154  [[nodiscard]] std::optional<int64_t> const& get_num_rows() const { return _num_rows; }
155 
161  [[nodiscard]] bool is_enabled_use_index() const { return _use_index; }
162 
168  [[nodiscard]] bool is_enabled_use_np_dtypes() const { return _use_np_dtypes; }
169 
175  [[nodiscard]] data_type get_timestamp_type() const { return _timestamp_type; }
176 
182  [[nodiscard]] std::vector<std::string> const& get_decimal128_columns() const
183  {
184  return _decimal128_columns;
185  }
186 
192  [[nodiscard]] bool get_ignore_timezone_in_stripe_footer() const
193  {
194  return _ignore_timezone_in_stripe_footer;
195  }
196 
197  // Setters
198 
204  void set_source(source_info src) { _source = std::move(src); }
205 
211  void set_columns(std::vector<std::string> col_names) { _columns = std::move(col_names); }
212 
223  void set_stripes(std::vector<std::vector<size_type>> stripes)
224  {
225  CUDF_EXPECTS(stripes.empty() or (_skip_rows == 0), "Can't set stripes along with skip_rows");
226  CUDF_EXPECTS(stripes.empty() or not _num_rows.has_value(),
227  "Can't set stripes along with num_rows");
228  _stripes = std::move(stripes);
229  }
230 
239  void set_skip_rows(int64_t rows)
240  {
241  CUDF_EXPECTS(rows >= 0, "skip_rows cannot be negative");
242  CUDF_EXPECTS(rows == 0 or _stripes.empty(), "Can't set both skip_rows along with stripes");
243  _skip_rows = rows;
244  }
245 
254  void set_num_rows(int64_t nrows)
255  {
256  CUDF_EXPECTS(nrows >= 0, "num_rows cannot be negative");
257  CUDF_EXPECTS(_stripes.empty(), "Can't set both num_rows and stripes");
258  _num_rows = nrows;
259  }
260 
266  void enable_use_index(bool use) { _use_index = use; }
267 
273  void enable_use_np_dtypes(bool use) { _use_np_dtypes = use; }
274 
280  void set_timestamp_type(data_type type) { _timestamp_type = type; }
281 
287  void set_decimal128_columns(std::vector<std::string> val)
288  {
289  _decimal128_columns = std::move(val);
290  }
291 
298  {
299  _ignore_timezone_in_stripe_footer = val;
300  }
301 };
302 
307  orc_reader_options options;
308 
309  public:
315  explicit orc_reader_options_builder() = default;
316 
322  explicit orc_reader_options_builder(source_info src) : options{std::move(src)} {}
323 
330  orc_reader_options_builder& columns(std::vector<std::string> col_names)
331  {
332  options.set_columns(std::move(col_names));
333  return *this;
334  }
335 
342  orc_reader_options_builder& stripes(std::vector<std::vector<size_type>> stripes)
343  {
344  options.set_stripes(std::move(stripes));
345  return *this;
346  }
347 
355  {
356  options.set_skip_rows(rows);
357  return *this;
358  }
359 
367  {
368  options.set_num_rows(nrows);
369  return *this;
370  }
371 
379  {
380  options.enable_use_index(use);
381  return *this;
382  }
383 
391  {
392  options.enable_use_np_dtypes(use);
393  return *this;
394  }
395 
403  {
404  options.set_timestamp_type(type);
405  return *this;
406  }
407 
414  orc_reader_options_builder& decimal128_columns(std::vector<std::string> val)
415  {
416  options.set_decimal128_columns(std::move(val));
417  return *this;
418  }
419 
427  {
429  return *this;
430  }
431 
435  operator orc_reader_options&&() { return std::move(options); }
436 
444  orc_reader_options&& build() { return std::move(options); }
445 };
446 
465  orc_reader_options const& options,
468 
479  public:
486 
532  std::size_t chunk_read_limit,
533  std::size_t pass_read_limit,
534  size_type output_row_granularity,
535  orc_reader_options const& options,
538 
554  std::size_t chunk_read_limit,
555  std::size_t pass_read_limit,
556  orc_reader_options const& options,
559 
573  std::size_t chunk_read_limit,
574  orc_reader_options const& options,
577 
582 
588  [[nodiscard]] bool has_next() const;
589 
601  [[nodiscard]] table_with_metadata read_chunk() const;
602 
603  private:
604  std::unique_ptr<cudf::io::orc::detail::chunked_reader> reader;
605 };
606  // end of group
617 
627 static constexpr statistics_freq ORC_STATISTICS_STRIPE = statistics_freq::STATISTICS_ROWGROUP;
628 static constexpr statistics_freq ORC_STATISTICS_ROW_GROUP = statistics_freq::STATISTICS_PAGE;
629 
634  // Specify the sink to use for writer output
635  sink_info _sink;
636  // Specify the compression format to use
637  compression_type _compression = compression_type::SNAPPY;
638  // Specify frequency of statistics collection
639  statistics_freq _stats_freq = ORC_STATISTICS_ROW_GROUP;
640  // Maximum size of each stripe (unless smaller than a single row group)
641  size_t _stripe_size_bytes = default_stripe_size_bytes;
642  // Maximum number of rows in stripe (unless smaller than a single row group)
643  size_type _stripe_size_rows = default_stripe_size_rows;
644  // Row index stride (maximum number of rows in each row group)
645  size_type _row_index_stride = default_row_index_stride;
646  // Set of columns to output
647  table_view _table;
648  // Optional associated metadata
649  std::optional<table_input_metadata> _metadata;
650  // Optional footer key_value_metadata
651  std::map<std::string, std::string> _user_data;
652  // Optional compression statistics
653  std::shared_ptr<writer_compression_statistics> _compression_stats;
654  // Specify whether string dictionaries should be alphabetically sorted
655  bool _enable_dictionary_sort = true;
656 
658 
666  : _sink(std::move(sink)), _table(std::move(table))
667  {
668  }
669 
670  public:
676  explicit orc_writer_options() = default;
677 
687 
693  [[nodiscard]] sink_info const& get_sink() const { return _sink; }
694 
700  [[nodiscard]] compression_type get_compression() const { return _compression; }
701 
707  [[nodiscard]] bool is_enabled_statistics() const
708  {
709  return _stats_freq != statistics_freq::STATISTICS_NONE;
710  }
711 
717  [[nodiscard]] statistics_freq get_statistics_freq() const { return _stats_freq; }
718 
724  [[nodiscard]] auto get_stripe_size_bytes() const { return _stripe_size_bytes; }
725 
731  [[nodiscard]] auto get_stripe_size_rows() const { return _stripe_size_rows; }
732 
738  [[nodiscard]] auto get_row_index_stride() const
739  {
740  auto const unaligned_stride = std::min(_row_index_stride, get_stripe_size_rows());
741  return unaligned_stride - unaligned_stride % 8;
742  }
743 
749  [[nodiscard]] table_view get_table() const { return _table; }
750 
756  [[nodiscard]] auto const& get_metadata() const { return _metadata; }
757 
763  [[nodiscard]] std::map<std::string, std::string> const& get_key_value_metadata() const
764  {
765  return _user_data;
766  }
767 
773  [[nodiscard]] std::shared_ptr<writer_compression_statistics> get_compression_statistics() const
774  {
775  return _compression_stats;
776  }
777 
783  [[nodiscard]] bool get_enable_dictionary_sort() const { return _enable_dictionary_sort; }
784 
785  // Setters
786 
793  {
794  _compression = comp;
795  if (comp == compression_type::AUTO) { _compression = compression_type::SNAPPY; }
796  }
797 
808  void enable_statistics(statistics_freq val) { _stats_freq = val; }
809 
817  void set_stripe_size_bytes(size_t size_bytes)
818  {
819  CUDF_EXPECTS(size_bytes >= 64 << 10, "64KB is the minimum stripe size");
820  _stripe_size_bytes = size_bytes;
821  }
822 
834  {
835  CUDF_EXPECTS(size_rows >= 512, "Maximum stripe size cannot be smaller than 512");
836  _stripe_size_rows = size_rows;
837  }
838 
849  {
850  CUDF_EXPECTS(stride >= 512, "Row index stride cannot be smaller than 512");
851  _row_index_stride = stride;
852  }
853 
859  void set_table(table_view tbl) { _table = tbl; }
860 
866  void set_metadata(table_input_metadata meta) { _metadata = std::move(meta); }
867 
873  void set_key_value_metadata(std::map<std::string, std::string> metadata)
874  {
875  _user_data = std::move(metadata);
876  }
877 
883  void set_compression_statistics(std::shared_ptr<writer_compression_statistics> comp_stats)
884  {
885  _compression_stats = std::move(comp_stats);
886  }
887 
893  void set_enable_dictionary_sort(bool val) { _enable_dictionary_sort = val; }
894 };
895 
900  orc_writer_options options;
901 
902  public:
909 
916  orc_writer_options_builder(sink_info const& sink, table_view const& table) : options{sink, table}
917  {
918  }
919 
927  {
928  options.set_compression(comp);
929  return *this;
930  }
931 
944  {
945  options.enable_statistics(val);
946  return *this;
947  }
948 
956  {
957  options.set_stripe_size_bytes(val);
958  return *this;
959  }
960 
968  {
969  options.set_stripe_size_rows(val);
970  return *this;
971  }
972 
980  {
981  options.set_row_index_stride(val);
982  return *this;
983  }
984 
992  {
993  options.set_table(tbl);
994  return *this;
995  }
996 
1004  {
1005  options.set_metadata(std::move(meta));
1006  return *this;
1007  }
1008 
1015  orc_writer_options_builder& key_value_metadata(std::map<std::string, std::string> metadata)
1016  {
1017  options.set_key_value_metadata(std::move(metadata));
1018  return *this;
1019  }
1020 
1028  std::shared_ptr<writer_compression_statistics> const& comp_stats)
1029  {
1030  options.set_compression_statistics(comp_stats);
1031  return *this;
1032  }
1033 
1041  {
1042  options.set_enable_dictionary_sort(val);
1043  return *this;
1044  }
1045 
1049  operator orc_writer_options&&() { return std::move(options); }
1050 
1058  orc_writer_options&& build() { return std::move(options); }
1059 };
1060 
1076 void write_orc(orc_writer_options const& options,
1078 
1083 
1088  // Specify the sink to use for writer output
1089  sink_info _sink;
1090  // Specify the compression format to use
1091  compression_type _compression = compression_type::SNAPPY;
1092  // Specify granularity of statistics collection
1093  statistics_freq _stats_freq = ORC_STATISTICS_ROW_GROUP;
1094  // Maximum size of each stripe (unless smaller than a single row group)
1095  size_t _stripe_size_bytes = default_stripe_size_bytes;
1096  // Maximum number of rows in stripe (unless smaller than a single row group)
1097  size_type _stripe_size_rows = default_stripe_size_rows;
1098  // Row index stride (maximum number of rows in each row group)
1099  size_type _row_index_stride = default_row_index_stride;
1100  // Optional associated metadata
1101  std::optional<table_input_metadata> _metadata;
1102  // Optional footer key_value_metadata
1103  std::map<std::string, std::string> _user_data;
1104  // Optional compression statistics
1105  std::shared_ptr<writer_compression_statistics> _compression_stats;
1106  // Specify whether string dictionaries should be alphabetically sorted
1107  bool _enable_dictionary_sort = true;
1108 
1110 
1116  chunked_orc_writer_options(sink_info sink) : _sink(std::move(sink)) {}
1117 
1118  public:
1124  explicit chunked_orc_writer_options() = default;
1125 
1134 
1140  [[nodiscard]] sink_info const& get_sink() const { return _sink; }
1141 
1147  [[nodiscard]] compression_type get_compression() const { return _compression; }
1148 
1154  [[nodiscard]] statistics_freq get_statistics_freq() const { return _stats_freq; }
1155 
1161  [[nodiscard]] auto get_stripe_size_bytes() const { return _stripe_size_bytes; }
1162 
1168  [[nodiscard]] auto get_stripe_size_rows() const { return _stripe_size_rows; }
1169 
1175  [[nodiscard]] auto get_row_index_stride() const
1176  {
1177  auto const unaligned_stride = std::min(_row_index_stride, get_stripe_size_rows());
1178  return unaligned_stride - unaligned_stride % 8;
1179  }
1180 
1186  [[nodiscard]] auto const& get_metadata() const { return _metadata; }
1187 
1193  [[nodiscard]] std::map<std::string, std::string> const& get_key_value_metadata() const
1194  {
1195  return _user_data;
1196  }
1197 
1203  [[nodiscard]] std::shared_ptr<writer_compression_statistics> get_compression_statistics() const
1204  {
1205  return _compression_stats;
1206  }
1207 
1213  [[nodiscard]] bool get_enable_dictionary_sort() const { return _enable_dictionary_sort; }
1214 
1215  // Setters
1216 
1223  {
1224  _compression = comp;
1225  if (comp == compression_type::AUTO) { _compression = compression_type::SNAPPY; }
1226  }
1227 
1238  void enable_statistics(statistics_freq val) { _stats_freq = val; }
1239 
1247  void set_stripe_size_bytes(size_t size_bytes)
1248  {
1249  CUDF_EXPECTS(size_bytes >= 64 << 10, "64KB is the minimum stripe size");
1250  _stripe_size_bytes = size_bytes;
1251  }
1252 
1264  {
1265  CUDF_EXPECTS(size_rows >= 512, "maximum stripe size cannot be smaller than 512");
1266  _stripe_size_rows = size_rows;
1267  }
1268 
1279  {
1280  CUDF_EXPECTS(stride >= 512, "Row index stride cannot be smaller than 512");
1281  _row_index_stride = stride;
1282  }
1283 
1289  void metadata(table_input_metadata meta) { _metadata = std::move(meta); }
1290 
1296  void set_key_value_metadata(std::map<std::string, std::string> metadata)
1297  {
1298  _user_data = std::move(metadata);
1299  }
1300 
1306  void set_compression_statistics(std::shared_ptr<writer_compression_statistics> comp_stats)
1307  {
1308  _compression_stats = std::move(comp_stats);
1309  }
1310 
1316  void set_enable_dictionary_sort(bool val) { _enable_dictionary_sort = val; }
1317 };
1318 
1324 
1325  public:
1332 
1338  explicit chunked_orc_writer_options_builder(sink_info const& sink) : options{sink} {}
1339 
1347  {
1348  options.set_compression(comp);
1349  return *this;
1350  }
1351 
1364  {
1365  options.enable_statistics(val);
1366  return *this;
1367  }
1368 
1376  {
1377  options.set_stripe_size_bytes(val);
1378  return *this;
1379  }
1380 
1388  {
1389  options.set_stripe_size_rows(val);
1390  return *this;
1391  }
1392 
1400  {
1401  options.set_row_index_stride(val);
1402  return *this;
1403  }
1404 
1412  {
1413  options.metadata(std::move(meta));
1414  return *this;
1415  }
1416 
1424  std::map<std::string, std::string> metadata)
1425  {
1426  options.set_key_value_metadata(std::move(metadata));
1427  return *this;
1428  }
1429 
1437  std::shared_ptr<writer_compression_statistics> const& comp_stats)
1438  {
1439  options.set_compression_statistics(comp_stats);
1440  return *this;
1441  }
1442 
1450  {
1451  options.set_enable_dictionary_sort(val);
1452  return *this;
1453  }
1454 
1458  operator chunked_orc_writer_options&&() { return std::move(options); }
1459 
1467  chunked_orc_writer_options&& build() { return std::move(options); }
1468 };
1469 
1492  public:
1498 
1503 
1512 
1523 
1527  void close();
1528 
1530  std::unique_ptr<orc::detail::writer> writer;
1531 };
1532  // end of group
1534 } // namespace io
1535 } // namespace CUDF_EXPORT cudf
Indicator for the logical data type of an element in a column.
Definition: types.hpp:278
The chunked orc reader class to read an ORC file iteratively into a series of tables,...
Definition: orc.hpp:478
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())
Construct the reader from output size limits along with other ORC reader options.
bool has_next() const
Check if there is any data in the given data sources has not yet read.
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())
Construct the reader from input/output size limits along with other ORC reader options.
~chunked_orc_reader()
Destructor, destroying the internal reader instance.
table_with_metadata read_chunk() const
Read a chunk of rows in the given data sources.
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())
Construct the reader from input/output size limits, output row granularity, along with other ORC read...
chunked_orc_reader()
Default constructor, this should never be used.
Builds settings to use for write_orc_chunked().
Definition: orc.hpp:1322
chunked_orc_writer_options_builder & enable_dictionary_sort(bool val)
Sets whether string dictionaries should be sorted.
Definition: orc.hpp:1449
chunked_orc_writer_options && build()
move chunked_orc_writer_options member once it's built.
Definition: orc.hpp:1467
chunked_orc_writer_options_builder & stripe_size_bytes(size_t val)
Sets the maximum stripe size, in bytes.
Definition: orc.hpp:1375
chunked_orc_writer_options_builder()=default
Default constructor.
chunked_orc_writer_options_builder & stripe_size_rows(size_type val)
Sets the maximum number of rows in output stripes.
Definition: orc.hpp:1387
chunked_orc_writer_options_builder & compression_statistics(std::shared_ptr< writer_compression_statistics > const &comp_stats)
Sets the pointer to the output compression statistics.
Definition: orc.hpp:1436
chunked_orc_writer_options_builder & key_value_metadata(std::map< std::string, std::string > metadata)
Sets Key-Value footer metadata.
Definition: orc.hpp:1423
chunked_orc_writer_options_builder & compression(compression_type comp)
Sets compression type.
Definition: orc.hpp:1346
chunked_orc_writer_options_builder & metadata(table_input_metadata meta)
Sets associated metadata.
Definition: orc.hpp:1411
chunked_orc_writer_options_builder(sink_info const &sink)
Constructor from sink and table.
Definition: orc.hpp:1338
chunked_orc_writer_options_builder & enable_statistics(statistics_freq val)
Choose granularity of statistics collection.
Definition: orc.hpp:1363
chunked_orc_writer_options_builder & row_index_stride(size_type val)
Sets the row index stride.
Definition: orc.hpp:1399
Settings to use for write_orc_chunked().
Definition: orc.hpp:1087
void set_stripe_size_bytes(size_t size_bytes)
Sets the maximum stripe size, in bytes.
Definition: orc.hpp:1247
chunked_orc_writer_options()=default
Default constructor.
void metadata(table_input_metadata meta)
Sets associated metadata.
Definition: orc.hpp:1289
void set_key_value_metadata(std::map< std::string, std::string > metadata)
Sets Key-Value footer metadata.
Definition: orc.hpp:1296
void set_compression_statistics(std::shared_ptr< writer_compression_statistics > comp_stats)
Sets the pointer to the output compression statistics.
Definition: orc.hpp:1306
sink_info const & get_sink() const
Returns sink info.
Definition: orc.hpp:1140
auto get_stripe_size_rows() const
Returns maximum stripe size, in rows.
Definition: orc.hpp:1168
auto get_row_index_stride() const
Returns the row index stride.
Definition: orc.hpp:1175
void set_row_index_stride(size_type stride)
Sets the row index stride.
Definition: orc.hpp:1278
statistics_freq get_statistics_freq() const
Returns granularity of statistics collection.
Definition: orc.hpp:1154
void set_compression(compression_type comp)
Sets compression type.
Definition: orc.hpp:1222
std::map< std::string, std::string > const & get_key_value_metadata() const
Returns Key-Value footer metadata information.
Definition: orc.hpp:1193
void set_enable_dictionary_sort(bool val)
Sets whether string dictionaries should be sorted.
Definition: orc.hpp:1316
auto const & get_metadata() const
Returns associated metadata.
Definition: orc.hpp:1186
bool get_enable_dictionary_sort() const
Returns whether string dictionaries should be sorted.
Definition: orc.hpp:1213
compression_type get_compression() const
Returns compression type.
Definition: orc.hpp:1147
void set_stripe_size_rows(size_type size_rows)
Sets the maximum stripe size, in rows.
Definition: orc.hpp:1263
std::shared_ptr< writer_compression_statistics > get_compression_statistics() const
Returns a shared pointer to the user-provided compression statistics.
Definition: orc.hpp:1203
auto get_stripe_size_bytes() const
Returns maximum stripe size, in bytes.
Definition: orc.hpp:1161
void enable_statistics(statistics_freq val)
Choose granularity of statistics collection.
Definition: orc.hpp:1238
static chunked_orc_writer_options_builder builder(sink_info const &sink)
Create builder to create chunked_orc_writer_options.
Chunked orc writer class writes an ORC file in a chunked/stream form.
Definition: orc.hpp:1491
~orc_chunked_writer()
virtual destructor, Added so we don't leak detail types.
orc_chunked_writer()
Default constructor, this should never be used. This is added just to satisfy cython.
orc_chunked_writer(chunked_orc_writer_options const &options, rmm::cuda_stream_view stream=cudf::get_default_stream())
Constructor with chunked writer options.
std::unique_ptr< orc::detail::writer > writer
Unique pointer to impl writer class.
Definition: orc.hpp:1530
orc_chunked_writer & write(table_view const &table)
Writes table to output.
void close()
Finishes the chunked/streamed write process.
Builds settings to use for read_orc().
Definition: orc.hpp:306
orc_reader_options_builder & use_index(bool use)
Enable/Disable use of row index to speed-up reading.
Definition: orc.hpp:378
orc_reader_options_builder & decimal128_columns(std::vector< std::string > val)
Columns that should be read as 128-bit Decimal.
Definition: orc.hpp:414
orc_reader_options_builder & use_np_dtypes(bool use)
Enable/Disable use of numpy-compatible dtypes.
Definition: orc.hpp:390
orc_reader_options_builder & ignore_timezone_in_stripe_footer(bool ignore)
Set whether to ignore writer timezone in the stripe footer.
Definition: orc.hpp:426
orc_reader_options_builder & skip_rows(int64_t rows)
Sets number of rows to skip from the start.
Definition: orc.hpp:354
orc_reader_options_builder()=default
Default constructor.
orc_reader_options_builder(source_info src)
Constructor from source info.
Definition: orc.hpp:322
orc_reader_options_builder & stripes(std::vector< std::vector< size_type >> stripes)
Sets list of individual stripes to read per source.
Definition: orc.hpp:342
orc_reader_options_builder & num_rows(int64_t nrows)
Sets number of row to read.
Definition: orc.hpp:366
orc_reader_options_builder & columns(std::vector< std::string > col_names)
Sets names of the column to read.
Definition: orc.hpp:330
orc_reader_options && build()
move orc_reader_options member once it's built.
Definition: orc.hpp:444
orc_reader_options_builder & timestamp_type(data_type type)
Sets timestamp type to which timestamp column will be cast.
Definition: orc.hpp:402
Settings to use for read_orc().
Definition: orc.hpp:68
int64_t get_skip_rows() const
Returns number of rows to skip from the start.
Definition: orc.hpp:146
orc_reader_options()=default
Default constructor.
void enable_use_np_dtypes(bool use)
Enable/Disable use of numpy-compatible dtypes.
Definition: orc.hpp:273
void set_num_rows(int64_t nrows)
Sets number of row to read.
Definition: orc.hpp:254
auto const & get_stripes() const
Returns vector of vectors, stripes to read for each input source.
Definition: orc.hpp:139
void set_decimal128_columns(std::vector< std::string > val)
Set columns that should be read as 128-bit Decimal.
Definition: orc.hpp:287
void set_skip_rows(int64_t rows)
Sets number of rows to skip from the start.
Definition: orc.hpp:239
void enable_use_index(bool use)
Enable/Disable use of row index to speed-up reading.
Definition: orc.hpp:266
void set_columns(std::vector< std::string > col_names)
Sets names of the column to read.
Definition: orc.hpp:211
void set_stripes(std::vector< std::vector< size_type >> stripes)
Sets list of stripes to read for each input source.
Definition: orc.hpp:223
void enable_ignore_timezone_in_stripe_footer(bool val)
Sets whether to ignore writer timezone in the stripe footer.
Definition: orc.hpp:297
data_type get_timestamp_type() const
Returns timestamp type to which timestamp column will be cast.
Definition: orc.hpp:175
auto const & get_columns() const
Returns names of the columns to read, if set.
Definition: orc.hpp:132
void set_source(source_info src)
Sets source info.
Definition: orc.hpp:204
static orc_reader_options_builder builder(source_info src)
Creates orc_reader_options_builder which will build orc_reader_options.
std::optional< int64_t > const & get_num_rows() const
Returns number of row to read.
Definition: orc.hpp:154
source_info const & get_source() const
Returns source info.
Definition: orc.hpp:125
bool is_enabled_use_np_dtypes() const
Whether to use numpy-compatible dtypes.
Definition: orc.hpp:168
bool is_enabled_use_index() const
Whether to use row index to speed-up reading.
Definition: orc.hpp:161
bool get_ignore_timezone_in_stripe_footer() const
Returns whether to ignore writer timezone in the stripe footer.
Definition: orc.hpp:192
std::vector< std::string > const & get_decimal128_columns() const
Returns fully qualified names of columns that should be read as 128-bit Decimal.
Definition: orc.hpp:182
void set_timestamp_type(data_type type)
Sets timestamp type to which timestamp column will be cast.
Definition: orc.hpp:280
Builds settings to use for write_orc().
Definition: orc.hpp:899
orc_writer_options_builder & table(table_view tbl)
Sets table to be written to output.
Definition: orc.hpp:991
orc_writer_options_builder & row_index_stride(size_type val)
Sets the row index stride.
Definition: orc.hpp:979
orc_writer_options_builder & enable_statistics(statistics_freq val)
Choose granularity of column statistics to be written.
Definition: orc.hpp:943
orc_writer_options_builder & metadata(table_input_metadata meta)
Sets associated metadata.
Definition: orc.hpp:1003
orc_writer_options_builder(sink_info const &sink, table_view const &table)
Constructor from sink and table.
Definition: orc.hpp:916
orc_writer_options && build()
move orc_writer_options member once it's built.
Definition: orc.hpp:1058
orc_writer_options_builder()=default
Default constructor.
orc_writer_options_builder & key_value_metadata(std::map< std::string, std::string > metadata)
Sets Key-Value footer metadata.
Definition: orc.hpp:1015
orc_writer_options_builder & compression_statistics(std::shared_ptr< writer_compression_statistics > const &comp_stats)
Sets the pointer to the output compression statistics.
Definition: orc.hpp:1027
orc_writer_options_builder & stripe_size_rows(size_type val)
Sets the maximum number of rows in output stripes.
Definition: orc.hpp:967
orc_writer_options_builder & enable_dictionary_sort(bool val)
Sets whether string dictionaries should be sorted.
Definition: orc.hpp:1040
orc_writer_options_builder & compression(compression_type comp)
Sets compression type.
Definition: orc.hpp:926
orc_writer_options_builder & stripe_size_bytes(size_t val)
Sets the maximum stripe size, in bytes.
Definition: orc.hpp:955
Settings to use for write_orc().
Definition: orc.hpp:633
void enable_statistics(statistics_freq val)
Choose granularity of statistics collection.
Definition: orc.hpp:808
auto const & get_metadata() const
Returns associated metadata.
Definition: orc.hpp:756
std::map< std::string, std::string > const & get_key_value_metadata() const
Returns Key-Value footer metadata information.
Definition: orc.hpp:763
std::shared_ptr< writer_compression_statistics > get_compression_statistics() const
Returns a shared pointer to the user-provided compression statistics.
Definition: orc.hpp:773
bool is_enabled_statistics() const
Whether writing column statistics is enabled/disabled.
Definition: orc.hpp:707
auto get_stripe_size_bytes() const
Returns maximum stripe size, in bytes.
Definition: orc.hpp:724
void set_stripe_size_rows(size_type size_rows)
Sets the maximum stripe size, in rows.
Definition: orc.hpp:833
void set_key_value_metadata(std::map< std::string, std::string > metadata)
Sets metadata.
Definition: orc.hpp:873
auto get_stripe_size_rows() const
Returns maximum stripe size, in rows.
Definition: orc.hpp:731
table_view get_table() const
Returns table to be written to output.
Definition: orc.hpp:749
void set_metadata(table_input_metadata meta)
Sets associated metadata.
Definition: orc.hpp:866
statistics_freq get_statistics_freq() const
Returns frequency of statistics collection.
Definition: orc.hpp:717
void set_compression_statistics(std::shared_ptr< writer_compression_statistics > comp_stats)
Sets the pointer to the output compression statistics.
Definition: orc.hpp:883
auto get_row_index_stride() const
Returns the row index stride.
Definition: orc.hpp:738
void set_table(table_view tbl)
Sets table to be written to output.
Definition: orc.hpp:859
orc_writer_options()=default
Default constructor.
void set_compression(compression_type comp)
Sets compression type.
Definition: orc.hpp:792
void set_enable_dictionary_sort(bool val)
Sets whether string dictionaries should be sorted.
Definition: orc.hpp:893
void set_row_index_stride(size_type stride)
Sets the row index stride.
Definition: orc.hpp:848
compression_type get_compression() const
Returns compression type.
Definition: orc.hpp:700
static orc_writer_options_builder builder(sink_info const &sink, table_view const &table)
Create builder to create orc_writer_options.
bool get_enable_dictionary_sort() const
Returns whether string dictionaries should be sorted.
Definition: orc.hpp:783
void set_stripe_size_bytes(size_t size_bytes)
Sets the maximum stripe size, in bytes.
Definition: orc.hpp:817
sink_info const & get_sink() const
Returns sink info.
Definition: orc.hpp:693
Metadata for a table.
Definition: types.hpp:915
A set of cudf::column_view's of the same size.
Definition: table_view.hpp:206
A set of cudf::column's of the same size.
Definition: table.hpp:31
rmm::cuda_stream_view const get_default_stream()
Get the current default stream.
bool is_supported_read_orc(compression_type compression)
Check if the compression type is supported for reading ORC files.
constexpr size_type default_stripe_size_rows
1M rows default orc stripe rows
Definition: orc.hpp:35
bool is_supported_write_orc(compression_type compression)
Check if the compression type is supported for writing ORC files.
constexpr size_type default_row_index_stride
10K rows default orc row index stride
Definition: orc.hpp:36
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())
Reads an ORC dataset into a set of columns.
constexpr size_t default_stripe_size_bytes
64MB default orc stripe size
Definition: orc.hpp:34
statistics_freq
Column statistics granularity type for parquet/orc writers.
Definition: types.hpp:85
compression_type
Compression algorithms.
Definition: types.hpp:46
@ STATISTICS_ROWGROUP
Per-Rowgroup column statistics.
Definition: types.hpp:87
@ STATISTICS_NONE
No column statistics.
Definition: types.hpp:86
@ STATISTICS_PAGE
Per-page column statistics.
Definition: types.hpp:88
void write_orc(orc_writer_options const &options, rmm::cuda_stream_view stream=cudf::get_default_stream())
Writes a set of columns to ORC format.
rmm::device_async_resource_ref get_current_device_resource_ref()
Get the current device memory resource reference.
cuda::mr::resource_ref< cuda::mr::device_accessible > device_async_resource_ref
#define CUDF_EXPECTS(...)
Macro for checking (pre-)conditions that throws an exception when a condition is violated.
Definition: error.hpp:182
int32_t size_type
Row index type for columns and tables.
Definition: types.hpp:76
Type definitions for the cuDF-IO API.
APIs for getting and setting the current device memory resource.
cuDF interfaces
Definition: host_udf.hpp:26
Destination information for write interfaces.
Definition: types.hpp:493
Source information for read interfaces.
Definition: types.hpp:306
Table with table metadata used by io readers to return the metadata by value.
Definition: types.hpp:271
Class definitions for (mutable)_table_view
Type declarations for libcudf.