Skip to content

[FLINK-39168][cdc-connector-mysql] Cache splitId local variable to avoid redundant method calls in getFinishedSplitInfos #4288

Merged
lvyanquan merged 1 commit intoapache:masterfrom
ThorneANN:FLINK-39168-mysql-snapshotsplit-improve
Feb 27, 2026
Merged

[FLINK-39168][cdc-connector-mysql] Cache splitId local variable to avoid redundant method calls in getFinishedSplitInfos #4288
lvyanquan merged 1 commit intoapache:masterfrom
ThorneANN:FLINK-39168-mysql-snapshotsplit-improve

Conversation

@ThorneANN
Copy link
Contributor

Cache split.splitId() result in a local variable to avoid calling the method twice per iteration:

  • Clarity: Makes it explicit that both usages refer to the same value, improving readability.
  • Consistency: Eliminates any theoretical risk if splitId() were ever changed to a non-pure method in the future.
  • Minor efficiency: Avoids a redundant method dispatch on every iteration of the loop.

… method twice per iteration:

  - Clarity: Makes it explicit that both usages refer to the same value, improving readability.
  - Consistency: Eliminates any theoretical risk if splitId() were ever changed to a non-pure method in the future.
  - Minor efficiency: Avoids a redundant method dispatch on every iteration of the loop.
@ThorneANN ThorneANN changed the title [FLINK-39168][mysql] Cache splitId local variable to avoid redundant method calls in getFinishedSplitInfos [FLINK-39168][cdc-connector-mysql] Cache splitId local variable to avoid redundant method calls in getFinishedSplitInfos Feb 26, 2026
@ThorneANN
Copy link
Contributor Author

@Copilot review

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves readability and avoids redundant method calls in the MySQL CDC snapshot split assigner by caching split.splitId() in a local variable when building finished split metadata.

Changes:

  • Cache split.splitId() into a local splitId variable inside getFinishedSplitInfos().
  • Use the cached splitId for both map lookup (splitFinishedOffsets.get(...)) and FinishedSnapshotSplitInfo construction.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@lvyanquan lvyanquan left a comment

Choose a reason for hiding this comment

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

+1.

@lvyanquan lvyanquan merged commit ef9f977 into apache:master Feb 27, 2026
13 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants