[
https://issues.apache.org/jira/browse/CALCITE-7632?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Mihai Budiu resolved CALCITE-7632.
----------------------------------
Fix Version/s: 1.43.0
Resolution: Fixed
Fixed in
[https://github.com/apache/calcite/commit/c3e3e6b86bc6af7501ad7298fc4260b7557437c2]
Thank you for the contribution [~liuzhengri]
> Replace java.util.Stack with java.util.ArrayDeque in Pattern and
> TopDownRuleDriver
> ----------------------------------------------------------------------------------
>
> Key: CALCITE-7632
> URL: https://issues.apache.org/jira/browse/CALCITE-7632
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Reporter: Liu Zhengri
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.43.0
>
>
> Replace `java.util.Stack` with `java.util.ArrayDeque` in two locations,
> completing a TODO left in place since 2020.
> h3. Background
> In [CALCITE-4314|https://issues.apache.org/jira/browse/CALCITE-4314] (commit
> [e537246|https://github.com/apache/calcite/commit/e53724630af60566784e8aa7d8f56fe2932b12cc]),
> Vladimir Sitnikov enabled Error Prone checking for the Calcite codebase. He
> identified 2 remaining {{java.util.Stack}} usages as obsolete and added
> {{@SuppressWarnings("JdkObsolete")}} with {{// TODO: replace with Deque}} to
> suppress warnings. The commit message explicitly stated _"It should be
> replaced with Deque"_, but the actual refactoring was deferred.
> CALCITE-4314 was a broad static-analysis enablement issue — the Stack→Deque
> replacement was too granular to be tracked there specifically. This issue
> (CALCITE-7632) is a dedicated ticket to complete that deferred work.
> h3. Changes
> # {{core/src/main/java/org/apache/calcite/runtime/Pattern.java}}:
> {{Stack<Pattern>}} → {{Deque<Pattern>}} in {{PatternBuilder.stack}} field
> (used for SQL {{MATCH_RECOGNIZE}} NFA pattern matching)
> #
> {{core/src/main/java/org/apache/calcite/plan/volcano/TopDownRuleDriver.java}}:
> {{Stack<Task>}} → {{Deque<Task>}} in task queue (used for Volcano optimizer
> top-down Cascades-style optimization)
> Also removed the corresponding {{@SuppressWarnings("JdkObsolete")}}
> annotations and {{// TODO: replace with Deque}} comments.
> h3. Rationale
> * {{java.util.Stack}} extends {{Vector}} — all methods are {{synchronized}},
> adding unnecessary lock overhead in single-threaded contexts
> * {{ArrayDeque}} is non-synchronized, officially recommended by the Java
> documentation as a replacement for {{Stack}}
> * Eliminates Error Prone {{JdkObsolete}} warnings without suppression
> * Better memory expansion: {{ArrayDeque}} doubles capacity on resize vs
> {{Vector}}'s linear growth
> h3. Related
> * PR: [#5062|https://github.com/apache/calcite/pull/5062]
> * Origin: [CALCITE-4314|https://issues.apache.org/jira/browse/CALCITE-4314] /
> commit
> [e537246|https://github.com/apache/calcite/commit/e53724630af60566784e8aa7d8f56fe2932b12cc]
--
This message was sent by Atlassian Jira
(v8.20.10#820010)