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:
68  parquet_reader_options const& options);
69 
77  parquet_reader_options const& options);
78 
83 
89  [[nodiscard]] std::vector<FileMetaData> parquet_metadatas() const;
90 
96  [[nodiscard]] std::vector<byte_range_info> page_index_byte_ranges() const;
97 
104  cudf::host_span<cudf::host_span<uint8_t const> const> page_index_bytes) const;
105 
112  [[nodiscard]] std::vector<std::vector<size_type>> all_row_groups(
113  parquet_reader_options const& options) const;
114 
122  cudf::host_span<std::vector<size_type> const> row_group_indices) const;
123 
132 
144  [[nodiscard]] std::vector<std::vector<size_type>> filter_row_groups_with_byte_range(
145  cudf::host_span<std::vector<size_type> const> row_group_indices,
146  parquet_reader_options const& options) const;
147 
156  [[nodiscard]] std::vector<std::vector<size_type>> filter_row_groups_with_stats(
157  cudf::host_span<std::vector<size_type> const> row_group_indices,
158  parquet_reader_options const& options,
159  cuda::stream_ref stream) const;
160 
171  [[nodiscard]] std::pair<std::vector<byte_range_info>, std::vector<size_type>>
172  bloom_filters_byte_ranges(std::span<std::vector<size_type> const> row_group_indices,
173  parquet_reader_options const& options) const;
174 
186  [[nodiscard]] std::vector<std::vector<size_type>> filter_row_groups_with_bloom_filters(
187  std::span<cudf::device_span<uint8_t const> const> bloom_filter_data,
188  std::span<std::vector<size_type> const> row_group_indices,
189  parquet_reader_options const& options,
190  cuda::stream_ref stream) const;
191 
200  [[nodiscard]] std::pair<std::vector<byte_range_info>, std::vector<size_type>>
201  dictionary_pages_byte_ranges(cudf::host_span<std::vector<size_type> const> row_group_indices,
202  parquet_reader_options const& options) const;
203 
215  [[nodiscard]] std::vector<std::vector<size_type>> filter_row_groups_with_dictionary_pages(
216  cudf::host_span<cudf::device_span<uint8_t const> const> dictionary_page_data,
217  cudf::host_span<std::vector<size_type> const> row_group_indices,
218  parquet_reader_options const& options,
219  cuda::stream_ref stream) const;
220 
230  [[nodiscard]] std::unique_ptr<cudf::column> build_all_true_row_mask(
231  cudf::host_span<std::vector<size_type> const> row_group_indices,
232  cuda::stream_ref stream,
234 
246  [[nodiscard]] std::unique_ptr<cudf::column> build_row_mask_with_page_index_stats(
247  cudf::host_span<std::vector<size_type> const> row_group_indices,
248  parquet_reader_options const& options,
249  cuda::stream_ref stream,
251 
265  [[nodiscard]] std::pair<std::vector<byte_range_info>, std::vector<size_type>>
266  filter_column_chunks_byte_ranges(cudf::host_span<std::vector<size_type> const> row_group_indices,
267  parquet_reader_options const& options) const;
268 
285  cudf::host_span<std::vector<size_type> const> row_group_indices,
286  cudf::host_span<cudf::device_span<uint8_t const> const> column_chunk_data,
287  cudf::mutable_column_view& row_mask,
288  use_data_page_mask mask_data_pages,
289  parquet_reader_options const& options,
290  cuda::stream_ref stream,
292 
306  [[nodiscard]] std::pair<std::vector<byte_range_info>, std::vector<size_type>>
307  payload_column_chunks_byte_ranges(cudf::host_span<std::vector<size_type> const> row_group_indices,
308  parquet_reader_options const& options) const;
309 
325  [[nodiscard]] std::pair<std::vector<byte_range_info>, std::vector<size_type>>
326  payload_pages_byte_ranges(cudf::host_span<std::vector<size_type> const> row_group_indices,
327  cudf::column_view const& row_mask,
328  parquet_reader_options const& options,
329  cuda::stream_ref stream) const;
330 
346  cudf::host_span<std::vector<size_type> const> row_group_indices,
347  cudf::host_span<cudf::device_span<uint8_t const> const> column_chunk_data,
348  cudf::column_view const& row_mask,
349  use_data_page_mask mask_data_pages,
350  parquet_reader_options const& options,
351  cuda::stream_ref stream,
353 
362  [[nodiscard]] std::pair<std::vector<byte_range_info>, std::vector<size_type>>
363  all_column_chunks_byte_ranges(cudf::host_span<std::vector<size_type> const> row_group_indices,
364  parquet_reader_options const& options) const;
365 
378  cudf::host_span<std::vector<size_type> const> row_group_indices,
379  cudf::host_span<cudf::device_span<uint8_t const> const> column_chunk_data,
380  parquet_reader_options const& options,
381  cuda::stream_ref stream,
383 
402  std::size_t chunk_read_limit,
403  std::size_t pass_read_limit,
404  cudf::host_span<std::vector<size_type> const> row_group_indices,
405  cudf::column_view const& row_mask,
406  use_data_page_mask mask_data_pages,
407  cudf::host_span<cudf::device_span<uint8_t const> const> column_chunk_data,
408  parquet_reader_options const& options,
409  cuda::stream_ref stream,
411 
424  cudf::mutable_column_view& row_mask) const;
425 
444  std::size_t chunk_read_limit,
445  std::size_t pass_read_limit,
446  cudf::host_span<std::vector<size_type> const> row_group_indices,
447  cudf::column_view const& row_mask,
448  use_data_page_mask mask_data_pages,
449  cudf::host_span<cudf::device_span<uint8_t const> const> column_chunk_data,
450  parquet_reader_options const& options,
451  cuda::stream_ref stream,
453 
472  std::size_t chunk_read_limit,
473  std::size_t pass_read_limit,
474  cudf::host_span<std::vector<size_type> const> row_group_indices,
475  cudf::column_view const& row_mask,
477  parquet_reader_options const& options,
478  cuda::stream_ref stream,
480 
491  cudf::column_view const& row_mask) const;
492 
509  std::size_t chunk_read_limit,
510  std::size_t pass_read_limit,
511  cudf::host_span<std::vector<size_type> const> row_group_indices,
512  cudf::host_span<cudf::device_span<uint8_t const> const> column_chunk_data,
513  parquet_reader_options const& options,
514  cuda::stream_ref stream,
516 
523 
541  [[nodiscard]] std::vector<std::vector<std::vector<size_type>>> construct_row_group_passes(
542  cudf::host_span<std::vector<size_type> const> row_group_indices,
543  std::size_t pass_read_limit) const;
544 
550  [[nodiscard]] bool has_next_table_chunk() const;
551 
552  private:
553  std::unique_ptr<detail::hybrid_scan_reader_impl> _impl;
554 };
555  // end of group
557 
558 } // namespace io::parquet::experimental
559 } // 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.
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:300
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.