Skip to content

refactor(flink): simplify streaming write pipeline construction - #19579

Open
danny0405 wants to merge 1 commit into
apache:masterfrom
danny0405:discovery
Open

refactor(flink): simplify streaming write pipeline construction#19579
danny0405 wants to merge 1 commit into
apache:masterfrom
danny0405:discovery

Conversation

@danny0405

Copy link
Copy Markdown
Contributor

Describe the issue this Pull Request addresses

Pipelines.hoodieStreamWrite currently combines bucket-engine selection, data-write construction, and optional index-write construction in one nested method. This makes the pipeline topology harder to follow and duplicates the final bucket-write stage across simple and consistent-hashing bucket engines.

Summary and Changelog

This change makes the Flink streaming write pipeline construction easier to follow without changing its topology or behavior.

  • Extract the bucket-index pipeline into bucketStreamWrite.
  • Share the final bucket-write operator construction between simple and consistent-hashing bucket engines.
  • Extract optional record-index pipeline construction into addIndexWrite.
  • Replace nested return branches in bootstrap and bucket assignment selection with guard clauses.
  • Document the extracted pipeline stages with topology diagrams.
  • Add transformation-graph coverage for the consistent-hashing bucket write path.

No code was copied from another project.

Impact

No public API, user-facing behavior, configuration, storage format, or performance behavior changes. Operator names, UIDs, partitioning, parallelism, type information, and managed-memory declarations remain unchanged.

Risk Level

low. The change refactors pipeline construction while preserving the generated Flink operator graph. Focused graph tests cover normal writes, simple bucket writes, consistent-hashing bucket writes, record-level index routing, bulk inserts, and table-service pipelines.

Documentation Update

none. This is an internal refactor with Javadocs added for the extracted methods.

Testing

  • mvn -pl hudi-flink-datasource/hudi-flink -am -Drat.skip=true -DskipITs -Dtest=org.apache.hudi.sink.utils.TestPipelines -Dsurefire.failIfNoSpecifiedTests=false test (10 tests passed)
  • mvn -pl hudi-flink-datasource/hudi-flink -Drat.skip=true -DskipTests checkstyle:check
  • git diff --check

Contributor's checklist

  • Read through contributor's guide
  • Enough context is provided in the sections above
  • Adequate tests were added if applicable

@github-actions github-actions Bot added the size:M PR with lines of changes in (100, 300] label Aug 11, 2026

@hudi-agent hudi-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ 🤖 This review was generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.

Thanks for working on this! This PR refactors the Flink streaming write pipeline construction into bucketStreamWrite and addIndexWrite, shares the final bucket-write operator between the simple and consistent-hashing engines, and converts nested branches into guard clauses. I traced both bucket engine branches and the stream/index write path — operator names, UIDs, parallelism, type information, partitioner selection, the insert-overwrite guard, and managed-memory declarations all appear preserved, so the generated operator graph looks unchanged. No correctness issues found. A few style/readability suggestions in the inline comments. Please take a look, and this should be ready for a Hudi committer or PMC member to take it from here. A few minor naming nits below, but the refactor is clean and readable overall.

cc @yihua

declareManagedMemoryIfNecessary(
conf, writeDataStream, () -> OptionsResolver.getWriteBufferSizeInBytes(conf));

return isStreamingIndexWriteEnabled

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 nit: addIndexWrite uses a verb prefix while its sibling bucketStreamWrite reads as a noun/description — could you align them? Something like indexWritePipeline or buildIndexWriteStream would match the style of bucketStreamWrite and make it clearer these are both pipeline-builder helpers.

⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.

@codecov-commenter

codecov-commenter commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.85714% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.50%. Comparing base (dfc2106) to head (c595fc9).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...ain/java/org/apache/hudi/sink/utils/Pipelines.java 92.85% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master   #19579   +/-   ##
=========================================
  Coverage     77.49%   77.50%           
- Complexity    32784    32790    +6     
=========================================
  Files          2522     2522           
  Lines        139140   139145    +5     
  Branches      16723    16723           
=========================================
+ Hits         107832   107842   +10     
  Misses        23742    23742           
+ Partials       7566     7561    -5     
Components Coverage Δ
hudi-common 83.27% <ø> (+0.01%) ⬆️
hudi-client 82.74% <ø> (+0.01%) ⬆️
hudi-flink 85.74% <92.85%> (-0.01%) ⬇️
hudi-spark-datasource 70.59% <ø> (-0.01%) ⬇️
hudi-utilities 73.69% <ø> (+0.01%) ⬆️
hudi-cli 15.32% <ø> (ø)
hudi-hadoop 68.94% <ø> (ø)
hudi-sync 75.16% <ø> (ø)
hudi-io 79.36% <ø> (-0.10%) ⬇️
hudi-timeline-service 83.44% <ø> (ø)
hudi-cloud 64.06% <ø> (ø)
hudi-kafka-connect 53.20% <ø> (ø)
Flag Coverage Δ
common-and-other-modules 50.86% <82.85%> (+<0.01%) ⬆️
flink-integration-tests 49.18% <92.85%> (-0.01%) ⬇️
hadoop-mr-java-client 43.73% <ø> (+0.01%) ⬆️
integration-tests 13.56% <0.00%> (+<0.01%) ⬆️
spark-client-hadoop-common 50.38% <ø> (ø)
spark-java-tests 51.62% <ø> (+<0.01%) ⬆️
spark-scala-tests 45.97% <ø> (ø)
utilities 36.59% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ain/java/org/apache/hudi/sink/utils/Pipelines.java 93.72% <92.85%> (-0.64%) ⬇️

... and 20 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hudi-bot

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M PR with lines of changes in (100, 300]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants