Repository navigation
perf(pyarrow): group delete positions by file_path in a single pass - #3989
ArulJerald wants to merge 1 commit into
Conversation
_read_deletes built its result with a dict comprehension that filtered the whole delete table once per distinct file_path, making the cost O(rows x distinct paths). A delete file referencing many data files therefore degraded quadratically. The ORC branch had the same shape via unique(). Group by file_path instead, which is a single pass and lets both the Parquet and ORC branches share one code path. Dictionary encoding of file_path is retained, since delete files commonly repeat a small number of long paths across many rows; dictionaries are unified first because grouping cannot combine differing ones. Closes apache#3983
|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that's incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions. |
|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that's incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions. |
_read_deletesbuilt its result with a dict comprehension that filtered the whole delete table once per distinctfile_path, making the cost O(rows × distinct paths). A delete file referencing many data files therefore degraded quadratically. The ORC branch had the same shape viaunique().Closes #3983
Rationale for this change
Grouping by
file_pathis a single pass over the table, and it lets the Parquet and ORC branches share one code path instead of duplicating the per-path filter.Dictionary encoding of
file_pathis retained rather than dropped: positional delete files commonly repeat a small number of long paths across many rows, where the encoding is a substantial memory saving (measured ~24 MB vs ~198 MB on 2M rows referencing 2 distinct paths). Dictionaries are unified before grouping, since grouping raisesArrowNotImplementedError: Unifying differing dictionarieswhen chunks carry different ones.Are these changes tested?
Yes. Added
test_read_deletes_many_distinct_file_pathsintests/io/test_pyarrow.py, parametrized over Parquet and ORC, covering a delete file with 200 distinctfile_pathvalues and asserting the grouped positions are correct per path. The existingtest_read_deletes,test_delete, andtest_delete_duplicatescases continue to pass for both formats.Are there any user-facing changes?
No. This is an internal performance change;
_read_deletesreturns the same mapping offile_pathto positions as before.