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/cuda_stream_view.hpp>
17 #include <rmm/resource_ref.hpp>
18 
19 #include <memory>
20 #include <vector>
21 
27 namespace cudf::io::parquet::experimental::detail {
32 class hybrid_scan_reader_impl;
33 } // namespace cudf::io::parquet::experimental::detail
34 
37 
38 namespace CUDF_EXPORT cudf {
39 namespace io::parquet::experimental {
57  public:
65  parquet_reader_options const& options);
66 
74  parquet_reader_options const& options);
75 
80 
86  [[nodiscard]] std::vector<FileMetaData> parquet_metadatas() const;
87 
93  [[nodiscard]] std::vector<byte_range_info> page_index_byte_ranges() const;
94 
101  cudf::host_span<cudf::host_span<uint8_t const> const> page_index_bytes) const;
102 
109  [[nodiscard]] std::vector<std::vector<size_type>> all_row_groups(
110  parquet_reader_options const& options) const;
111 
119  cudf::host_span<std::vector<size_type> const> row_group_indices) const;
120 
129 
141  [[nodiscard]] std::vector<std::vector<size_type>> filter_row_groups_with_byte_range(
142  cudf::host_span<std::vector<size_type> const> row_group_indices,
143  parquet_reader_options const& options) const;
144 
153  [[nodiscard]] std::vector<std::vector<size_type>> filter_row_groups_with_stats(
154  cudf::host_span<std::vector<size_type> const> row_group_indices,
155  parquet_reader_options const& options,
156  rmm::cuda_stream_view stream) const;
157 
170  [[nodiscard]] std::pair<std::vector<byte_range_info>, std::vector<byte_range_info>>
171  secondary_filters_byte_ranges(cudf::host_span<std::vector<size_type> const> row_group_indices,
172  parquet_reader_options const& options) const;
173 
183  [[nodiscard]] std::unique_ptr<cudf::column> build_all_true_row_mask(
184  cudf::host_span<std::vector<size_type> const> row_group_indices,
185  rmm::cuda_stream_view stream,
187 
199  [[nodiscard]] std::unique_ptr<cudf::column> build_row_mask_with_page_index_stats(
200  cudf::host_span<std::vector<size_type> const> row_group_indices,
201  parquet_reader_options const& options,
202  rmm::cuda_stream_view stream,
204 
218  [[nodiscard]] std::pair<std::vector<byte_range_info>, std::vector<size_type>>
219  filter_column_chunks_byte_ranges(cudf::host_span<std::vector<size_type> const> row_group_indices,
220  parquet_reader_options const& options) const;
221 
238  cudf::host_span<std::vector<size_type> const> row_group_indices,
239  cudf::host_span<cudf::device_span<uint8_t const> const> column_chunk_data,
240  cudf::mutable_column_view& row_mask,
241  use_data_page_mask mask_data_pages,
242  parquet_reader_options const& options,
243  rmm::cuda_stream_view stream,
245 
259  [[nodiscard]] std::pair<std::vector<byte_range_info>, std::vector<size_type>>
260  payload_column_chunks_byte_ranges(cudf::host_span<std::vector<size_type> const> row_group_indices,
261  parquet_reader_options const& options) const;
262 
278  cudf::host_span<std::vector<size_type> const> row_group_indices,
279  cudf::host_span<cudf::device_span<uint8_t const> const> column_chunk_data,
280  cudf::column_view const& row_mask,
281  use_data_page_mask mask_data_pages,
282  parquet_reader_options const& options,
283  rmm::cuda_stream_view stream,
285 
294  [[nodiscard]] std::pair<std::vector<byte_range_info>, std::vector<size_type>>
295  all_column_chunks_byte_ranges(cudf::host_span<std::vector<size_type> const> row_group_indices,
296  parquet_reader_options const& options) const;
297 
310  cudf::host_span<std::vector<size_type> const> row_group_indices,
311  cudf::host_span<cudf::device_span<uint8_t const> const> column_chunk_data,
312  parquet_reader_options const& options,
313  rmm::cuda_stream_view stream,
315 
334  std::size_t chunk_read_limit,
335  std::size_t pass_read_limit,
336  cudf::host_span<std::vector<size_type> const> row_group_indices,
337  cudf::column_view const& row_mask,
338  use_data_page_mask mask_data_pages,
339  cudf::host_span<cudf::device_span<uint8_t const> const> column_chunk_data,
340  parquet_reader_options const& options,
341  rmm::cuda_stream_view stream,
343 
356  cudf::mutable_column_view& row_mask) const;
357 
376  std::size_t chunk_read_limit,
377  std::size_t pass_read_limit,
378  cudf::host_span<std::vector<size_type> const> row_group_indices,
379  cudf::column_view const& row_mask,
380  use_data_page_mask mask_data_pages,
381  cudf::host_span<cudf::device_span<uint8_t const> const> column_chunk_data,
382  parquet_reader_options const& options,
383  rmm::cuda_stream_view stream,
385 
396  cudf::column_view const& row_mask) const;
397 
414  std::size_t chunk_read_limit,
415  std::size_t pass_read_limit,
416  cudf::host_span<std::vector<size_type> const> row_group_indices,
417  cudf::host_span<cudf::device_span<uint8_t const> const> column_chunk_data,
418  parquet_reader_options const& options,
419  rmm::cuda_stream_view stream,
421 
428 
446  [[nodiscard]] std::vector<std::vector<std::vector<size_type>>> construct_row_group_passes(
447  cudf::host_span<std::vector<size_type> const> row_group_indices,
448  std::size_t pass_read_limit) const;
449 
455  [[nodiscard]] bool has_next_table_chunk() const;
456 
465  [[nodiscard]] std::pair<std::vector<byte_range_info>, std::vector<size_type>>
466  dictionary_pages_byte_ranges(cudf::host_span<std::vector<size_type> const> row_group_indices,
467  parquet_reader_options const& options) const;
468 
480  [[nodiscard]] std::vector<std::vector<size_type>> filter_row_groups_with_dictionary_pages(
481  cudf::host_span<cudf::device_span<uint8_t const> const> dictionary_page_data,
482  cudf::host_span<std::vector<size_type> const> row_group_indices,
483  parquet_reader_options const& options,
484  rmm::cuda_stream_view stream) const;
485 
486  private:
487  std::unique_ptr<detail::hybrid_scan_reader_impl> _impl;
488 };
489  // end of group
491 
492 } // namespace io::parquet::experimental
493 } // 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.
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, rmm::cuda_stream_view stream, rmm::device_async_resource_ref mr) const
Materialize payload columns and applies the row mask to the output table.
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.
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, rmm::cuda_stream_view 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< byte_range_info > > secondary_filters_byte_ranges(cudf::host_span< std::vector< size_type > const > row_group_indices, parquet_reader_options const &options) const
Get byte ranges of bloom filters and dictionary pages (secondary filters) for row group pruning.
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.
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, rmm::cuda_stream_view stream) const
Filter the input row groups using column chunk statistics.
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::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, rmm::cuda_stream_view stream, rmm::device_async_resource_ref mr) const
Builds a boolean column indicating surviving rows using page-level statistics in the page index.
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,...
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, rmm::cuda_stream_view stream, rmm::device_async_resource_ref mr) const
Setup chunking information for payload columns and preprocess the input data pages.
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_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, rmm::cuda_stream_view stream, rmm::device_async_resource_ref mr) const
Setup chunking information for all (or selected) columns and preprocess the input data pages.
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.
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, rmm::cuda_stream_view stream) const
Filter the row groups using column chunk dictionary pages.
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 ...
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, rmm::cuda_stream_view 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 ...
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, rmm::cuda_stream_view stream, rmm::device_async_resource_ref mr) const
Materializes all (or selected) columns and returns the final output table.
~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.
std::unique_ptr< cudf::column > build_all_true_row_mask(cudf::host_span< std::vector< size_type > const > row_group_indices, rmm::cuda_stream_view 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...
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.
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:50
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:296
int32_t size_type
Row index type for columns and tables.
Definition: types.hpp:84
Experimental Hybrid Scan Parquet reader optimized for highly selective filters.
Type definitions for the cuDF-IO API.
cuDF interfaces
Definition: host_udf.hpp:26
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.