Skip to content

[hotfix] Optimize SchemaChangeEventVisitor to reduce class inflations#4350

Merged
lvyanquan merged 3 commits into
apache:masterfrom
yuxiqian:hotfix/optimize-visitors
Mar 30, 2026
Merged

[hotfix] Optimize SchemaChangeEventVisitor to reduce class inflations#4350
lvyanquan merged 3 commits into
apache:masterfrom
yuxiqian:hotfix/optimize-visitors

Conversation

@yuxiqian
Copy link
Copy Markdown
Member

This PR introduces generic SchemaChangeEventVisitor to reduce the amount of visitor classes, as we're likely to support more schema change events.

Copy link
Copy Markdown
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 refactors schema change event visiting to reduce the number of per-event visitor interfaces by introducing generic visitor handler types and a dedicated voidVisit dispatch for side-effect-only handlers.

Changes:

  • Replace per-event visitor interfaces with generic VisitorHandler / VoidVisitorHandler.
  • Add SchemaChangeEventVisitor.voidVisit(...) and migrate several call sites to it (serializer + Doris/Paimon/StarRocks metadata appliers).
  • Remove now-redundant per-event visitor interface classes.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/serializer/event/SchemaChangeEventSerializer.java Switch serialization dispatch to SchemaChangeEventVisitor.voidVisit(...) to avoid Void returns.
flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-starrocks/src/main/java/org/apache/flink/cdc/connectors/starrocks/sink/StarRocksMetadataApplier.java Use voidVisit + method references for schema change application dispatch.
flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-paimon/src/main/java/org/apache/flink/cdc/connectors/paimon/sink/PaimonMetadataApplier.java Use voidVisit + method references for schema change application dispatch.
flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-doris/src/main/java/org/apache/flink/cdc/connectors/doris/sink/DorisMetadataApplier.java Use voidVisit + method references for schema change application dispatch.
flink-cdc-common/src/main/java/org/apache/flink/cdc/common/event/visitor/VoidVisitorHandler.java Introduce generic void visitor handler interface.
flink-cdc-common/src/main/java/org/apache/flink/cdc/common/event/visitor/VisitorHandler.java Introduce generic visitor handler interface returning a value.
flink-cdc-common/src/main/java/org/apache/flink/cdc/common/event/visitor/SchemaChangeEventVisitor.java Update to generic handlers and add voidVisit(...) dispatch method.
flink-cdc-common/src/main/java/org/apache/flink/cdc/common/event/visitor/*EventVisitor.java Remove per-event visitor interfaces now replaced by generic handler types.
Comments suppressed due to low confidence (2)

flink-cdc-common/src/main/java/org/apache/flink/cdc/common/event/visitor/VoidVisitorHandler.java:25

  • VoidVisitorHandler is generic over any SchemaChangeEvent, but the Javadoc still refers to TruncateTableEvent and the TruncateTableEvent import is unused. This is misleading and may fail style checks; update the Javadoc to describe the generic handler and remove the unused import.
    flink-cdc-common/src/main/java/org/apache/flink/cdc/common/event/visitor/VisitorHandler.java:25
  • VisitorHandler is now a generic functional interface, but the Javadoc still says it's a visitor for TruncateTableEvent and the TruncateTableEvent import is unused. Please update the Javadoc to match the new purpose and remove the unused import to keep the file consistent with project style checks.

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

Copy link
Copy Markdown
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 73305fb into apache:master Mar 30, 2026
36 of 38 checks passed
ThorneANN pushed a commit to ThorneANN/flink-cdc that referenced this pull request Mar 31, 2026
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