[
https://issues.apache.org/jira/browse/CALCITE-4482?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17276146#comment-17276146
]
Julian Hyde commented on CALCITE-4482:
--------------------------------------
Is the following not simpler and sufficient?
{noformat}
diff --git
a/core/src/main/java/org/apache/calcite/sql/pretty/SqlPrettyWriter.java
b/core/src/main/java/org/apache/calcite/sql/pretty/SqlPrettyWriter.java
index 8463c15f3..ef2bebd45 100644
--- a/core/src/main/java/org/apache/calcite/sql/pretty/SqlPrettyWriter.java
+++ b/core/src/main/java/org/apache/calcite/sql/pretty/SqlPrettyWriter.java
@@ -263,6 +263,10 @@
.withDialect(AnsiSqlDialect.DEFAULT)).getBean();
protected static final String NL = System.getProperty("line.separator");
+ private static final SqlWriterConfig CONFIG =
+ ImmutableBeans.create(SqlWriterConfig.class)
+ .withDialect(CalciteSqlDialect.DEFAULT);
+
//~ Instance fields --------------------------------------------------------
private final SqlDialect dialect;
@@ -353,8 +357,7 @@ public SqlPrettyWriter() {
/** Creates a {@link SqlWriterConfig} with Calcite's SQL dialect. */
public static SqlWriterConfig config() {
- return ImmutableBeans.create(SqlWriterConfig.class)
- .withDialect(CalciteSqlDialect.DEFAULT);
+ return CONFIG;
}
//~ Methods ----------------------------------------------------------------
{noformat}
> "ImmutableBeans.create" has performance issue
> ---------------------------------------------
>
> Key: CALCITE-4482
> URL: https://issues.apache.org/jira/browse/CALCITE-4482
> Project: Calcite
> Issue Type: Bug
> Reporter: Jiatao Tao
> Assignee: Jiatao Tao
> Priority: Major
> Attachments: image-2021-02-01-15-42-46-942.png,
> image-2021-02-01-15-45-11-863.png, image-2021-02-01-15-46-08-056.png,
> image-2021-02-01-15-47-31-577.png
>
>
> We are doing the stressing test, and we found SqlNode#toString's time is
> unusually high, seems the call is all from SqlNode#toString, we can reduce
> the useless call of "ImmutableBeans.create" to reduce the time:
> My proposal is to extra default SqlWriterConfig to SqlNode and
> SqlNode#toString use this static field.
>
> {code:java}
> public static final SqlWriterConfig defaultSqlWriterConfig =
> SqlPrettyWriter.config().withDialect(AnsiSqlDialect.DEFAULT)
> .withAlwaysUseParentheses(false)
> .withSelectListItemsOnSeparateLines(false)
> .withUpdateSetListNewline(false)
> .withIndentation(0);
> {code}
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)