Repository navigation
Conversation
Resolve effective ordering before physical planning and configure file partitioners at listing-task start. Keep ordered manifest rows in listing order while preserving duplicate reads and non-ordered packing. Signed-off-by: viiccwen <[email protected]>
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors order preservation in Ray Data's V2 datasources by introducing a start(preserve_order=...) method to the FilePartitioner interface, allowing partitioners to initialize their ordering strategy before processing inputs. This ensures correct behavior when order preservation is enabled after a read operation. The feedback highlights a potential IndexError in OnlineBinPacker if unit_ids is empty, and a missing datasource_v2 parameterization decorator on a new Parquet test.
Keep empty read-unit runs as separate manifest rows instead of indexing their empty unit ID tuples. Extend the existing ordering test with empty runs before and after non-empty runs. Signed-off-by: viiccwen <[email protected]>
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.
Description
Fix datasource V2 reads that can reorder files or chunks despite
preserve_order=True. Resolve effective ordering before physical planning and pass it explicitly to file partitioners, including ordering required byzip().Related issues
Fixes #68649.
Fixes #68648.
Fixes #68646.
Before
CSV, Text, and WebDataset selected their bucket count when the datasource was constructed; MCAP read ordering from the current global context during ingestion. Parquet's bin packer could reorder files and row groups within manifests. Ordering required by
zip()was enabled after planning, too late for listing and partitioning to use it.After
Dataset._execute_dag()resolves ordering before planning. Each listing task callsFilePartitioner.start(preserve_order=...)before its first manifest. RoundRobin uses one bucket for ordered reads; OnlineBinPacker uses next-fit packing and merges only adjacent, ascending runs of the same file. Both packing modes share manifest construction, and repeated paths retain their multiplicity.Data flow
flowchart TD subgraph Before subgraph BAPI["API: Dataset"] B1["_execute_dag: plan before enforcing ordering"] end subgraph BPlanning["Physical planning: ListFiles"] B2["Capture ordering before it is enforced"] end subgraph BIO["IO: datasource V2"] B3["Partitioners use early, global, or default ordering"] B4["ReadFiles consumes regrouped manifest rows"] end B1 --> B2 --> B3 --> B4 end subgraph After subgraph AAPI["API: Dataset"] A1["_execute_dag: resolve ordering before planning"] end subgraph APlanning["Physical planning: ListFiles"] A2["Capture effective ordering"] end subgraph AIO["IO: datasource V2"] A3["partition_files: FilePartitioner.start"] A4["Partitioners retain listing and unit order"] A5["ReadFiles consumes ordered manifest rows"] end A1 --> A2 --> A3 --> A4 --> A5 end classDef added fill:#c8e6c9,stroke:#2e7d32,color:#000 classDef changed fill:#fff9c4,stroke:#f9a825,color:#000 class A3 added class B1,B2,B3,A1,A2,A4 changed