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 };
292 
297  orc_reader_options options;
298 
299  public:
305  explicit orc_reader_options_builder() = default;
306 
312  explicit orc_reader_options_builder(source_info src) : options{std::move(src)} {}
313 
320  orc_reader_options_builder& columns(std::vector<std::string> col_names)
321  {
322  options._columns = std::move(col_names);
323  return *this;
324  }
325 
332  orc_reader_options_builder& stripes(std::vector<std::vector<size_type>> stripes)
333  {
334  options.set_stripes(std::move(stripes));
335  return *this;
336  }
337 
345  {
346  options.set_skip_rows(rows);
347  return *this;
348  }
349 
357  {
358  options.set_num_rows(nrows);
359  return *this;
360  }
361 
369  {
370  options._use_index = use;
371  return *this;
372  }
373 
381  {
382  options._use_np_dtypes = use;
383  return *this;
384  }
385 
393  {
394  options._timestamp_type = type;
395  return *this;
396  }
397 
404  orc_reader_options_builder& decimal128_columns(std::vector<std::string> val)
405  {
406  options._decimal128_columns = std::move(val);
407  return *this;
408  }
409 
417  {
418  options._ignore_timezone_in_stripe_footer = ignore;
419  return *this;
420  }
421 
425  operator orc_reader_options&&() { return std::move(options); }
426 
434  orc_reader_options&& build() { return std::move(options); }
435 };
436 
455  orc_reader_options const& options,
458 
469  public:
476 
522  std::size_t chunk_read_limit,
523  std::size_t pass_read_limit,
524  size_type output_row_granularity,
525  orc_reader_options const& options,
528 
544  std::size_t chunk_read_limit,
545  std::size_t pass_read_limit,
546  orc_reader_options const& options,
549 
563  std::size_t chunk_read_limit,
564  orc_reader_options const& options,
567 
572 
578  [[nodiscard]] bool has_next() const;
579 
591  [[nodiscard]] table_with_metadata read_chunk() const;
592 
593  private:
594  std::unique_ptr<cudf::io::orc::detail::chunked_reader> reader;
595 };
596  // end of group
607 
617 static constexpr statistics_freq ORC_STATISTICS_STRIPE = statistics_freq::STATISTICS_ROWGROUP;
618 static constexpr statistics_freq ORC_STATISTICS_ROW_GROUP = statistics_freq::STATISTICS_PAGE;
619 
624  // Specify the sink to use for writer output
625  sink_info _sink;
626  // Specify the compression format to use
627  compression_type _compression = compression_type::SNAPPY;
628  // Specify frequency of statistics collection
629  statistics_freq _stats_freq = ORC_STATISTICS_ROW_GROUP;
630  // Maximum size of each stripe (unless smaller than a single row group)
631  size_t _stripe_size_bytes = default_stripe_size_bytes;
632  // Maximum number of rows in stripe (unless smaller than a single row group)
633  size_type _stripe_size_rows = default_stripe_size_rows;
634  // Row index stride (maximum number of rows in each row group)
635  size_type _row_index_stride = default_row_index_stride;
636  // Set of columns to output
637  table_view _table;
638  // Optional associated metadata
639  std::optional<table_input_metadata> _metadata;
640  // Optional footer key_value_metadata
641  std::map<std::string, std::string> _user_data;
642  // Optional compression statistics
643  std::shared_ptr<writer_compression_statistics> _compression_stats;
644  // Specify whether string dictionaries should be alphabetically sorted
645  bool _enable_dictionary_sort = true;
646 
648 
656  : _sink(std::move(sink)), _table(std::move(table))
657  {
658  }
659 
660  public:
666  explicit orc_writer_options() = default;
667 
677 
683  [[nodiscard]] sink_info const& get_sink() const { return _sink; }
684 
690  [[nodiscard]] compression_type get_compression() const { return _compression; }
691 
697  [[nodiscard]] bool is_enabled_statistics() const
698  {
699  return _stats_freq != statistics_freq::STATISTICS_NONE;
700  }
701 
707  [[nodiscard]] statistics_freq get_statistics_freq() const { return _stats_freq; }
708 
714  [[nodiscard]] auto get_stripe_size_bytes() const { return _stripe_size_bytes; }
715 
721  [[nodiscard]] auto get_stripe_size_rows() const { return _stripe_size_rows; }
722 
728  [[nodiscard]] auto get_row_index_stride() const
729  {
730  auto const unaligned_stride = std::min(_row_index_stride, get_stripe_size_rows());
731  return unaligned_stride - unaligned_stride % 8;
732  }
733 
739  [[nodiscard]] table_view get_table() const { return _table; }
740 
746  [[nodiscard]] auto const& get_metadata() const { return _metadata; }
747 
753  [[nodiscard]] std::map<std::string, std::string> const& get_key_value_metadata() const
754  {
755  return _user_data;
756  }
757 
763  [[nodiscard]] std::shared_ptr<writer_compression_statistics> get_compression_statistics() const
764  {
765  return _compression_stats;
766  }
767 
773  [[nodiscard]] bool get_enable_dictionary_sort() const { return _enable_dictionary_sort; }
774 
775  // Setters
776 
783  {
784  _compression = comp;
785  if (comp == compression_type::AUTO) { _compression = compression_type::SNAPPY; }
786  }
787 
798  void enable_statistics(statistics_freq val) { _stats_freq = val; }
799 
807  void set_stripe_size_bytes(size_t size_bytes)
808  {
809  CUDF_EXPECTS(size_bytes >= 64 << 10, "64KB is the minimum stripe size");
810  _stripe_size_bytes = size_bytes;
811  }
812 
824  {
825  CUDF_EXPECTS(size_rows >= 512, "Maximum stripe size cannot be smaller than 512");
826  _stripe_size_rows = size_rows;
827  }
828 
839  {
840  CUDF_EXPECTS(stride >= 512, "Row index stride cannot be smaller than 512");
841  _row_index_stride = stride;
842  }
843 
849  void set_table(table_view tbl) { _table = tbl; }
850 
856  void set_metadata(table_input_metadata meta) { _metadata = std::move(meta); }
857 
863  void set_key_value_metadata(std::map<std::string, std::string> metadata)
864  {
865  _user_data = std::move(metadata);
866  }
867 
873  void set_compression_statistics(std::shared_ptr<writer_compression_statistics> comp_stats)
874  {
875  _compression_stats = std::move(comp_stats);
876  }
877 
883  void set_enable_dictionary_sort(bool val) { _enable_dictionary_sort = val; }
884 };
885 
890  orc_writer_options options;
891 
892  public:
899 
906  orc_writer_options_builder(sink_info const& sink, table_view const& table) : options{sink, table}
907  {
908  }
909 
917  {
918  options.set_compression(comp);
919  return *this;
920  }
921 
934  {
935  options._stats_freq = val;
936  return *this;
937  }
938 
946  {
947  options.set_stripe_size_bytes(val);
948  return *this;
949  }
950 
958  {
959  options.set_stripe_size_rows(val);
960  return *this;
961  }
962 
970  {
971  options.set_row_index_stride(val);
972  return *this;
973  }
974 
982  {
983  options._table = tbl;
984  return *this;
985  }
986 
994  {
995  options._metadata = std::move(meta);
996  return *this;
997  }
998 
1005  orc_writer_options_builder& key_value_metadata(std::map<std::string, std::string> metadata)
1006  {
1007  options._user_data = std::move(metadata);
1008  return *this;
1009  }
1010 
1018  std::shared_ptr<writer_compression_statistics> const& comp_stats)
1019  {
1020  options._compression_stats = comp_stats;
1021  return *this;
1022  }
1023 
1031  {
1032  options._enable_dictionary_sort = val;
1033  return *this;
1034  }
1035 
1039  operator orc_writer_options&&() { return std::move(options); }
1040 
1048  orc_writer_options&& build() { return std::move(options); }
1049 };
1050 
1066 void write_orc(orc_writer_options const& options,
1068 
1073 
1078  // Specify the sink to use for writer output
1079  sink_info _sink;
1080  // Specify the compression format to use
1081  compression_type _compression = compression_type::SNAPPY;
1082  // Specify granularity of statistics collection
1083  statistics_freq _stats_freq = ORC_STATISTICS_ROW_GROUP;
1084  // Maximum size of each stripe (unless smaller than a single row group)
1085  size_t _stripe_size_bytes = default_stripe_size_bytes;
1086  // Maximum number of rows in stripe (unless smaller than a single row group)
1087  size_type _stripe_size_rows = default_stripe_size_rows;
1088  // Row index stride (maximum number of rows in each row group)
1089  size_type _row_index_stride = default_row_index_stride;
1090  // Optional associated metadata
1091  std::optional<table_input_metadata> _metadata;
1092  // Optional footer key_value_metadata
1093  std::map<std::string, std::string> _user_data;
1094  // Optional compression statistics
1095  std::shared_ptr<writer_compression_statistics> _compression_stats;
1096  // Specify whether string dictionaries should be alphabetically sorted
1097  bool _enable_dictionary_sort = true;
1098 
1100 
1106  chunked_orc_writer_options(sink_info sink) : _sink(std::move(sink)) {}
1107 
1108  public:
1114  explicit chunked_orc_writer_options() = default;
1115 
1124 
1130  [[nodiscard]] sink_info const& get_sink() const { return _sink; }
1131 
1137  [[nodiscard]] compression_type get_compression() const { return _compression; }
1138 
1144  [[nodiscard]] statistics_freq get_statistics_freq() const { return _stats_freq; }
1145 
1151  [[nodiscard]] auto get_stripe_size_bytes() const { return _stripe_size_bytes; }
1152 
1158  [[nodiscard]] auto get_stripe_size_rows() const { return _stripe_size_rows; }
1159 
1165  [[nodiscard]] auto get_row_index_stride() const
1166  {
1167  auto const unaligned_stride = std::min(_row_index_stride, get_stripe_size_rows());
1168  return unaligned_stride - unaligned_stride % 8;
1169  }
1170 
1176  [[nodiscard]] auto const& get_metadata() const { return _metadata; }
1177 
1183  [[nodiscard]] std::map<std::string, std::string> const& get_key_value_metadata() const
1184  {
1185  return _user_data;
1186  }
1187 
1193  [[nodiscard]] std::shared_ptr<writer_compression_statistics> get_compression_statistics() const
1194  {
1195  return _compression_stats;
1196  }
1197 
1203  [[nodiscard]] bool get_enable_dictionary_sort() const { return _enable_dictionary_sort; }
1204 
1205  // Setters
1206 
1213  {
1214  _compression = comp;
1215  if (comp == compression_type::AUTO) { _compression = compression_type::SNAPPY; }
1216  }
1217 
1228  void enable_statistics(statistics_freq val) { _stats_freq = val; }
1229 
1237  void set_stripe_size_bytes(size_t size_bytes)
1238  {
1239  CUDF_EXPECTS(size_bytes >= 64 << 10, "64KB is the minimum stripe size");
1240  _stripe_size_bytes = size_bytes;
1241  }
1242 
1254  {
1255  CUDF_EXPECTS(size_rows >= 512, "maximum stripe size cannot be smaller than 512");
1256  _stripe_size_rows = size_rows;
1257  }
1258 
1269  {
1270  CUDF_EXPECTS(stride >= 512, "Row index stride cannot be smaller than 512");
1271  _row_index_stride = stride;
1272  }
1273 
1279  void metadata(table_input_metadata meta) { _metadata = std::move(meta); }
1280 
1286  void set_key_value_metadata(std::map<std::string, std::string> metadata)
1287  {
1288  _user_data = std::move(metadata);
1289  }
1290 
1296  void set_compression_statistics(std::shared_ptr<writer_compression_statistics> comp_stats)
1297  {
1298  _compression_stats = std::move(comp_stats);
1299  }
1300 
1306  void set_enable_dictionary_sort(bool val) { _enable_dictionary_sort = val; }
1307 };
1308 
1314 
1315  public:
1322 
1328  explicit chunked_orc_writer_options_builder(sink_info const& sink) : options{sink} {}
1329 
1337  {
1338  options.set_compression(comp);
1339  return *this;
1340  }
1341 
1354  {
1355  options._stats_freq = val;
1356  return *this;
1357  }
1358 
1366  {
1367  options.set_stripe_size_bytes(val);
1368  return *this;
1369  }
1370 
1378  {
1379  options.set_stripe_size_rows(val);
1380  return *this;
1381  }
1382 
1390  {
1391  options.set_row_index_stride(val);
1392  return *this;
1393  }
1394 
1402  {
1403  options._metadata = std::move(meta);
1404  return *this;
1405  }
1406 
1414  std::map<std::string, std::string> metadata)
1415  {
1416  options._user_data = std::move(metadata);
1417  return *this;
1418  }
1419 
1427  std::shared_ptr<writer_compression_statistics> const& comp_stats)
1428  {
1429  options._compression_stats = comp_stats;
1430  return *this;
1431  }
1432 
1440  {
1441  options._enable_dictionary_sort = val;
1442  return *this;
1443  }
1444 
1448  operator chunked_orc_writer_options&&() { return std::move(options); }
1449 
1457  chunked_orc_writer_options&& build() { return std::move(options); }
1458 };
1459 
1482  public:
1488 
1493 
1502 
1513 
1517  void close();
1518 
1520  std::unique_ptr<orc::detail::writer> writer;
1521 };
1522  // end of group
1524 } // namespace io
1525 } // namespace CUDF_EXPORT cudf
Indicator for the logical data type of an element in a column.
Definition: types.hpp:286
The chunked orc reader class to read an ORC file iteratively into a series of tables,...
Definition: orc.hpp:468
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:1312
chunked_orc_writer_options_builder & enable_dictionary_sort(bool val)
Sets whether string dictionaries should be sorted.
Definition: orc.hpp:1439
chunked_orc_writer_options && build()
move chunked_orc_writer_options member once it's built.
Definition: orc.hpp:1457
chunked_orc_writer_options_builder & stripe_size_bytes(size_t val)
Sets the maximum stripe size, in bytes.
Definition: orc.hpp:1365
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:1377
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:1426
chunked_orc_writer_options_builder & key_value_metadata(std::map< std::string, std::string > metadata)
Sets Key-Value footer metadata.
Definition: orc.hpp:1413
chunked_orc_writer_options_builder & compression(compression_type comp)
Sets compression type.
Definition: orc.hpp:1336
chunked_orc_writer_options_builder & metadata(table_input_metadata meta)
Sets associated metadata.
Definition: orc.hpp:1401
chunked_orc_writer_options_builder(sink_info const &sink)
Constructor from sink and table.
Definition: orc.hpp:1328
chunked_orc_writer_options_builder & enable_statistics(statistics_freq val)
Choose granularity of statistics collection.
Definition: orc.hpp:1353
chunked_orc_writer_options_builder & row_index_stride(size_type val)
Sets the row index stride.
Definition: orc.hpp:1389
Settings to use for write_orc_chunked().
Definition: orc.hpp:1077
void set_stripe_size_bytes(size_t size_bytes)
Sets the maximum stripe size, in bytes.
Definition: orc.hpp:1237
chunked_orc_writer_options()=default
Default constructor.
void metadata(table_input_metadata meta)
Sets associated metadata.
Definition: orc.hpp:1279
void set_key_value_metadata(std::map< std::string, std::string > metadata)
Sets Key-Value footer metadata.
Definition: orc.hpp:1286
void set_compression_statistics(std::shared_ptr< writer_compression_statistics > comp_stats)
Sets the pointer to the output compression statistics.
Definition: orc.hpp:1296
sink_info const & get_sink() const
Returns sink info.
Definition: orc.hpp:1130
auto get_stripe_size_rows() const
Returns maximum stripe size, in rows.
Definition: orc.hpp:1158
auto get_row_index_stride() const
Returns the row index stride.
Definition: orc.hpp:1165
void set_row_index_stride(size_type stride)
Sets the row index stride.
Definition: orc.hpp:1268
statistics_freq get_statistics_freq() const
Returns granularity of statistics collection.
Definition: orc.hpp:1144
void set_compression(compression_type comp)
Sets compression type.
Definition: orc.hpp:1212
std::map< std::string, std::string > const & get_key_value_metadata() const
Returns Key-Value footer metadata information.
Definition: orc.hpp:1183
void set_enable_dictionary_sort(bool val)
Sets whether string dictionaries should be sorted.
Definition: orc.hpp:1306
auto const & get_metadata() const
Returns associated metadata.
Definition: orc.hpp:1176
bool get_enable_dictionary_sort() const
Returns whether string dictionaries should be sorted.
Definition: orc.hpp:1203
compression_type get_compression() const
Returns compression type.
Definition: orc.hpp:1137
void set_stripe_size_rows(size_type size_rows)
Sets the maximum stripe size, in rows.
Definition: orc.hpp:1253
std::shared_ptr< writer_compression_statistics > get_compression_statistics() const
Returns a shared pointer to the user-provided compression statistics.
Definition: orc.hpp:1193
auto get_stripe_size_bytes() const
Returns maximum stripe size, in bytes.
Definition: orc.hpp:1151
void enable_statistics(statistics_freq val)
Choose granularity of statistics collection.
Definition: orc.hpp:1228
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:1481
~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:1520
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:296
orc_reader_options_builder & use_index(bool use)
Enable/Disable use of row index to speed-up reading.
Definition: orc.hpp:368
orc_reader_options_builder & decimal128_columns(std::vector< std::string > val)
Columns that should be read as 128-bit Decimal.
Definition: orc.hpp:404
orc_reader_options_builder & use_np_dtypes(bool use)
Enable/Disable use of numpy-compatible dtypes.
Definition: orc.hpp:380
orc_reader_options_builder & ignore_timezone_in_stripe_footer(bool ignore)
Set whether to ignore writer timezone in the stripe footer.
Definition: orc.hpp:416
orc_reader_options_builder & skip_rows(int64_t rows)
Sets number of rows to skip from the start.
Definition: orc.hpp:344
orc_reader_options_builder()=default
Default constructor.
orc_reader_options_builder(source_info src)
Constructor from source info.
Definition: orc.hpp:312
orc_reader_options_builder & stripes(std::vector< std::vector< size_type >> stripes)
Sets list of individual stripes to read per source.
Definition: orc.hpp:332
orc_reader_options_builder & num_rows(int64_t nrows)
Sets number of row to read.
Definition: orc.hpp:356
orc_reader_options_builder & columns(std::vector< std::string > col_names)
Sets names of the column to read.
Definition: orc.hpp:320
orc_reader_options && build()
move orc_reader_options member once it's built.
Definition: orc.hpp:434
orc_reader_options_builder & timestamp_type(data_type type)
Sets timestamp type to which timestamp column will be cast.
Definition: orc.hpp:392
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
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:889
orc_writer_options_builder & table(table_view tbl)
Sets table to be written to output.
Definition: orc.hpp:981
orc_writer_options_builder & row_index_stride(size_type val)
Sets the row index stride.
Definition: orc.hpp:969
orc_writer_options_builder & enable_statistics(statistics_freq val)
Choose granularity of column statistics to be written.
Definition: orc.hpp:933
orc_writer_options_builder & metadata(table_input_metadata meta)
Sets associated metadata.
Definition: orc.hpp:993
orc_writer_options_builder(sink_info const &sink, table_view const &table)
Constructor from sink and table.
Definition: orc.hpp:906
orc_writer_options && build()
move orc_writer_options member once it's built.
Definition: orc.hpp:1048
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:1005
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:1017
orc_writer_options_builder & stripe_size_rows(size_type val)
Sets the maximum number of rows in output stripes.
Definition: orc.hpp:957
orc_writer_options_builder & enable_dictionary_sort(bool val)
Sets whether string dictionaries should be sorted.
Definition: orc.hpp:1030
orc_writer_options_builder & compression(compression_type comp)
Sets compression type.
Definition: orc.hpp:916
orc_writer_options_builder & stripe_size_bytes(size_t val)
Sets the maximum stripe size, in bytes.
Definition: orc.hpp:945
Settings to use for write_orc().
Definition: orc.hpp:623
void enable_statistics(statistics_freq val)
Choose granularity of statistics collection.
Definition: orc.hpp:798
auto const & get_metadata() const
Returns associated metadata.
Definition: orc.hpp:746
std::map< std::string, std::string > const & get_key_value_metadata() const
Returns Key-Value footer metadata information.
Definition: orc.hpp:753
std::shared_ptr< writer_compression_statistics > get_compression_statistics() const
Returns a shared pointer to the user-provided compression statistics.
Definition: orc.hpp:763
bool is_enabled_statistics() const
Whether writing column statistics is enabled/disabled.
Definition: orc.hpp:697
auto get_stripe_size_bytes() const
Returns maximum stripe size, in bytes.
Definition: orc.hpp:714
void set_stripe_size_rows(size_type size_rows)
Sets the maximum stripe size, in rows.
Definition: orc.hpp:823
void set_key_value_metadata(std::map< std::string, std::string > metadata)
Sets metadata.
Definition: orc.hpp:863
auto get_stripe_size_rows() const
Returns maximum stripe size, in rows.
Definition: orc.hpp:721
table_view get_table() const
Returns table to be written to output.
Definition: orc.hpp:739
void set_metadata(table_input_metadata meta)
Sets associated metadata.
Definition: orc.hpp:856
statistics_freq get_statistics_freq() const
Returns frequency of statistics collection.
Definition: orc.hpp:707
void set_compression_statistics(std::shared_ptr< writer_compression_statistics > comp_stats)
Sets the pointer to the output compression statistics.
Definition: orc.hpp:873
auto get_row_index_stride() const
Returns the row index stride.
Definition: orc.hpp:728
void set_table(table_view tbl)
Sets table to be written to output.
Definition: orc.hpp:849
orc_writer_options()=default
Default constructor.
void set_compression(compression_type comp)
Sets compression type.
Definition: orc.hpp:782
void set_enable_dictionary_sort(bool val)
Sets whether string dictionaries should be sorted.
Definition: orc.hpp:883
void set_row_index_stride(size_type stride)
Sets the row index stride.
Definition: orc.hpp:838
compression_type get_compression() const
Returns compression type.
Definition: orc.hpp:690
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:773
void set_stripe_size_bytes(size_t size_bytes)
Sets the maximum stripe size, in bytes.
Definition: orc.hpp:807
sink_info const & get_sink() const
Returns sink info.
Definition: orc.hpp:683
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:84
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.