-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add hybrid scan multifile two-step materializers #22833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
121bf9d
Add hybrid scan multifile reader basics
mhaseeb123 b763cdb
Minor
mhaseeb123 c9bf419
Clean up claude's comments
mhaseeb123 795f058
Add gtests
mhaseeb123 ec0b59e
Merge branch 'main' into fea/hybrid-scan-multifile-base
mhaseeb123 f8b90ea
Apply suggestions from code review
mhaseeb123 90aef61
Update cpp/src/io/parquet/experimental/hybrid_scan_multifile.cpp
mhaseeb123 8876f57
Apply suggestions from @PointKernel (thanks!)
mhaseeb123 a575276
Minor
mhaseeb123 c7d7cb6
Minor changes
mhaseeb123 467a628
Allow more than 2B rows
mhaseeb123 1909146
Minor bug fix
mhaseeb123 17fd247
Minor
mhaseeb123 0493395
Merge branch 'main' into fea/hybrid-scan-multifile-base
mhaseeb123 e0319ab
Merge branch 'main' into fea/hybrid-scan-multifile-base
mhaseeb123 bf25506
Merge branch 'main' into fea/hybrid-scan-multifile-base
mhaseeb123 e013fda
Add multifile row group filtering with stats and byte ranges
mhaseeb123 209a9e2
Merge branch 'main' into fea/hybrid-scan-multifile-row-group-filter-p…
mhaseeb123 c164897
Revert unneeded changes
mhaseeb123 7a35f6e
Style fix
mhaseeb123 8c7b183
Address comments
mhaseeb123 140e90d
Address review comments
mhaseeb123 9fcbb0a
Apply suggestions
mhaseeb123 a35f429
Style
mhaseeb123 269212c
Merge branch 'main' of https://github.com/rapidsai/cudf into fea/hybr…
mhaseeb123 0d404b1
Multifile hybrid scan APIs for row mask construction
mhaseeb123 db305f0
Simplify test
mhaseeb123 6b9d7af
Merge branch 'main' into fea/hybrid-scan-multifile-row-mask
mhaseeb123 48319ba
Multifile all column materializers for multifile hybrid scan
mhaseeb123 f9151ce
Doc updates
mhaseeb123 350047d
Merge branch 'main' into fea/column-chunk-byte-ranges
mhaseeb123 6cbf7ea
Merge branch 'main' into fea/column-chunk-byte-ranges
Matt711 db034d1
Add multifile hybrid scan two-step column materializers
mhaseeb123 1949b00
Merge branch 'main' into fea/two-step-materialize
mhaseeb123 f5875a1
Merge branch 'main' into fea/two-step-materialize
mhaseeb123 48c2eca
Merge branch 'main' into fea/two-step-materialize
mhaseeb123 13f0da6
Merge branch 'main' into fea/two-step-materialize
mhaseeb123 c641fa4
Style fix
mhaseeb123 f60af20
Minor
mhaseeb123 95c073d
Style
mhaseeb123 4544e87
Merge branch 'main' into fea/two-step-materialize
mhaseeb123 f62f443
Merge branch 'main' into fea/two-step-materialize
mhaseeb123 e0552ec
Merge branch 'main' into fea/two-step-materialize
mhaseeb123 9b0722c
Apply suggestions
mhaseeb123 5b86957
Merge branch 'main' into fea/two-step-materialize
mhaseeb123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
164 changes: 164 additions & 0 deletions
164
cpp/tests/io/experimental/hybrid_scan_multifile_composer.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,164 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #include "hybrid_scan_multifile_composer.hpp" | ||
|
|
||
| #include "hybrid_scan_multifile_common.hpp" | ||
|
|
||
| #include <cudf/io/experimental/hybrid_scan_multifile.hpp> | ||
| #include <cudf/io/parquet.hpp> | ||
| #include <cudf/io/parquet_io_utils.hpp> | ||
| #include <cudf/io/text/byte_range_info.hpp> | ||
| #include <cudf/utilities/error.hpp> | ||
|
|
||
| #include <rmm/device_buffer.hpp> | ||
|
|
||
| #include <algorithm> | ||
| #include <cstddef> | ||
| #include <memory> | ||
| #include <vector> | ||
|
|
||
| using cudf::io::parquet::experimental::use_data_page_mask; | ||
|
|
||
| namespace { | ||
|
|
||
| /** | ||
| * @brief Device buffers and spans from multiple input sources | ||
| */ | ||
| struct multisource_device_data { | ||
| std::vector<rmm::device_buffer> buffers; | ||
| std::vector<std::vector<cudf::device_span<uint8_t const>>> per_source_spans; | ||
| std::vector<cudf::device_span<uint8_t const>> flat_spans; | ||
| }; | ||
|
|
||
| /** | ||
| * @brief Groups a flat byte range list by source using the specified source map | ||
| */ | ||
| std::vector<std::vector<cudf::io::text::byte_range_info>> group_byte_ranges_by_source( | ||
| std::pair<std::vector<cudf::io::text::byte_range_info>, std::vector<cudf::size_type>> const& | ||
| byte_ranges_and_source_map, | ||
| std::size_t num_sources) | ||
| { | ||
| auto const& [byte_ranges, source_map] = byte_ranges_and_source_map; | ||
| CUDF_EXPECTS(byte_ranges.size() == source_map.size(), "Invalid source map size"); | ||
|
|
||
| auto byte_ranges_per_source = | ||
| std::vector<std::vector<cudf::io::text::byte_range_info>>(num_sources); | ||
| std::for_each(byte_ranges.begin(), | ||
| byte_ranges.end(), | ||
| [&, range_index = std::size_t{0}](auto const& range) mutable { | ||
| auto const source_index = source_map[range_index++]; | ||
| CUDF_EXPECTS(source_index >= 0 and static_cast<std::size_t>(source_index) < | ||
| byte_ranges_per_source.size(), | ||
| "Invalid byte range source index"); | ||
| byte_ranges_per_source[source_index].push_back(range); | ||
| }); | ||
| return byte_ranges_per_source; | ||
| } | ||
|
|
||
| /** | ||
| * @brief Fetches byte ranges from multiple sources and returns per-source and flattened spans | ||
| */ | ||
| multisource_device_data fetch_multisource_device_data( | ||
| multifile_inputs const& inputs, | ||
| std::pair<std::vector<cudf::io::text::byte_range_info>, std::vector<cudf::size_type>> const& | ||
| byte_ranges_and_source_map, | ||
| rmm::cuda_stream_view stream, | ||
| rmm::device_async_resource_ref mr) | ||
| { | ||
| auto const byte_ranges_per_source = | ||
| group_byte_ranges_by_source(byte_ranges_and_source_map, inputs.datasources.size()); | ||
| auto [buffers, per_source_spans, tasks] = cudf::io::parquet::fetch_byte_ranges_to_device_async( | ||
| inputs.datasource_refs, | ||
| cudf::host_span<std::vector<cudf::io::text::byte_range_info> const>{byte_ranges_per_source}, | ||
| stream, | ||
| mr); | ||
| tasks.get(); | ||
|
|
||
| auto flat_spans = std::vector<cudf::device_span<uint8_t const>>{}; | ||
| for (auto const& source_spans : per_source_spans) { | ||
| flat_spans.insert(flat_spans.end(), source_spans.begin(), source_spans.end()); | ||
| } | ||
|
|
||
| return {std::move(buffers), std::move(per_source_spans), std::move(flat_spans)}; | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| std::tuple<std::unique_ptr<cudf::table>, std::unique_ptr<cudf::table>> hybrid_scan_multifile( | ||
| cudf::io::source_info const& source_info, | ||
| cudf::ast::operation const& filter_expression, | ||
| std::optional<std::vector<std::string>> const& payload_column_names, | ||
| bool case_sensitive_names, | ||
| rmm::cuda_stream_view stream, | ||
| rmm::device_async_resource_ref mr) | ||
| { | ||
| auto options = cudf::io::parquet_reader_options::builder() | ||
| .filter(filter_expression) | ||
| .case_sensitive_names(case_sensitive_names) | ||
| .build(); | ||
| if (payload_column_names.has_value()) { options.set_column_names(payload_column_names.value()); } | ||
|
|
||
| auto inputs = multifile_inputs(source_info); | ||
| auto reader = | ||
| cudf::io::parquet::experimental::hybrid_scan_multifile{inputs.footer_byte_spans, options}; | ||
| setup_page_indexes(reader, inputs); | ||
|
|
||
| auto const input_row_groups = reader.all_row_groups(options); | ||
| auto const row_groups = reader.filter_row_groups_with_stats(input_row_groups, options, stream); | ||
| auto row_mask = reader.build_row_mask_with_page_index_stats(row_groups, options, stream, mr); | ||
|
|
||
| auto filter_column_chunks = fetch_multisource_device_data( | ||
| inputs, reader.filter_column_chunks_byte_ranges(row_groups, options), stream, mr); | ||
| auto row_mask_view = row_mask->mutable_view(); | ||
| auto filter_result = reader.materialize_filter_columns(row_groups, | ||
| filter_column_chunks.flat_spans, | ||
| row_mask_view, | ||
| use_data_page_mask::YES, | ||
| options, | ||
| stream, | ||
| mr); | ||
|
|
||
| auto payload_column_chunks = fetch_multisource_device_data( | ||
| inputs, reader.payload_column_chunks_byte_ranges(row_groups, options), stream, mr); | ||
| auto payload_result = reader.materialize_payload_columns(row_groups, | ||
| payload_column_chunks.flat_spans, | ||
| row_mask_view, | ||
| use_data_page_mask::YES, | ||
| options, | ||
| stream, | ||
| mr); | ||
|
|
||
| return std::tuple{std::move(filter_result.tbl), std::move(payload_result.tbl)}; | ||
| } | ||
|
|
||
| std::unique_ptr<cudf::table> hybrid_scan_multifile_single_step( | ||
| cudf::io::source_info const& source_info, | ||
| cudf::ast::operation const& filter_expression, | ||
| std::optional<std::vector<std::string>> const& column_names, | ||
| bool case_sensitive_names, | ||
| rmm::cuda_stream_view stream, | ||
| rmm::device_async_resource_ref mr) | ||
| { | ||
| auto options = cudf::io::parquet_reader_options::builder() | ||
| .filter(filter_expression) | ||
| .case_sensitive_names(case_sensitive_names) | ||
| .build(); | ||
| if (column_names.has_value()) { options.set_column_names(column_names.value()); } | ||
|
|
||
| auto inputs = multifile_inputs(source_info); | ||
| auto reader = | ||
| cudf::io::parquet::experimental::hybrid_scan_multifile{inputs.footer_byte_spans, options}; | ||
| setup_page_indexes(reader, inputs); | ||
|
|
||
| auto const input_row_groups = reader.all_row_groups(options); | ||
| auto const row_groups = reader.filter_row_groups_with_stats(input_row_groups, options, stream); | ||
|
|
||
| auto all_column_chunks = fetch_multisource_device_data( | ||
| inputs, reader.all_column_chunks_byte_ranges(row_groups, options), stream, mr); | ||
| return reader | ||
| .materialize_all_columns(row_groups, all_column_chunks.flat_spans, options, stream, mr) | ||
| .tbl; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please sort these files alphabetically.