[python] Add SnapshotManager batch lookahead with get_snapshots_batch and find_next_scannable#7418
Merged
JingsongLi merged 3 commits intoapache:masterfrom Mar 13, 2026
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… and find_next_scannable Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2 tasks
Clarifying docstring
11 tasks
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.
Summary
SnapshotManager.get_snapshots_batch(snapshot_ids, max_workers=4): batch-checks existence of a list of snapshot files viafile_io.exists_batch(), then fetches the existing ones in parallel usingThreadPoolExecutor, returning{id: Snapshot|None}SnapshotManager.find_next_scannable(start_id, should_scan, lookahead_size=10, max_workers=4): looks aheadlookahead_sizesnapshot IDs, fetches them in one batch, and returns(snapshot, next_id, skipped_count)for the first snapshot passingshould_scanThese two methods are the performance foundation for
AsyncStreamingTableScan(coming in2c):exists_batchreplaces N serial file existence checks with a single round trip — important on object stores where per-call latency is significantCOMPACT,OVERWRITE) without a separate round trip per snapshotskipped_countin the return value enables the prefetch path in the streaming scan to submit the next lookahead fetch to a background thread while the consumer processes the current planStack context
This is part of a stack of PRs adding streaming read support to
paimon-python. Each PR is independently reviewable with a narrow scope:python-streaming-2a-changelog-producerChangelogProducerenum + config optionpython-streaming-2b-snapshot-lookaheadSnapshotManager.get_snapshots_batch()+find_next_scannable()python-streaming-2c-scan-and-builderAsyncStreamingTableScan,StreamReadBuilder,Table.new_stream_read_builder()python-streaming-2d-consumerpython-streaming-2e-acceptance-docsIncrementalDiffScanneracceptance tests + streaming docsTracking issue: #7152
Test plan
cd paimon-python && python -m pytest pypaimon/tests/snapshot_manager_test.py -vcd paimon-python && flake8 pypaimon/snapshot/snapshot_manager.py pypaimon/tests/snapshot_manager_test.py🤖 Generated with Claude Code