hybrid_scan_multifile.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 
6 #pragma once
7 
9 #include <cudf/io/parquet.hpp>
12 #include <cudf/io/types.hpp>
13 #include <cudf/types.hpp>
14 #include <cudf/utilities/export.hpp>
15 
16 #include <rmm/resource_ref.hpp>
17 
18 #include <cuda/stream>
19 
20 #include <memory>
21 #include <span>
22 #include <utility>
23 #include <vector>
24 
30 namespace cudf::io::parquet::experimental::detail {
35 class hybrid_scan_reader_impl;
36 } // namespace cudf::io::parquet::experimental::detail
37 
40 
41 namespace CUDF_EXPORT cudf {
42 namespace io::parquet::experimental {
60  public:
70  parquet_reader_options const& options);
71 
81  parquet_reader_options const& options);
82 
91  explicit hybrid_scan_multifile(std::vector<FileMetaData>&& parquet_metadata,
92  parquet_reader_options const& options);
93 
98 
104  [[nodiscard]] std::vector<FileMetaData> parquet_metadatas() const;
105 
111  [[nodiscard]] std::vector<byte_range_info> page_index_byte_ranges() const;
112 
119  cudf::host_span<cudf::host_span<uint8_t const> const> page_index_bytes) const;
120 
127  [[nodiscard]] std::vector<std::vector<size_type>> all_row_groups(
128  parquet_reader_options const& options) const;
129 
137  cudf::host_span<std::vector<size_type> const> row_group_indices) const;
138 
147 
159  [[nodiscard]] std::vector<std::vector<size_type>> filter_row_groups_with_byte_range(
160  cudf::host_span<std::vector<size_type> const> row_group_indices,
161  parquet_reader_options const& options) const;
162 
171  [[nodiscard]] std::vector<std::vector<size_type>> filter_row_groups_with_stats(
172  cudf::host_span<std::vector<size_type> const> row_group_indices,
173  parquet_reader_options const& options,
174  cuda::stream_ref stream) const;
175 
186  [[nodiscard]] std::pair<std::vector<byte_range_info>, std::vector<size_type>>
187  bloom_filters_byte_ranges(std::span<std::vector<size_type> const> row_group_indices,
188  parquet_reader_options const& options) const;
189 
201  [[nodiscard]] std::vector<std::vector<size_type>> filter_row_groups_with_bloom_filters(
202  std::span<cudf::device_span<uint8_t const> const> bloom_filter_data,
203  std::span<std::vector<size_type> const> row_group_indices,
204  parquet_reader_options const& options,
205  cuda::stream_ref stream) const;
206 
215  [[nodiscard]] std::pair<std::vector<byte_range_info>, std::vector<size_type>>
216  dictionary_pages_byte_ranges(cudf::host_span<std::vector<size_type> const> row_group_indices,
217  parquet_reader_options const& options) const;
218 
230  [[nodiscard]] std::vector<std::vector<size_type>> filter_row_groups_with_dictionary_pages(
231  cudf::host_span<cudf::device_span<uint8_t const> const> dictionary_page_data,
232  cudf::host_span<std::vector<size_type> const> row_group_indices,
233  parquet_reader_options const& options,
234  cuda::stream_ref stream) const;
235 
245  [[nodiscard]] std::unique_ptr<cudf::column> build_all_true_row_mask(
246  cudf::host_span<std::vector<size_type> const> row_group_indices,
247  cuda::stream_ref stream,
249 
261  [[nodiscard]] std::unique_ptr<cudf::column> build_row_mask_with_page_index_stats(
262  cudf::host_span<std::vector<size_type> const> row_group_indices,
263  parquet_reader_options const& options,
264  cuda::stream_ref stream,
266 
280  [[nodiscard]] std::pair<std::vector<byte_range_info>, std::vector<size_type>>
281  filter_column_chunks_byte_ranges(cudf::host_span<std::vector<size_type> const> row_group_indices,
282  parquet_reader_options const& options) const;
283 
300  cudf::host_span<std::vector<size_type> const> row_group_indices,
301  cudf::host_span<cudf::device_span<uint8_t const> const> column_chunk_data,
302  cudf::mutable_column_view& row_mask,
303  use_data_page_mask mask_data_pages,
304  parquet_reader_options const& options,
305  cuda::stream_ref stream,
307 
321  [[nodiscard]] std::pair<std::vector<byte_range_info>, std::vector<size_type>>
322  payload_column_chunks_byte_ranges(cudf::host_span<std::vector<size_type> const> row_group_indices,
323  parquet_reader_options const& options) const;
324 
340  [[nodiscard]] std::pair<std::vector<byte_range_info>, std::vector<size_type>>
341  payload_pages_byte_ranges(cudf::host_span<std::vector<size_type> const> row_group_indices,
342  cudf::column_view const& row_mask,
343  parquet_reader_options const& options,
344  cuda::stream_ref stream) const;
345 
361  cudf::host_span<std::vector<size_type> const> row_group_indices,
362  cudf::host_span<cudf::device_span<uint8_t const> const> column_chunk_data,
363  cudf::column_view const& row_mask,
364  use_data_page_mask mask_data_pages,
365  parquet_reader_options const& options,
366  cuda::stream_ref stream,
368 
377  [[nodiscard]] std::pair<std::vector<byte_range_info>, std::vector<size_type>>
378  all_column_chunks_byte_ranges(cudf::host_span<std::vector<size_type> const> row_group_indices,
379  parquet_reader_options const& options) const;
380 
393  cudf::host_span<std::vector<size_type> const> row_group_indices,
394  cudf::host_span<cudf::device_span<uint8_t const> const> column_chunk_data,
395  parquet_reader_options const& options,
396  cuda::stream_ref stream,
398 
417  std::size_t chunk_read_limit,
418  std::size_t pass_read_limit,
419  cudf::host_span<std::vector<size_type> const> row_group_indices,
420  cudf::column_view const& row_mask,
421  use_data_page_mask mask_data_pages,
422  cudf::host_span<cudf::device_span<uint8_t const> const> column_chunk_data,
423  parquet_reader_options const& options,
424  cuda::stream_ref stream,
426 
439  cudf::mutable_column_view& row_mask) const;
440 
459  std::size_t chunk_read_limit,
460  std::size_t pass_read_limit,
461  cudf::host_span<std::vector<size_type> const> row_group_indices,
462  cudf::column_view const& row_mask,
463  use_data_page_mask mask_data_pages,
464  cudf::host_span<cudf::device_span<uint8_t const> const> column_chunk_data,
465  parquet_reader_options const& options,
466  cuda::stream_ref stream,
468 
487  std::size_t chunk_read_limit,
488  std::size_t pass_read_limit,
489  cudf::host_span<std::vector<size_type> const> row_group_indices,
490  cudf::column_view const& row_mask,
492  parquet_reader_options const& options,
493  cuda::stream_ref stream,
495 
506  cudf::column_view const& row_mask) const;
507 
524  std::size_t chunk_read_limit,
525  std::size_t pass_read_limit,
526  cudf::host_span<std::vector<size_type> const> row_group_indices,
527  cudf::host_span<cudf::device_span<uint8_t const> const> column_chunk_data,
528  parquet_reader_options const& options,
529  cuda::stream_ref stream,
531 
538 
556  [[nodiscard]] std::vector<std::vector<std::vector<size_type>>> construct_row_group_passes(
557  cudf::host_span<std::vector<size_type> const> row_group_indices,
558  std::size_t pass_read_limit) const;
559 
565  [[nodiscard]] bool has_next_table_chunk() const;
566 
567  private:
568  std::unique_ptr<detail::hybrid_scan_reader_impl> _impl;
569 };
570  // end of group
572 
573 } // namespace io::parquet::experimental
574 } // namespace CUDF_EXPORT cudf
Class and helper functions for specifying a byte range within a data source.
A non-owning, immutable view of device data as a column of elements, some of which may be null as ind...
Multi-file variant of the experimental Hybrid Scan Parquet reader.
void setup_chunking_for_all_columns(std::size_t chunk_read_limit, std::size_t pass_read_limit, cudf::host_span< std::vector< size_type > const > row_group_indices, cudf::host_span< cudf::device_span< uint8_t const > const > column_chunk_data, parquet_reader_options const &options, cuda::stream_ref stream, rmm::device_async_resource_ref mr) const
Setup chunking information for all (or selected) columns and preprocess the input data pages.
std::pair< std::vector< byte_range_info >, std::vector< size_type > > all_column_chunks_byte_ranges(cudf::host_span< std::vector< size_type > const > row_group_indices, parquet_reader_options const &options) const
Get byte ranges of column chunks of all (or selected) columns.
hybrid_scan_multifile(cudf::host_span< FileMetaData const > parquet_metadata, parquet_reader_options const &options)
Constructor for the multi-file experimental Parquet reader.
std::vector< FileMetaData > parquet_metadatas() const
Get parquet metadatas for all sources.
table_with_metadata materialize_all_columns(cudf::host_span< std::vector< size_type > const > row_group_indices, cudf::host_span< cudf::device_span< uint8_t const > const > column_chunk_data, parquet_reader_options const &options, cuda::stream_ref stream, rmm::device_async_resource_ref mr) const
Materializes all (or selected) columns and returns the final output table.
void setup_chunking_for_payload_columns(std::size_t chunk_read_limit, std::size_t pass_read_limit, cudf::host_span< std::vector< size_type > const > row_group_indices, cudf::column_view const &row_mask, use_data_page_mask mask_data_pages, cudf::host_span< cudf::device_span< uint8_t const > const > column_chunk_data, parquet_reader_options const &options, cuda::stream_ref stream, rmm::device_async_resource_ref mr) const
Setup chunking information for payload columns and preprocess the input data pages.
std::vector< std::vector< size_type > > filter_row_groups_with_dictionary_pages(cudf::host_span< cudf::device_span< uint8_t const > const > dictionary_page_data, cudf::host_span< std::vector< size_type > const > row_group_indices, parquet_reader_options const &options, cuda::stream_ref stream) const
Filter the row groups using column chunk dictionary pages.
void setup_chunking_for_payload_columns(std::size_t chunk_read_limit, std::size_t pass_read_limit, cudf::host_span< std::vector< size_type > const > row_group_indices, cudf::column_view const &row_mask, cudf::host_span< cudf::device_span< uint8_t const > const > page_data, parquet_reader_options const &options, cuda::stream_ref stream, rmm::device_async_resource_ref mr) const
Setup chunking information for payload columns and preprocess the input data pages.
bool has_next_table_chunk() const
Check if there is any parquet data left to read for the current chunked setup.
size_type total_rows_in_row_groups(cudf::host_span< std::vector< size_type > const > row_group_indices) const
Get the total number of top-level rows in the per-source row groups.
void reset_column_selection() const
Resets the current column selection.
table_with_metadata materialize_payload_columns(cudf::host_span< std::vector< size_type > const > row_group_indices, cudf::host_span< cudf::device_span< uint8_t const > const > column_chunk_data, cudf::column_view const &row_mask, use_data_page_mask mask_data_pages, parquet_reader_options const &options, cuda::stream_ref stream, rmm::device_async_resource_ref mr) const
Materialize payload columns and applies the row mask to the output table.
table_with_metadata materialize_filter_columns(cudf::host_span< std::vector< size_type > const > row_group_indices, cudf::host_span< cudf::device_span< uint8_t const > const > column_chunk_data, cudf::mutable_column_view &row_mask, use_data_page_mask mask_data_pages, parquet_reader_options const &options, cuda::stream_ref stream, rmm::device_async_resource_ref mr) const
Materializes filter columns and updates the input row mask to only the rows that exist in the output ...
std::vector< std::vector< size_type > > all_row_groups(parquet_reader_options const &options) const
Get all available per-source row group indices from the parquet files.
std::pair< std::vector< byte_range_info >, std::vector< size_type > > bloom_filters_byte_ranges(std::span< std::vector< size_type > const > row_group_indices, parquet_reader_options const &options) const
Get byte ranges of bloom filters for row group pruning.
std::vector< std::vector< size_type > > filter_row_groups_with_stats(cudf::host_span< std::vector< size_type > const > row_group_indices, parquet_reader_options const &options, cuda::stream_ref stream) const
Filter the input row groups using column chunk statistics.
std::unique_ptr< cudf::column > build_all_true_row_mask(cudf::host_span< std::vector< size_type > const > row_group_indices, cuda::stream_ref stream, rmm::device_async_resource_ref mr) const
Builds a boolean survival column of size equal to the total number of rows in the row groups containi...
std::vector< std::vector< size_type > > filter_row_groups_with_byte_range(cudf::host_span< std::vector< size_type > const > row_group_indices, parquet_reader_options const &options) const
Filter the row groups using the byte range specified by [bytes_to_skip, bytes_to_skip + bytes_to_read...
std::vector< byte_range_info > page_index_byte_ranges() const
Get byte ranges of the page index for all sources.
std::vector< std::vector< std::vector< size_type > > > construct_row_group_passes(cudf::host_span< std::vector< size_type > const > row_group_indices, std::size_t pass_read_limit) const
Partition row groups into passes such that the amount of GPU memory required to read,...
std::vector< std::vector< size_type > > filter_row_groups_with_bloom_filters(std::span< cudf::device_span< uint8_t const > const > bloom_filter_data, std::span< std::vector< size_type > const > row_group_indices, parquet_reader_options const &options, cuda::stream_ref stream) const
Filter the row groups using column chunk bloom filters.
table_with_metadata materialize_filter_columns_chunk(cudf::mutable_column_view &row_mask) const
Materializes a chunk of filter columns and updates the corresponding range of input row mask to only ...
void setup_page_indexes(cudf::host_span< cudf::host_span< uint8_t const > const > page_index_bytes) const
Setup the per-source page index within each Parquet file metadata.
hybrid_scan_multifile(std::vector< FileMetaData > &&parquet_metadata, parquet_reader_options const &options)
Constructor that takes ownership of pre-populated Parquet file metadata.
table_with_metadata materialize_payload_columns_chunk(cudf::column_view const &row_mask) const
Materializes a chunk of payload columns and applies the corresponding range of input row mask to the ...
~hybrid_scan_multifile()
Destructor for the multi-file experimental Parquet reader.
std::pair< std::vector< byte_range_info >, std::vector< size_type > > dictionary_pages_byte_ranges(cudf::host_span< std::vector< size_type > const > row_group_indices, parquet_reader_options const &options) const
Get byte ranges of column chunk dictionary pages for row group pruning.
table_with_metadata materialize_all_columns_chunk() const
Materializes a chunk of all (or selected) columns and returns the output table chunk.
std::pair< std::vector< byte_range_info >, std::vector< size_type > > payload_column_chunks_byte_ranges(cudf::host_span< std::vector< size_type > const > row_group_indices, parquet_reader_options const &options) const
Get byte ranges of column chunks of payload columns.
hybrid_scan_multifile(cudf::host_span< cudf::host_span< uint8_t const > const > footer_bytes, parquet_reader_options const &options)
Constructor for the multi-file experimental Parquet reader.
void setup_chunking_for_filter_columns(std::size_t chunk_read_limit, std::size_t pass_read_limit, cudf::host_span< std::vector< size_type > const > row_group_indices, cudf::column_view const &row_mask, use_data_page_mask mask_data_pages, cudf::host_span< cudf::device_span< uint8_t const > const > column_chunk_data, parquet_reader_options const &options, cuda::stream_ref stream, rmm::device_async_resource_ref mr) const
Setup chunking information for filter columns and preprocess the input data pages.
std::pair< std::vector< byte_range_info >, std::vector< size_type > > payload_pages_byte_ranges(cudf::host_span< std::vector< size_type > const > row_group_indices, cudf::column_view const &row_mask, parquet_reader_options const &options, cuda::stream_ref stream) const
Get byte ranges of pages of payload columns.
std::unique_ptr< cudf::column > build_row_mask_with_page_index_stats(cudf::host_span< std::vector< size_type > const > row_group_indices, parquet_reader_options const &options, cuda::stream_ref stream, rmm::device_async_resource_ref mr) const
Builds a boolean column indicating surviving rows using page-level statistics in the page index.
std::pair< std::vector< byte_range_info >, std::vector< size_type > > filter_column_chunks_byte_ranges(cudf::host_span< std::vector< size_type > const > row_group_indices, parquet_reader_options const &options) const
Get byte ranges of column chunks of filter columns.
Information about content of a parquet file.
Settings for read_parquet().
Definition: parquet.hpp:70
stores offset and size used to indicate a byte range
A non-owning, mutable view of device data as a column of elements, some of which may be null as indic...
use_data_page_mask
Whether to compute and use a page mask using the row mask to skip decompression and decoding of the m...
Definition: hybrid_scan.hpp:56
cuda::mr::resource_ref< cuda::mr::device_accessible > device_async_resource_ref
cuda::std::span< T, Extent > device_span
Device span is an alias of cuda::std::span.
Definition: span.hpp:302
int32_t size_type
Row index type for columns and tables.
Definition: types.hpp:76
Experimental Hybrid Scan Parquet reader optimized for highly selective filters.
Type definitions for the cuDF-IO API.
cuDF interfaces
Definition: host_udf.hpp:27
APIs for reading and writing Parquet files.
Parquet footer schema structs.
Host span, a non-owning view over a contiguous sequence of host-accessible elements.
Definition: span.hpp:65
Table with table metadata used by io readers to return the metadata by value.
Definition: types.hpp:271
Type declarations for libcudf.