orc.hpp
Go to the documentation of this file.
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  * http://www.apache.org/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 
54 [[nodiscard]] bool is_supported_read_orc(compression_type compression);
55 
65 [[nodiscard]] bool is_supported_write_orc(compression_type compression);
66 
71 
76  source_info _source;
77 
78  // Names of column to read; `nullopt` is all
79  std::optional<std::vector<std::string>> _columns;
80 
81  // List of individual stripes to read (ignored if empty)
82  std::vector<std::vector<size_type>> _stripes;
83  // Rows to skip from the start
84  int64_t _skip_rows = 0;
85  // Rows to read; `nullopt` is all
86  std::optional<int64_t> _num_rows;
87 
88  // Whether to use row index to speed-up reading
89  bool _use_index = true;
90 
91  // Whether to use numpy-compatible dtypes
92  bool _use_np_dtypes = true;
93  // Cast timestamp columns to a specific type
94  data_type _timestamp_type{type_id::EMPTY};
95 
96  // Columns that should be read as Decimal128
97  std::vector<std::string> _decimal128_columns;
98 
100 
106  explicit orc_reader_options(source_info src) : _source{std::move(src)} {}
107 
108  public:
114  orc_reader_options() = default;
115 
123 
129  [[nodiscard]] source_info const& get_source() const { return _source; }
130 
136  [[nodiscard]] auto const& get_columns() const { return _columns; }
137 
143  [[nodiscard]] auto const& get_stripes() const { return _stripes; }
144 
150  [[nodiscard]] int64_t get_skip_rows() const { return _skip_rows; }
151 
158  [[nodiscard]] std::optional<int64_t> const& get_num_rows() const { return _num_rows; }
159 
165  [[nodiscard]] bool is_enabled_use_index() const { return _use_index; }
166 
172  [[nodiscard]] bool is_enabled_use_np_dtypes() const { return _use_np_dtypes; }
173 
179  [[nodiscard]] data_type get_timestamp_type() const { return _timestamp_type; }
180 
186  [[nodiscard]] std::vector<std::string> const& get_decimal128_columns() const
187  {
188  return _decimal128_columns;
189  }
190 
191  // Setters
192 
198  void set_columns(std::vector<std::string> col_names) { _columns = std::move(col_names); }
199 
210  void set_stripes(std::vector<std::vector<size_type>> stripes)
211  {
212  CUDF_EXPECTS(stripes.empty() or (_skip_rows == 0), "Can't set stripes along with skip_rows");
213  CUDF_EXPECTS(stripes.empty() or not _num_rows.has_value(),
214  "Can't set stripes along with num_rows");
215  _stripes = std::move(stripes);
216  }
217 
226  void set_skip_rows(int64_t rows)
227  {
228  CUDF_EXPECTS(rows >= 0, "skip_rows cannot be negative");
229  CUDF_EXPECTS(rows == 0 or _stripes.empty(), "Can't set both skip_rows along with stripes");
230  _skip_rows = rows;
231  }
232 
241  void set_num_rows(int64_t nrows)
242  {
243  CUDF_EXPECTS(nrows >= 0, "num_rows cannot be negative");
244  CUDF_EXPECTS(_stripes.empty(), "Can't set both num_rows and stripes");
245  _num_rows = nrows;
246  }
247 
253  void enable_use_index(bool use) { _use_index = use; }
254 
260  void enable_use_np_dtypes(bool use) { _use_np_dtypes = use; }
261 
267  void set_timestamp_type(data_type type) { _timestamp_type = type; }
268 
274  void set_decimal128_columns(std::vector<std::string> val)
275  {
276  _decimal128_columns = std::move(val);
277  }
278 };
279 
284  orc_reader_options options;
285 
286  public:
292  explicit orc_reader_options_builder() = default;
293 
299  explicit orc_reader_options_builder(source_info src) : options{std::move(src)} {}
300 
307  orc_reader_options_builder& columns(std::vector<std::string> col_names)
308  {
309  options._columns = std::move(col_names);
310  return *this;
311  }
312 
319  orc_reader_options_builder& stripes(std::vector<std::vector<size_type>> stripes)
320  {
321  options.set_stripes(std::move(stripes));
322  return *this;
323  }
324 
332  {
333  options.set_skip_rows(rows);
334  return *this;
335  }
336 
344  {
345  options.set_num_rows(nrows);
346  return *this;
347  }
348 
356  {
357  options._use_index = use;
358  return *this;
359  }
360 
368  {
369  options._use_np_dtypes = use;
370  return *this;
371  }
372 
380  {
381  options._timestamp_type = type;
382  return *this;
383  }
384 
391  orc_reader_options_builder& decimal128_columns(std::vector<std::string> val)
392  {
393  options._decimal128_columns = std::move(val);
394  return *this;
395  }
396 
400  operator orc_reader_options&&() { return std::move(options); }
401 
409  orc_reader_options&& build() { return std::move(options); }
410 };
411 
430  orc_reader_options const& options,
433 
444  public:
451 
497  std::size_t chunk_read_limit,
498  std::size_t pass_read_limit,
499  size_type output_row_granularity,
500  orc_reader_options const& options,
503 
519  std::size_t chunk_read_limit,
520  std::size_t pass_read_limit,
521  orc_reader_options const& options,
524 
538  std::size_t chunk_read_limit,
539  orc_reader_options const& options,
542 
547 
553  [[nodiscard]] bool has_next() const;
554 
566  [[nodiscard]] table_with_metadata read_chunk() const;
567 
568  private:
569  std::unique_ptr<cudf::io::orc::detail::chunked_reader> reader;
570 };
571  // end of group
583 
593 static constexpr statistics_freq ORC_STATISTICS_STRIPE = statistics_freq::STATISTICS_ROWGROUP;
594 static constexpr statistics_freq ORC_STATISTICS_ROW_GROUP = statistics_freq::STATISTICS_PAGE;
595 
600  // Specify the sink to use for writer output
601  sink_info _sink;
602  // Specify the compression format to use
603  compression_type _compression = compression_type::SNAPPY;
604  // Specify frequency of statistics collection
605  statistics_freq _stats_freq = ORC_STATISTICS_ROW_GROUP;
606  // Maximum size of each stripe (unless smaller than a single row group)
607  size_t _stripe_size_bytes = default_stripe_size_bytes;
608  // Maximum number of rows in stripe (unless smaller than a single row group)
609  size_type _stripe_size_rows = default_stripe_size_rows;
610  // Row index stride (maximum number of rows in each row group)
611  size_type _row_index_stride = default_row_index_stride;
612  // Set of columns to output
613  table_view _table;
614  // Optional associated metadata
615  std::optional<table_input_metadata> _metadata;
616  // Optional footer key_value_metadata
617  std::map<std::string, std::string> _user_data;
618  // Optional compression statistics
619  std::shared_ptr<writer_compression_statistics> _compression_stats;
620  // Specify whether string dictionaries should be alphabetically sorted
621  bool _enable_dictionary_sort = true;
622 
624 
632  : _sink(std::move(sink)), _table(std::move(table))
633  {
634  }
635 
636  public:
642  explicit orc_writer_options() = default;
643 
653 
659  [[nodiscard]] sink_info const& get_sink() const { return _sink; }
660 
666  [[nodiscard]] compression_type get_compression() const { return _compression; }
667 
673  [[nodiscard]] bool is_enabled_statistics() const
674  {
675  return _stats_freq != statistics_freq::STATISTICS_NONE;
676  }
677 
683  [[nodiscard]] statistics_freq get_statistics_freq() const { return _stats_freq; }
684 
690  [[nodiscard]] auto get_stripe_size_bytes() const { return _stripe_size_bytes; }
691 
697  [[nodiscard]] auto get_stripe_size_rows() const { return _stripe_size_rows; }
698 
704  [[nodiscard]] auto get_row_index_stride() const
705  {
706  auto const unaligned_stride = std::min(_row_index_stride, get_stripe_size_rows());
707  return unaligned_stride - unaligned_stride % 8;
708  }
709 
715  [[nodiscard]] table_view get_table() const { return _table; }
716 
722  [[nodiscard]] auto const& get_metadata() const { return _metadata; }
723 
729  [[nodiscard]] std::map<std::string, std::string> const& get_key_value_metadata() const
730  {
731  return _user_data;
732  }
733 
739  [[nodiscard]] std::shared_ptr<writer_compression_statistics> get_compression_statistics() const
740  {
741  return _compression_stats;
742  }
743 
749  [[nodiscard]] bool get_enable_dictionary_sort() const { return _enable_dictionary_sort; }
750 
751  // Setters
752 
759  {
760  _compression = comp;
761  if (comp == compression_type::AUTO) { _compression = compression_type::SNAPPY; }
762  }
763 
774  void enable_statistics(statistics_freq val) { _stats_freq = val; }
775 
783  void set_stripe_size_bytes(size_t size_bytes)
784  {
785  CUDF_EXPECTS(size_bytes >= 64 << 10, "64KB is the minimum stripe size");
786  _stripe_size_bytes = size_bytes;
787  }
788 
800  {
801  CUDF_EXPECTS(size_rows >= 512, "Maximum stripe size cannot be smaller than 512");
802  _stripe_size_rows = size_rows;
803  }
804 
815  {
816  CUDF_EXPECTS(stride >= 512, "Row index stride cannot be smaller than 512");
817  _row_index_stride = stride;
818  }
819 
825  void set_table(table_view tbl) { _table = tbl; }
826 
832  void set_metadata(table_input_metadata meta) { _metadata = std::move(meta); }
833 
839  void set_key_value_metadata(std::map<std::string, std::string> metadata)
840  {
841  _user_data = std::move(metadata);
842  }
843 
849  void set_compression_statistics(std::shared_ptr<writer_compression_statistics> comp_stats)
850  {
851  _compression_stats = std::move(comp_stats);
852  }
853 
859  void set_enable_dictionary_sort(bool val) { _enable_dictionary_sort = val; }
860 };
861 
866  orc_writer_options options;
867 
868  public:
875 
882  orc_writer_options_builder(sink_info const& sink, table_view const& table) : options{sink, table}
883  {
884  }
885 
893  {
894  options.set_compression(comp);
895  return *this;
896  }
897 
910  {
911  options._stats_freq = val;
912  return *this;
913  }
914 
922  {
923  options.set_stripe_size_bytes(val);
924  return *this;
925  }
926 
934  {
935  options.set_stripe_size_rows(val);
936  return *this;
937  }
938 
946  {
947  options.set_row_index_stride(val);
948  return *this;
949  }
950 
958  {
959  options._table = tbl;
960  return *this;
961  }
962 
970  {
971  options._metadata = std::move(meta);
972  return *this;
973  }
974 
981  orc_writer_options_builder& key_value_metadata(std::map<std::string, std::string> metadata)
982  {
983  options._user_data = std::move(metadata);
984  return *this;
985  }
986 
994  std::shared_ptr<writer_compression_statistics> const& comp_stats)
995  {
996  options._compression_stats = comp_stats;
997  return *this;
998  }
999 
1007  {
1008  options._enable_dictionary_sort = val;
1009  return *this;
1010  }
1011 
1015  operator orc_writer_options&&() { return std::move(options); }
1016 
1024  orc_writer_options&& build() { return std::move(options); }
1025 };
1026 
1040 void write_orc(orc_writer_options const& options,
1042 
1047 
1052  // Specify the sink to use for writer output
1053  sink_info _sink;
1054  // Specify the compression format to use
1055  compression_type _compression = compression_type::SNAPPY;
1056  // Specify granularity of statistics collection
1057  statistics_freq _stats_freq = ORC_STATISTICS_ROW_GROUP;
1058  // Maximum size of each stripe (unless smaller than a single row group)
1059  size_t _stripe_size_bytes = default_stripe_size_bytes;
1060  // Maximum number of rows in stripe (unless smaller than a single row group)
1061  size_type _stripe_size_rows = default_stripe_size_rows;
1062  // Row index stride (maximum number of rows in each row group)
1063  size_type _row_index_stride = default_row_index_stride;
1064  // Optional associated metadata
1065  std::optional<table_input_metadata> _metadata;
1066  // Optional footer key_value_metadata
1067  std::map<std::string, std::string> _user_data;
1068  // Optional compression statistics
1069  std::shared_ptr<writer_compression_statistics> _compression_stats;
1070  // Specify whether string dictionaries should be alphabetically sorted
1071  bool _enable_dictionary_sort = true;
1072 
1074 
1080  chunked_orc_writer_options(sink_info sink) : _sink(std::move(sink)) {}
1081 
1082  public:
1088  explicit chunked_orc_writer_options() = default;
1089 
1098 
1104  [[nodiscard]] sink_info const& get_sink() const { return _sink; }
1105 
1111  [[nodiscard]] compression_type get_compression() const { return _compression; }
1112 
1118  [[nodiscard]] statistics_freq get_statistics_freq() const { return _stats_freq; }
1119 
1125  [[nodiscard]] auto get_stripe_size_bytes() const { return _stripe_size_bytes; }
1126 
1132  [[nodiscard]] auto get_stripe_size_rows() const { return _stripe_size_rows; }
1133 
1139  [[nodiscard]] auto get_row_index_stride() const
1140  {
1141  auto const unaligned_stride = std::min(_row_index_stride, get_stripe_size_rows());
1142  return unaligned_stride - unaligned_stride % 8;
1143  }
1144 
1150  [[nodiscard]] auto const& get_metadata() const { return _metadata; }
1151 
1157  [[nodiscard]] std::map<std::string, std::string> const& get_key_value_metadata() const
1158  {
1159  return _user_data;
1160  }
1161 
1167  [[nodiscard]] std::shared_ptr<writer_compression_statistics> get_compression_statistics() const
1168  {
1169  return _compression_stats;
1170  }
1171 
1177  [[nodiscard]] bool get_enable_dictionary_sort() const { return _enable_dictionary_sort; }
1178 
1179  // Setters
1180 
1187  {
1188  _compression = comp;
1189  if (comp == compression_type::AUTO) { _compression = compression_type::SNAPPY; }
1190  }
1191 
1202  void enable_statistics(statistics_freq val) { _stats_freq = val; }
1203 
1211  void set_stripe_size_bytes(size_t size_bytes)
1212  {
1213  CUDF_EXPECTS(size_bytes >= 64 << 10, "64KB is the minimum stripe size");
1214  _stripe_size_bytes = size_bytes;
1215  }
1216 
1228  {
1229  CUDF_EXPECTS(size_rows >= 512, "maximum stripe size cannot be smaller than 512");
1230  _stripe_size_rows = size_rows;
1231  }
1232 
1243  {
1244  CUDF_EXPECTS(stride >= 512, "Row index stride cannot be smaller than 512");
1245  _row_index_stride = stride;
1246  }
1247 
1253  void metadata(table_input_metadata meta) { _metadata = std::move(meta); }
1254 
1260  void set_key_value_metadata(std::map<std::string, std::string> metadata)
1261  {
1262  _user_data = std::move(metadata);
1263  }
1264 
1270  void set_compression_statistics(std::shared_ptr<writer_compression_statistics> comp_stats)
1271  {
1272  _compression_stats = std::move(comp_stats);
1273  }
1274 
1280  void set_enable_dictionary_sort(bool val) { _enable_dictionary_sort = val; }
1281 };
1282 
1288 
1289  public:
1296 
1302  explicit chunked_orc_writer_options_builder(sink_info const& sink) : options{sink} {}
1303 
1311  {
1312  options.set_compression(comp);
1313  return *this;
1314  }
1315 
1328  {
1329  options._stats_freq = val;
1330  return *this;
1331  }
1332 
1340  {
1341  options.set_stripe_size_bytes(val);
1342  return *this;
1343  }
1344 
1352  {
1353  options.set_stripe_size_rows(val);
1354  return *this;
1355  }
1356 
1364  {
1365  options.set_row_index_stride(val);
1366  return *this;
1367  }
1368 
1376  {
1377  options._metadata = std::move(meta);
1378  return *this;
1379  }
1380 
1388  std::map<std::string, std::string> metadata)
1389  {
1390  options._user_data = std::move(metadata);
1391  return *this;
1392  }
1393 
1401  std::shared_ptr<writer_compression_statistics> const& comp_stats)
1402  {
1403  options._compression_stats = comp_stats;
1404  return *this;
1405  }
1406 
1414  {
1415  options._enable_dictionary_sort = val;
1416  return *this;
1417  }
1418 
1422  operator chunked_orc_writer_options&&() { return std::move(options); }
1423 
1431  chunked_orc_writer_options&& build() { return std::move(options); }
1432 };
1433 
1456  public:
1462 
1467 
1476 
1484 
1488  void close();
1489 
1491  std::unique_ptr<orc::detail::writer> writer;
1492 };
1493  // end of group
1495 } // namespace io
1496 } // namespace CUDF_EXPORT cudf
Indicator for the logical data type of an element in a column.
Definition: types.hpp:243
The chunked orc reader class to read an ORC file iteratively into a series of tables,...
Definition: orc.hpp:443
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:1286
chunked_orc_writer_options_builder & enable_dictionary_sort(bool val)
Sets whether string dictionaries should be sorted.
Definition: orc.hpp:1413
chunked_orc_writer_options && build()
move chunked_orc_writer_options member once it's built.
Definition: orc.hpp:1431
chunked_orc_writer_options_builder & stripe_size_bytes(size_t val)
Sets the maximum stripe size, in bytes.
Definition: orc.hpp:1339
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:1351
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:1400
chunked_orc_writer_options_builder & key_value_metadata(std::map< std::string, std::string > metadata)
Sets Key-Value footer metadata.
Definition: orc.hpp:1387
chunked_orc_writer_options_builder & compression(compression_type comp)
Sets compression type.
Definition: orc.hpp:1310
chunked_orc_writer_options_builder & metadata(table_input_metadata meta)
Sets associated metadata.
Definition: orc.hpp:1375
chunked_orc_writer_options_builder(sink_info const &sink)
Constructor from sink and table.
Definition: orc.hpp:1302
chunked_orc_writer_options_builder & enable_statistics(statistics_freq val)
Choose granularity of statistics collection.
Definition: orc.hpp:1327
chunked_orc_writer_options_builder & row_index_stride(size_type val)
Sets the row index stride.
Definition: orc.hpp:1363
Settings to use for write_orc_chunked().
Definition: orc.hpp:1051
void set_stripe_size_bytes(size_t size_bytes)
Sets the maximum stripe size, in bytes.
Definition: orc.hpp:1211
chunked_orc_writer_options()=default
Default constructor.
void metadata(table_input_metadata meta)
Sets associated metadata.
Definition: orc.hpp:1253
void set_key_value_metadata(std::map< std::string, std::string > metadata)
Sets Key-Value footer metadata.
Definition: orc.hpp:1260
void set_compression_statistics(std::shared_ptr< writer_compression_statistics > comp_stats)
Sets the pointer to the output compression statistics.
Definition: orc.hpp:1270
sink_info const & get_sink() const
Returns sink info.
Definition: orc.hpp:1104
auto get_stripe_size_rows() const
Returns maximum stripe size, in rows.
Definition: orc.hpp:1132
auto get_row_index_stride() const
Returns the row index stride.
Definition: orc.hpp:1139
void set_row_index_stride(size_type stride)
Sets the row index stride.
Definition: orc.hpp:1242
statistics_freq get_statistics_freq() const
Returns granularity of statistics collection.
Definition: orc.hpp:1118
void set_compression(compression_type comp)
Sets compression type.
Definition: orc.hpp:1186
std::map< std::string, std::string > const & get_key_value_metadata() const
Returns Key-Value footer metadata information.
Definition: orc.hpp:1157
void set_enable_dictionary_sort(bool val)
Sets whether string dictionaries should be sorted.
Definition: orc.hpp:1280
auto const & get_metadata() const
Returns associated metadata.
Definition: orc.hpp:1150
bool get_enable_dictionary_sort() const
Returns whether string dictionaries should be sorted.
Definition: orc.hpp:1177
compression_type get_compression() const
Returns compression type.
Definition: orc.hpp:1111
void set_stripe_size_rows(size_type size_rows)
Sets the maximum stripe size, in rows.
Definition: orc.hpp:1227
std::shared_ptr< writer_compression_statistics > get_compression_statistics() const
Returns a shared pointer to the user-provided compression statistics.
Definition: orc.hpp:1167
auto get_stripe_size_bytes() const
Returns maximum stripe size, in bytes.
Definition: orc.hpp:1125
void enable_statistics(statistics_freq val)
Choose granularity of statistics collection.
Definition: orc.hpp:1202
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:1455
~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:1491
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:283
orc_reader_options_builder & use_index(bool use)
Enable/Disable use of row index to speed-up reading.
Definition: orc.hpp:355
orc_reader_options_builder & decimal128_columns(std::vector< std::string > val)
Columns that should be read as 128-bit Decimal.
Definition: orc.hpp:391
orc_reader_options_builder & use_np_dtypes(bool use)
Enable/Disable use of numpy-compatible dtypes.
Definition: orc.hpp:367
orc_reader_options_builder & skip_rows(int64_t rows)
Sets number of rows to skip from the start.
Definition: orc.hpp:331
orc_reader_options_builder()=default
Default constructor.
orc_reader_options_builder(source_info src)
Constructor from source info.
Definition: orc.hpp:299
orc_reader_options_builder & stripes(std::vector< std::vector< size_type >> stripes)
Sets list of individual stripes to read per source.
Definition: orc.hpp:319
orc_reader_options_builder & num_rows(int64_t nrows)
Sets number of row to read.
Definition: orc.hpp:343
orc_reader_options_builder & columns(std::vector< std::string > col_names)
Sets names of the column to read.
Definition: orc.hpp:307
orc_reader_options && build()
move orc_reader_options member once it's built.
Definition: orc.hpp:409
orc_reader_options_builder & timestamp_type(data_type type)
Sets timestamp type to which timestamp column will be cast.
Definition: orc.hpp:379
Settings to use for read_orc().
Definition: orc.hpp:75
int64_t get_skip_rows() const
Returns number of rows to skip from the start.
Definition: orc.hpp:150
orc_reader_options()=default
Default constructor.
void enable_use_np_dtypes(bool use)
Enable/Disable use of numpy-compatible dtypes.
Definition: orc.hpp:260
void set_num_rows(int64_t nrows)
Sets number of row to read.
Definition: orc.hpp:241
auto const & get_stripes() const
Returns vector of vectors, stripes to read for each input source.
Definition: orc.hpp:143
void set_decimal128_columns(std::vector< std::string > val)
Set columns that should be read as 128-bit Decimal.
Definition: orc.hpp:274
void set_skip_rows(int64_t rows)
Sets number of rows to skip from the start.
Definition: orc.hpp:226
void enable_use_index(bool use)
Enable/Disable use of row index to speed-up reading.
Definition: orc.hpp:253
void set_columns(std::vector< std::string > col_names)
Sets names of the column to read.
Definition: orc.hpp:198
void set_stripes(std::vector< std::vector< size_type >> stripes)
Sets list of stripes to read for each input source.
Definition: orc.hpp:210
data_type get_timestamp_type() const
Returns timestamp type to which timestamp column will be cast.
Definition: orc.hpp:179
auto const & get_columns() const
Returns names of the columns to read, if set.
Definition: orc.hpp:136
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:158
source_info const & get_source() const
Returns source info.
Definition: orc.hpp:129
bool is_enabled_use_np_dtypes() const
Whether to use numpy-compatible dtypes.
Definition: orc.hpp:172
bool is_enabled_use_index() const
Whether to use row index to speed-up reading.
Definition: orc.hpp:165
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:186
void set_timestamp_type(data_type type)
Sets timestamp type to which timestamp column will be cast.
Definition: orc.hpp:267
Builds settings to use for write_orc().
Definition: orc.hpp:865
orc_writer_options_builder & table(table_view tbl)
Sets table to be written to output.
Definition: orc.hpp:957
orc_writer_options_builder & row_index_stride(size_type val)
Sets the row index stride.
Definition: orc.hpp:945
orc_writer_options_builder & enable_statistics(statistics_freq val)
Choose granularity of column statistics to be written.
Definition: orc.hpp:909
orc_writer_options_builder & metadata(table_input_metadata meta)
Sets associated metadata.
Definition: orc.hpp:969
orc_writer_options_builder(sink_info const &sink, table_view const &table)
Constructor from sink and table.
Definition: orc.hpp:882
orc_writer_options && build()
move orc_writer_options member once it's built.
Definition: orc.hpp:1024
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:981
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:993
orc_writer_options_builder & stripe_size_rows(size_type val)
Sets the maximum number of rows in output stripes.
Definition: orc.hpp:933
orc_writer_options_builder & enable_dictionary_sort(bool val)
Sets whether string dictionaries should be sorted.
Definition: orc.hpp:1006
orc_writer_options_builder & compression(compression_type comp)
Sets compression type.
Definition: orc.hpp:892
orc_writer_options_builder & stripe_size_bytes(size_t val)
Sets the maximum stripe size, in bytes.
Definition: orc.hpp:921
Settings to use for write_orc().
Definition: orc.hpp:599
void enable_statistics(statistics_freq val)
Choose granularity of statistics collection.
Definition: orc.hpp:774
auto const & get_metadata() const
Returns associated metadata.
Definition: orc.hpp:722
std::map< std::string, std::string > const & get_key_value_metadata() const
Returns Key-Value footer metadata information.
Definition: orc.hpp:729
std::shared_ptr< writer_compression_statistics > get_compression_statistics() const
Returns a shared pointer to the user-provided compression statistics.
Definition: orc.hpp:739
bool is_enabled_statistics() const
Whether writing column statistics is enabled/disabled.
Definition: orc.hpp:673
auto get_stripe_size_bytes() const
Returns maximum stripe size, in bytes.
Definition: orc.hpp:690
void set_stripe_size_rows(size_type size_rows)
Sets the maximum stripe size, in rows.
Definition: orc.hpp:799
void set_key_value_metadata(std::map< std::string, std::string > metadata)
Sets metadata.
Definition: orc.hpp:839
auto get_stripe_size_rows() const
Returns maximum stripe size, in rows.
Definition: orc.hpp:697
table_view get_table() const
Returns table to be written to output.
Definition: orc.hpp:715
void set_metadata(table_input_metadata meta)
Sets associated metadata.
Definition: orc.hpp:832
statistics_freq get_statistics_freq() const
Returns frequency of statistics collection.
Definition: orc.hpp:683
void set_compression_statistics(std::shared_ptr< writer_compression_statistics > comp_stats)
Sets the pointer to the output compression statistics.
Definition: orc.hpp:849
auto get_row_index_stride() const
Returns the row index stride.
Definition: orc.hpp:704
void set_table(table_view tbl)
Sets table to be written to output.
Definition: orc.hpp:825
orc_writer_options()=default
Default constructor.
void set_compression(compression_type comp)
Sets compression type.
Definition: orc.hpp:758
void set_enable_dictionary_sort(bool val)
Sets whether string dictionaries should be sorted.
Definition: orc.hpp:859
void set_row_index_stride(size_type stride)
Sets the row index stride.
Definition: orc.hpp:814
compression_type get_compression() const
Returns compression type.
Definition: orc.hpp:666
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:749
void set_stripe_size_bytes(size_t size_bytes)
Sets the maximum stripe size, in bytes.
Definition: orc.hpp:783
sink_info const & get_sink() const
Returns sink info.
Definition: orc.hpp:659
Metadata for a table.
Definition: io/types.hpp:890
A set of cudf::column_view's of the same size.
Definition: table_view.hpp:200
A set of cudf::column's of the same size.
Definition: table.hpp:40
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:42
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: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())
Reads an ORC dataset into a set of columns.
constexpr size_t default_stripe_size_bytes
64MB default orc stripe size
Definition: orc.hpp:41
statistics_freq
Column statistics granularity type for parquet/orc writers.
Definition: io/types.hpp:96
compression_type
Compression algorithms.
Definition: io/types.hpp:57
@ STATISTICS_ROWGROUP
Per-Rowgroup column statistics.
Definition: io/types.hpp:98
@ STATISTICS_NONE
No column statistics.
Definition: io/types.hpp:97
@ STATISTICS_PAGE
Per-page column statistics.
Definition: io/types.hpp:99
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::async_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:178
int32_t size_type
Row index type for columns and tables.
Definition: types.hpp:95
cuDF-IO API type definitions
cuDF interfaces
Definition: host_udf.hpp:37
Destination information for write interfaces.
Definition: io/types.hpp:468
Source information for read interfaces.
Definition: io/types.hpp:327
Table with table metadata used by io readers to return the metadata by value.
Definition: io/types.hpp:303
Class definitions for (mutable)_table_view
Type declarations for libcudf.