Repository navigation
feat(data): Support split and parallel scans - Part-4: bounded parallel Arrow reader - #1167
Open
kamcheungting-db wants to merge 3 commits into
Open
kamcheungting-db wants to merge 3 commits into
kamcheungting-db wants to merge 3 commits into
Conversation
…el Arrow reader Add ParallelScanReader, which reads the groups of a FileScanTaskGroupStream with a fixed set of workers and returns one Arrow C stream. - Each worker owns a FileScanTaskReader with residual enforcement forced on. Workers claim groups through a planning token: only one calls the group stream at a time, outside all locks. - Completed batches enter an output queue bounded by batch count and by charged bytes. Producers are admitted in FIFO order; a batch larger than the byte budget is admitted only into an empty queue. - ArrowBatchSizer charges a batch as the checked sum of its Arrow buffer spans, after preflighting offsets, lengths, buffer counts, and every layout-dependent size product for overflow. List views and run-end encoded arrays are rejected. - Each task stream's schema is compared with the projected schema before its batches are read. - The first planning, read, schema, or sizing error stops new work, releases queued batches, and is reported from get_next as EIO with the file and byte range in get_last_error. Releasing the stream between callbacks stops and joins the workers. - iceberg_data now links Threads unconditionally. Co-authored-by: Isaac <no-reply@databricks.com>
…date GCC and AppleClang reject a template parameter that shares the member function's name. Also replace C-style arrays in the batch sizer tests. Co-authored-by: Isaac <no-reply@databricks.com>
Use std::cmp_* for signed/unsigned comparisons and std::ranges::is_sorted. Co-authored-by: Isaac <no-reply@databricks.com>
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What this PR does
Adds
ParallelScanReader(iceberg/data/parallel_scan_reader.h), which reads the groups of aFileScanTaskGroupStream(from #1113) with a fixed set of workers and returns one Arrow C stream.How it works
FileScanTaskReader. Residual filters are always enforced (apply_residualsis forced on). Each task stream's schema is compared with the projected schema before its batches are read.max_queued_batches) and by charged bytes (max_queued_bytes). Producers are admitted in FIFO order. A batch larger than the byte budget enters only an empty queue, as its sole batch. Zero-byte batches still count toward the batch limit. A worker holds at most one completed batch while it waits.ArrowBatchSizercharges a batch as the checked sum of the spans of all present buffers, including children, dictionaries, and variadic buffers. Before nanoarrow sizes anything, it checks offsets, lengths, buffer, child, and dictionary counts, and every layout-dependent size product for overflow. List views and run-end encoded arrays are rejected.get_nextasEIO, with the file and byte range inget_last_error(). Releasing the stream between callbacks stops the workers, releases batches that were not returned, and joins the threads; batches already returned stay valid. No callback, release, or join runs under a lock.iceberg_datanow linksThreads::Threadsunconditionally, including withICEBERG_SPDLOG=OFF.The queue limits bound admission, not process memory: format reader buffers, delete indexes, and arrays already returned to the caller are outside the budget. The header documents this, the per-worker memory estimate, and the preconditions (registered format factories, a
FileIOthat supports concurrent reads, immutable task metadata, a planning executor that outlives the stream, and matchingcase_sensitive).Tests
New
parallel_scan_test, which links onlyiceberg_dataand builds withICEBERG_BUILD_BUNDLE=OFF. It uses hand-built groups and a scoped fake reader registered for Parquet and Avro:ArrowBatchSizer: fixed width, sliced, variable width, nested, dictionary, string view, zero-column structs, unsupported list views, and overflow and malformed-count rejectionsThe suite passes repeatedly under ThreadSanitizer and AddressSanitizer with UndefinedBehaviorSanitizer, with the bundle and spdlog off. Real Parquet and Avro tables are covered in Part-5.
pre-commitis clean.Related
Part 1 #976 · Part 2a #1002 · Part 2b #1062 · Part 2c #1065 · Part 3 #1113 · Part 3.5 #1166 (makes residual evaluation scale across workers) · Part 5 #1168 (end-to-end validation and benchmark).
This pull request and its description were written by Isaac.