Skip to content
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

Adds a closure method to TransformerLoader #1495

Merged

Conversation

christianc1
Copy link
Contributor

Adds a closure method to TransformerLoader to delegate generator stop signals to proxied loaders.

Change Log

Added

  • Adds method `TransformerLoader::closure()` to delegate generator stop signals to proxied loaders.

Fixed

Changed

Removed

Deprecated

Security


Description

This updates the TransformerLoader adding the TransformerLoader::closure() method. Many Loaders rely on being notified by the pipeline when the last set of Rows as been processed. For example, the JsonLoader adapter uses this method to output the array closure after outputting the rows. Now, TransformerLoader supports Loaders implementing the Closure interface.

Copy link
Contributor

github-actions bot commented Feb 22, 2025

Flow PHP - Benchmarks

Results of the benchmarks from this PR are compared with the results from 1.x branch.

Extractors
+-----------------------+-------------------+------+-----+-----------------+------------------+-----------------+
| benchmark             | subject           | revs | its | mem_peak        | mode             | rstdev          |
+-----------------------+-------------------+------+-----+-----------------+------------------+-----------------+
| CSVExtractorBench     | bench_extract_10k | 1    | 3   | 4.813mb +0.01%  | 553.534ms -1.23% | ±0.70% -25.19%  |
| JsonExtractorBench    | bench_extract_10k | 1    | 3   | 4.886mb +0.01%  | 1.065s +0.39%    | ±0.24% -28.61%  |
| ParquetExtractorBench | bench_extract_10k | 1    | 3   | 86.334mb +0.00% | 899.414ms +1.22% | ±0.64% +305.42% |
| TextExtractorBench    | bench_extract_10k | 1    | 3   | 4.543mb +0.01%  | 35.991ms +0.10%  | ±0.17% -79.17%  |
| XmlExtractorBench     | bench_extract_10k | 1    | 3   | 4.518mb +0.01%  | 605.098ms -0.79% | ±0.42% -46.10%  |
+-----------------------+-------------------+------+-----+-----------------+------------------+-----------------+
Transformers
+-----------------------------+--------------------------+------+-----+------------------+-----------------+----------------+
| benchmark                   | subject                  | revs | its | mem_peak         | mode            | rstdev         |
+-----------------------------+--------------------------+------+-----+------------------+-----------------+----------------+
| RenameEntryTransformerBench | bench_transform_10k_rows | 1    | 3   | 127.340mb +0.00% | 71.017ms +3.00% | ±0.99% -23.93% |
+-----------------------------+--------------------------+------+-----+------------------+-----------------+----------------+
Loaders
+--------------------+----------------+------+-----+------------------+------------------+-----------------+
| benchmark          | subject        | revs | its | mem_peak         | mode             | rstdev          |
+--------------------+----------------+------+-----+------------------+------------------+-----------------+
| CSVLoaderBench     | bench_load_10k | 1    | 3   | 64.013mb +0.00%  | 105.188ms +2.23% | ±0.92% +60.61%  |
| JsonLoaderBench    | bench_load_10k | 1    | 3   | 84.360mb +0.00%  | 96.199ms +2.85%  | ±0.71% -32.23%  |
| ParquetLoaderBench | bench_load_10k | 1    | 3   | 161.204mb +0.00% | 20.747s +0.87%   | ±0.20% -42.08%  |
| TextLoaderBench    | bench_load_10k | 1    | 3   | 18.010mb +0.00%  | 31.915ms +1.42%  | ±2.79% +623.65% |
+--------------------+----------------+------+-----+------------------+------------------+-----------------+
Building Blocks
+-------------------+----------------------------+------+-----+------------------+------------------+-----------------+
| benchmark         | subject                    | revs | its | mem_peak         | mode             | rstdev          |
+-------------------+----------------------------+------+-----+------------------+------------------+-----------------+
| EntryFactoryBench | bench_entry_factory        | 1    | 3   | 105.983mb +0.00% | 455.515ms -0.93% | ±1.67% -0.09%   |
| EntryFactoryBench | bench_entry_factory        | 1    | 3   | 55.173mb +0.00%  | 232.394ms -0.55% | ±1.90% +49.20%  |
| EntryFactoryBench | bench_entry_factory        | 1    | 3   | 14.695mb +0.00%  | 50.052ms +0.17%  | ±0.78% -33.80%  |
| TypeDetectorBench | bench_type_detector        | 1    | 3   | 43.883mb +0.00%  | 361.354ms +0.12% | ±0.62% +130.23% |
| TypeDetectorBench | bench_type_detector        | 1    | 3   | 11.693mb +0.00%  | 73.330ms -0.08%  | ±0.69% +29.25%  |
| RowsBench         | bench_chunk_10_on_10k      | 2    | 3   | 97.026mb +0.00%  | 3.458ms +7.42%   | ±2.98% +25.39%  |
| RowsBench         | bench_diff_left_1k_on_10k  | 2    | 3   | 114.313mb +0.00% | 185.084ms -0.89% | ±0.49% -69.12%  |
| RowsBench         | bench_diff_right_1k_on_10k | 2    | 3   | 97.033mb +0.00%  | 18.664ms -1.64%  | ±0.69% -46.12%  |
| RowsBench         | bench_drop_1k_on_10k       | 2    | 3   | 97.901mb +0.00%  | 1.564ms -5.14%   | ±2.80% -26.68%  |
| RowsBench         | bench_drop_right_1k_on_10k | 2    | 3   | 97.901mb +0.00%  | 1.588ms +10.31%  | ±1.51% +403.06% |
| RowsBench         | bench_entries_on_10k       | 2    | 3   | 96.062mb +0.00%  | 5.000ms +12.12%  | ±3.32% +47.57%  |
| RowsBench         | bench_filter_on_10k        | 2    | 3   | 96.591mb +0.00%  | 16.686ms +0.70%  | ±0.18% -85.19%  |
| RowsBench         | bench_find_on_10k          | 2    | 3   | 96.591mb +0.00%  | 16.833ms +2.93%  | ±0.79% +1.43%   |
| RowsBench         | bench_find_one_on_10k      | 10   | 3   | 95.282mb +0.00%  | 1.994μs +10.77%  | ±2.40% +0.00%   |
| RowsBench         | bench_first_on_10k         | 10   | 3   | 95.282mb +0.00%  | 0.400μs 0.00%    | ±0.00% 0.00%    |
| RowsBench         | bench_flat_map_on_1k       | 2    | 3   | 104.500mb +0.00% | 15.383ms +3.79%  | ±2.66% +195.02% |
| RowsBench         | bench_map_on_10k           | 2    | 3   | 134.567mb +0.00% | 75.912ms +2.09%  | ±1.38% +14.76%  |
| RowsBench         | bench_merge_1k_on_10k      | 2    | 3   | 97.110mb +0.00%  | 1.412ms +6.65%   | ±1.35% -43.48%  |
| RowsBench         | bench_partition_by_on_10k  | 2    | 3   | 100.413mb +0.00% | 65.864ms +2.77%  | ±0.93% +25.25%  |
| RowsBench         | bench_remove_on_10k        | 2    | 3   | 98.163mb +0.00%  | 3.910ms +6.26%   | ±0.86% -73.76%  |
| RowsBench         | bench_sort_asc_on_1k       | 2    | 3   | 95.575mb +0.00%  | 42.964ms +2.13%  | ±1.11% +12.31%  |
| RowsBench         | bench_sort_by_on_1k        | 2    | 3   | 95.576mb +0.00%  | 44.232ms +4.79%  | ±0.75% -35.61%  |
| RowsBench         | bench_sort_desc_on_1k      | 2    | 3   | 95.575mb +0.00%  | 44.261ms +4.44%  | ±0.99% +17.65%  |
| RowsBench         | bench_sort_entries_on_1k   | 2    | 3   | 97.722mb +0.00%  | 8.210ms -0.43%   | ±0.21% -65.56%  |
| RowsBench         | bench_sort_on_1k           | 2    | 3   | 95.472mb +0.00%  | 29.257ms -0.13%  | ±1.31% +72.53%  |
| RowsBench         | bench_take_1k_on_10k       | 10   | 3   | 95.282mb +0.00%  | 13.537μs +4.64%  | ±3.37% +56.20%  |
| RowsBench         | bench_take_right_1k_on_10k | 10   | 3   | 95.282mb +0.00%  | 15.734μs +4.17%  | ±1.31% -50.07%  |
| RowsBench         | bench_unique_on_1k         | 2    | 3   | 114.314mb +0.00% | 189.198ms +0.40% | ±1.94% +11.51%  |
+-------------------+----------------------------+------+-----+------------------+------------------+-----------------+

Copy link

codecov bot commented Feb 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.00%. Comparing base (457164b) to head (8dd1077).
Report is 2 commits behind head on 1.x.

Additional details and impacted files
@@           Coverage Diff           @@
##              1.x    #1495   +/-   ##
=======================================
  Coverage   83.00%   83.00%           
=======================================
  Files         677      677           
  Lines       18076    18079    +3     
=======================================
+ Hits        15004    15007    +3     
  Misses       3072     3072           
Components Coverage Δ
etl 86.00% <100.00%> (+<0.01%) ⬆️
cli 86.73% <ø> (ø)
lib-array-dot 94.53% <ø> (ø)
lib-azure-sdk 62.56% <ø> (ø)
lib-doctrine-dbal-bulk 90.11% <ø> (ø)
lib-filesystem 76.75% <ø> (ø)
lib-parquet 84.33% <ø> (ø)
lib-parquet-viewer 82.02% <ø> (ø)
lib-rdsl 87.09% <ø> (ø)
lib-snappy 90.69% <ø> (ø)
bridge-filesystem-async-aws 90.38% <ø> (ø)
bridge-filesystem-azure 89.92% <ø> (ø)
bridge-monolog-http 96.38% <ø> (ø)
symfony-http-foundation 74.19% <ø> (ø)
adapter-chartjs 86.45% <ø> (ø)
adapter-csv 89.57% <ø> (ø)
adapter-doctrine 88.08% <ø> (ø)
adapter-elasticsearch 97.19% <ø> (ø)
adapter-google-sheet 78.04% <ø> (ø)
adapter-http 59.15% <ø> (ø)
adapter-json 90.62% <ø> (ø)
adapter-logger 53.84% <ø> (ø)
adapter-meilisearch 97.75% <ø> (ø)
adapter-parquet 80.85% <ø> (ø)
adapter-text 84.44% <ø> (ø)
adapter-xml 83.15% <ø> (ø)

@norberttech
Copy link
Member

Good catch @christianc1!

Could you please add a test that would cover this behavior?

@norberttech norberttech added this to the 0.11.0 milestone Feb 23, 2025
@github-actions github-actions bot added size: S and removed size: XS labels Feb 23, 2025
@norberttech norberttech enabled auto-merge (squash) February 23, 2025 16:27
@norberttech
Copy link
Member

Thank you @christianc1 🙏
Also, if you are on our Discord Server please ping me so I can grant you a contributor role with access to channels only for contributors

@norberttech norberttech merged commit 48ec14a into flow-php:1.x Feb 23, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants