Skip to content

[MINOR][CORE] Remove dead code across gluten-core#12590

Open
LuciferYang wants to merge 1 commit into
apache:mainfrom
LuciferYang:gluten-minor-core-remove-dead-code
Open

[MINOR][CORE] Remove dead code across gluten-core#12590
LuciferYang wants to merge 1 commit into
apache:mainfrom
LuciferYang:gluten-minor-core-remove-dead-code

Conversation

@LuciferYang

@LuciferYang LuciferYang commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Cleanup pass over gluten-core that removes three dead code paths surfaced by the Dead code / dead cases cross-cutting theme in the earlier L1/L2/L3 review docs. No behavior change on reachable paths.

  1. FloydWarshallGraph.Builder.Impl: drop the never-read private var graph field and its two graph = None writes in addVertex / addEdge. Remnant of an abandoned build-cache mechanism; the live cache is Transition.factory#graphCache.

  2. ConfigHelpers.TIME_STRING_PATTERN: drop the compiled Pattern plus its java.util.regex.Pattern import. timeFromString delegates to JavaUtils.timeStringAs; the regex has no reference.

  3. canPropagateConvention: rename five unused pattern vars p to _ in the case _: X => true arms.

Two changes from the initial version were dropped after review:

  • GlutenInjector.applier keeps val conf = new GlutenCoreConfig(...): instantiating it forces GlutenCoreConfig registration, so it is not safe to remove.
  • Transition.Factory#findTransition keeps the case _ branch as a guard against future additions to the sealed RowType / BatchType hierarchy.

How was this patch tested?

  • Existing tests; this is a no-op cleanup on reachable paths.
  • Compilation runs under -Wconf:any:e (fatal warnings): ./build/mvn -Pbackends-velox -Pspark-3.5 -pl gluten-core -am install -DskipTests.
  • ./dev/format-scala-code.sh: no additional diff.
  • Repo-wide grep verified zero references to TIME_STRING_PATTERN and to the removed FloydWarshallGraph.Builder.Impl.graph field.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude claude-opus-4-7

Copilot AI review requested due to automatic review settings July 21, 2026 11:49
@github-actions github-actions Bot added the CORE works for Gluten Core label Jul 21, 2026
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Copilot AI 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.

Pull request overview

Removes several unused / unreachable code paths in gluten-core identified via Scala unused warnings and prior dead-code review themes, aiming to reduce maintenance surface area without changing behavior for reachable paths.

Changes:

  • Removed unused GlutenCoreConfig instantiation/import from GlutenInjector.applier.
  • Removed unreachable fallback case _ in Transition.Factory#findTransition (sealed 2×2 requirement product already fully covered).
  • Cleaned up unused locals/pattern vars and removed an unused regex Pattern constant; removed an unused builder cache field in FloydWarshallGraph.Builder.Impl.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
gluten-core/src/main/scala/org/apache/gluten/extension/injector/GlutenInjector.scala Drops unused GlutenCoreConfig import/instantiation in applier.
gluten-core/src/main/scala/org/apache/gluten/extension/columnar/transition/Transition.scala Removes unreachable case _ branch in findTransition requirement matching.
gluten-core/src/main/scala/org/apache/gluten/extension/columnar/transition/package.scala Replaces unused pattern vars with _ in canPropagateConvention.
gluten-core/src/main/scala/org/apache/gluten/extension/columnar/transition/FloydWarshallGraph.scala Removes never-read cached graph field and invalidation writes in builder.
gluten-core/src/main/scala/org/apache/gluten/config/ConfigBuilder.scala Removes unused TIME_STRING_PATTERN and Pattern import; keeps delegation to JavaUtils.timeStringAs.

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

}

private def applier(session: SparkSession): ColumnarRuleApplier = {
val conf = new GlutenCoreConfig(session.sessionState.conf)

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 should not be removed, as this would register the GlutenCoreConfigs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reverted — kept the val conf instantiation. You're right that new GlutenCoreConfig(...) forces GlutenCoreConfig object initialization and its config registration, so removing it is not side-effect-free. Dropped this hunk from the PR.

Transition.empty
case _ =>
throw new UnsupportedOperationException(
s"Illegal convention requirement: $ConventionReq")

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 is a protect code, we can leave it here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reverted — kept the case _ guard. Agreed it's protective against future additions to the sealed RowType/BatchType hierarchy even though the current 2x2 is exhaustive. Dropped this hunk from the PR.

Cleanup pass over `gluten-core` that removes three dead code paths
surfaced by the `Dead code / dead cases` cross-cutting theme from the
earlier L1/L2/L3 review docs. No behavior change on reachable paths.

1. `FloydWarshallGraph.Builder.Impl`: drop the never-read `private var
   graph` field and its two `graph = None` writes in `addVertex` /
   `addEdge`. Remnant of an abandoned build-cache mechanism; the live
   cache is `Transition.factory#graphCache`.

2. `ConfigHelpers.TIME_STRING_PATTERN`: drop the compiled `Pattern`
   plus its `java.util.regex.Pattern` import. `timeFromString`
   delegates to `JavaUtils.timeStringAs`; the regex has no reference.

3. `canPropagateConvention`: rename five unused pattern vars `p` to `_`
   in the `case _: X => true` arms.

Dropped from the initial version after review:
- `GlutenInjector.applier` keeps `val conf = new GlutenCoreConfig(...)`
  since instantiating it forces `GlutenCoreConfig` registration.
- `Transition.Factory#findTransition` keeps the `case _` branch as a
  guard against future additions to the sealed RowType / BatchType
  hierarchy.
Copilot AI review requested due to automatic review settings July 22, 2026 05:53
@LuciferYang
LuciferYang force-pushed the gluten-minor-core-remove-dead-code branch from cac5067 to a7dedf6 Compare July 22, 2026 05:53
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Copilot AI 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.

Pull request overview

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

@jackylee-ch jackylee-ch 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.

Thanks.

@jackylee-ch

Copy link
Copy Markdown
Contributor

Run Gluten Clickhouse CI on x86

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

Labels

CORE works for Gluten Core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants