You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2023/05/08 09:30:23 UTC
[shardingsphere] branch master updated: Rename InlineExpressionParserFactory (#25519)
This is an automated email from the ASF dual-hosted git repository.
panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 027c8e2f98f Rename InlineExpressionParserFactory (#25519)
027c8e2f98f is described below
commit 027c8e2f98f68eaab4401758db801bce342e1384
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Mon May 8 17:30:15 2023 +0800
Rename InlineExpressionParserFactory (#25519)
---
...ReadwriteSplittingRuleConfigurationChecker.java | 6 +-
.../rule/ReadwriteSplittingRule.java | 8 +-
.../complex/ComplexInlineShardingAlgorithm.java | 6 +-
.../sharding/hint/HintInlineShardingAlgorithm.java | 6 +-
.../sharding/inline/InlineShardingAlgorithm.java | 6 +-
.../shardingsphere/sharding/rule/ShardingRule.java | 6 +-
.../shardingsphere/sharding/rule/TableRule.java | 6 +-
.../checker/ShardingTableRuleStatementChecker.java | 11 +-
.../sharding/CoreHintShardingAlgorithmFixture.java | 6 +-
infra/expr/core/pom.xml | 7 ++
.../infra/expr/core/InlineExpressionParser.java | 73 ------------
.../expr/core/InlineExpressionParserFactory.java | 42 +++++++
.../core/InlineExpressionParserFactoryTest.java | 46 ++++++++
.../expr/core/InlineExpressionParserTest.java | 128 ---------------------
.../espresso/EspressoInlineExpressionParser.java | 4 +-
...ngsphere.infra.expr.spi.InlineExpressionParser} | 0
.../hotsopt/HotspotInlineExpressionParser.java | 4 +-
...ngsphere.infra.expr.spi.InlineExpressionParser} | 0
...sionParser.java => InlineExpressionParser.java} | 4 +-
.../ShardingRuleConfigurationImportChecker.java | 6 +-
.../test/e2e/cases/dataset/DataSet.java | 4 +-
.../engine/composer/BatchE2EContainerComposer.java | 4 +-
.../test/e2e/engine/type/DDLE2EIT.java | 4 +-
.../test/e2e/engine/type/dml/BaseDMLE2EIT.java | 4 +-
.../test/e2e/env/DataSetEnvironmentManager.java | 4 +-
25 files changed, 145 insertions(+), 250 deletions(-)
diff --git a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationChecker.java b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationChecker.java
index 4f4c9fa5862..8ae501150ba 100644
--- a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationChecker.java
+++ b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationChecker.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.infra.config.rule.checker.RuleConfigurationChec
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
-import org.apache.shardingsphere.infra.expr.core.InlineExpressionParser;
+import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory;
import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.readwritesplitting.algorithm.loadbalance.WeightReadQueryLoadBalanceAlgorithm;
import org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
@@ -81,7 +81,7 @@ public final class ReadwriteSplittingRuleConfigurationChecker implements RuleCon
private void checkWriteDataSourceNames(final String databaseName, final Map<String, DataSource> dataSourceMap, final Collection<String> addedWriteDataSourceNames,
final ReadwriteSplittingDataSourceRuleConfiguration config, final Collection<ShardingSphereRule> rules) {
- for (String each : new InlineExpressionParser().splitAndEvaluate(config.getWriteDataSourceName())) {
+ for (String each : InlineExpressionParserFactory.newInstance().splitAndEvaluate(config.getWriteDataSourceName())) {
ShardingSpherePreconditions.checkState(dataSourceMap.containsKey(each) || containsInOtherRules(each, rules),
() -> new DataSourceNameExistedException(String.format("Write data source name `%s` not in database `%s`.", each, databaseName)));
ShardingSpherePreconditions.checkState(addedWriteDataSourceNames.add(each),
@@ -99,7 +99,7 @@ public final class ReadwriteSplittingRuleConfigurationChecker implements RuleCon
}
private void checkReadeDataSourceNames(final String databaseName, final Map<String, DataSource> dataSourceMap, final Collection<String> addedReadDataSourceNames, final String readDataSourceName) {
- for (String each : new InlineExpressionParser().splitAndEvaluate(readDataSourceName)) {
+ for (String each : InlineExpressionParserFactory.newInstance().splitAndEvaluate(readDataSourceName)) {
ShardingSpherePreconditions.checkState(dataSourceMap.containsKey(each),
() -> new DataSourceNameExistedException(String.format("Read data source name `%s` not in database `%s`.", each, databaseName)));
ShardingSpherePreconditions.checkState(addedReadDataSourceNames.add(each),
diff --git a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/ReadwriteSplittingRule.java b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/ReadwriteSplittingRule.java
index e89793f2403..76b65d5402c 100644
--- a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/ReadwriteSplittingRule.java
+++ b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/rule/ReadwriteSplittingRule.java
@@ -33,7 +33,7 @@ import org.apache.shardingsphere.infra.rule.identifier.type.exportable.Exportabl
import org.apache.shardingsphere.infra.rule.identifier.type.exportable.constant.ExportableConstants;
import org.apache.shardingsphere.infra.rule.identifier.type.exportable.constant.ExportableItemConstants;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
-import org.apache.shardingsphere.infra.expr.core.InlineExpressionParser;
+import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory;
import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.mode.event.storage.StorageNodeDataSourceChangedEvent;
import org.apache.shardingsphere.mode.event.storage.StorageNodeDataSourceDeletedEvent;
@@ -103,10 +103,10 @@ public final class ReadwriteSplittingRule implements DatabaseRule, DataSourceCon
private Map<String, ReadwriteSplittingDataSourceRule> createStaticDataSourceRules(final ReadwriteSplittingDataSourceRuleConfiguration config,
final ReadQueryLoadBalanceAlgorithm loadBalanceAlgorithm) {
- List<String> inlineReadwriteDataSourceNames = new InlineExpressionParser().splitAndEvaluate(config.getName());
- List<String> inlineWriteDatasourceNames = new InlineExpressionParser().splitAndEvaluate(config.getWriteDataSourceName());
+ List<String> inlineReadwriteDataSourceNames = InlineExpressionParserFactory.newInstance().splitAndEvaluate(config.getName());
+ List<String> inlineWriteDatasourceNames = InlineExpressionParserFactory.newInstance().splitAndEvaluate(config.getWriteDataSourceName());
List<List<String>> inlineReadDatasourceNames = config.getReadDataSourceNames().stream()
- .map(each -> new InlineExpressionParser().splitAndEvaluate(each)).collect(Collectors.toList());
+ .map(each -> InlineExpressionParserFactory.newInstance().splitAndEvaluate(each)).collect(Collectors.toList());
ShardingSpherePreconditions.checkState(inlineWriteDatasourceNames.size() == inlineReadwriteDataSourceNames.size(),
() -> new InvalidInlineExpressionDataSourceNameException("Inline expression write data source names size error."));
inlineReadDatasourceNames.forEach(each -> ShardingSpherePreconditions.checkState(each.size() == inlineReadwriteDataSourceNames.size(),
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/complex/ComplexInlineShardingAlgorithm.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/complex/ComplexInlineShardingAlgorithm.java
index ee8a106aa58..9ee42aa1839 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/complex/ComplexInlineShardingAlgorithm.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/complex/ComplexInlineShardingAlgorithm.java
@@ -21,7 +21,7 @@ import groovy.lang.Closure;
import groovy.util.Expando;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.util.exception.external.sql.type.generic.UnsupportedSQLOperationException;
-import org.apache.shardingsphere.infra.expr.core.InlineExpressionParser;
+import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory;
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingValue;
import org.apache.shardingsphere.sharding.exception.algorithm.sharding.MismatchedComplexInlineShardingAlgorithmColumnAndValueSizeException;
@@ -65,7 +65,7 @@ public final class ComplexInlineShardingAlgorithm implements ComplexKeysSharding
private String getAlgorithmExpression(final Properties props) {
String algorithmExpression = props.getProperty(ALGORITHM_EXPRESSION_KEY);
ShardingSpherePreconditions.checkNotNull(algorithmExpression, () -> new ShardingAlgorithmInitializationException(getType(), "Inline sharding algorithm expression can not be null."));
- return new InlineExpressionParser().handlePlaceHolder(algorithmExpression.trim());
+ return InlineExpressionParserFactory.newInstance().handlePlaceHolder(algorithmExpression.trim());
}
private Collection<String> getShardingColumns(final Properties props) {
@@ -126,7 +126,7 @@ public final class ComplexInlineShardingAlgorithm implements ComplexKeysSharding
}
private Closure<?> createClosure() {
- Closure<?> result = new InlineExpressionParser().evaluateClosure(algorithmExpression).rehydrate(new Expando(), null, null);
+ Closure<?> result = InlineExpressionParserFactory.newInstance().evaluateClosure(algorithmExpression).rehydrate(new Expando(), null, null);
result.setResolveStrategy(Closure.DELEGATE_ONLY);
return result;
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/hint/HintInlineShardingAlgorithm.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/hint/HintInlineShardingAlgorithm.java
index 08475dbbb29..32060decdef 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/hint/HintInlineShardingAlgorithm.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/hint/HintInlineShardingAlgorithm.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.sharding.algorithm.sharding.hint;
import groovy.lang.Closure;
import groovy.util.Expando;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
-import org.apache.shardingsphere.infra.expr.core.InlineExpressionParser;
+import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory;
import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingValue;
import org.apache.shardingsphere.sharding.exception.algorithm.sharding.ShardingAlgorithmInitializationException;
@@ -51,7 +51,7 @@ public final class HintInlineShardingAlgorithm implements HintShardingAlgorithm<
private String getAlgorithmExpression(final Properties props) {
String algorithmExpression = props.getProperty(ALGORITHM_EXPRESSION_KEY, DEFAULT_ALGORITHM_EXPRESSION);
ShardingSpherePreconditions.checkNotNull(algorithmExpression, () -> new ShardingAlgorithmInitializationException(getType(), "Inline sharding algorithm expression can not be null."));
- return new InlineExpressionParser().handlePlaceHolder(algorithmExpression.trim());
+ return InlineExpressionParserFactory.newInstance().handlePlaceHolder(algorithmExpression.trim());
}
@Override
@@ -67,7 +67,7 @@ public final class HintInlineShardingAlgorithm implements HintShardingAlgorithm<
}
private Closure<?> createClosure() {
- Closure<?> result = new InlineExpressionParser().evaluateClosure(algorithmExpression).rehydrate(new Expando(), null, null);
+ Closure<?> result = InlineExpressionParserFactory.newInstance().evaluateClosure(algorithmExpression).rehydrate(new Expando(), null, null);
result.setResolveStrategy(Closure.DELEGATE_ONLY);
return result;
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithm.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithm.java
index b14198c93b1..527a043c569 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithm.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithm.java
@@ -22,7 +22,7 @@ import groovy.lang.MissingMethodException;
import groovy.util.Expando;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.util.exception.external.sql.type.generic.UnsupportedSQLOperationException;
-import org.apache.shardingsphere.infra.expr.core.InlineExpressionParser;
+import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
@@ -57,7 +57,7 @@ public final class InlineShardingAlgorithm implements StandardShardingAlgorithm<
String expression = props.getProperty(ALGORITHM_EXPRESSION_KEY);
ShardingSpherePreconditions.checkState(null != expression && !expression.isEmpty(),
() -> new ShardingAlgorithmInitializationException(getType(), "Inline sharding algorithm expression cannot be null or empty"));
- return new InlineExpressionParser().handlePlaceHolder(expression.trim());
+ return InlineExpressionParserFactory.newInstance().handlePlaceHolder(expression.trim());
}
private boolean isAllowRangeQuery(final Properties props) {
@@ -80,7 +80,7 @@ public final class InlineShardingAlgorithm implements StandardShardingAlgorithm<
}
private Closure<?> createClosure() {
- Closure<?> result = new InlineExpressionParser().evaluateClosure(algorithmExpression).rehydrate(new Expando(), null, null);
+ Closure<?> result = InlineExpressionParserFactory.newInstance().evaluateClosure(algorithmExpression).rehydrate(new Expando(), null, null);
result.setResolveStrategy(Closure.DELEGATE_ONLY);
return result;
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
index 9a4bf893502..e35d9c15f0e 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
@@ -33,7 +33,7 @@ import org.apache.shardingsphere.infra.rule.identifier.scope.DatabaseRule;
import org.apache.shardingsphere.infra.rule.identifier.type.DataNodeContainedRule;
import org.apache.shardingsphere.infra.rule.identifier.type.TableContainedRule;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
-import org.apache.shardingsphere.infra.expr.core.InlineExpressionParser;
+import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory;
import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
@@ -164,12 +164,12 @@ public final class ShardingRule implements DatabaseRule, DataNodeContainedRule,
}
private Collection<String> getDataSourceNames(final ShardingAutoTableRuleConfiguration shardingAutoTableRuleConfig) {
- List<String> actualDataSources = new InlineExpressionParser().splitAndEvaluate(shardingAutoTableRuleConfig.getActualDataSources());
+ List<String> actualDataSources = InlineExpressionParserFactory.newInstance().splitAndEvaluate(shardingAutoTableRuleConfig.getActualDataSources());
return new HashSet<>(actualDataSources);
}
private Collection<String> getDataSourceNames(final ShardingTableRuleConfiguration shardingTableRuleConfig) {
- List<String> actualDataNodes = new InlineExpressionParser().splitAndEvaluate(shardingTableRuleConfig.getActualDataNodes());
+ List<String> actualDataNodes = InlineExpressionParserFactory.newInstance().splitAndEvaluate(shardingTableRuleConfig.getActualDataNodes());
return actualDataNodes.stream().map(each -> new DataNode(each).getDataSourceName()).collect(Collectors.toList());
}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/TableRule.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/TableRule.java
index 1c35ebc11ba..f12cc30aba4 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/TableRule.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/TableRule.java
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.infra.datanode.DataNodeInfo;
import org.apache.shardingsphere.infra.datanode.DataNodeUtils;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
-import org.apache.shardingsphere.infra.expr.core.InlineExpressionParser;
+import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.audit.ShardingAuditStrategyConfiguration;
@@ -106,7 +106,7 @@ public final class TableRule {
public TableRule(final ShardingTableRuleConfiguration tableRuleConfig, final Collection<String> dataSourceNames, final String defaultGenerateKeyColumn) {
logicTable = tableRuleConfig.getLogicTable();
- List<String> dataNodes = new InlineExpressionParser().splitAndEvaluate(tableRuleConfig.getActualDataNodes());
+ List<String> dataNodes = InlineExpressionParserFactory.newInstance().splitAndEvaluate(tableRuleConfig.getActualDataNodes());
dataNodeIndexMap = new HashMap<>(dataNodes.size(), 1);
actualDataNodes = isEmptyDataNodes(dataNodes) ? generateDataNodes(tableRuleConfig.getLogicTable(), dataSourceNames) : generateDataNodes(dataNodes, dataSourceNames);
actualTables = getActualTables();
@@ -158,7 +158,7 @@ public final class TableRule {
return new LinkedList<>();
}
List<String> dataSources = Strings.isNullOrEmpty(tableRuleConfig.getActualDataSources()) ? new LinkedList<>(dataSourceNames)
- : new InlineExpressionParser().splitAndEvaluate(tableRuleConfig.getActualDataSources());
+ : InlineExpressionParserFactory.newInstance().splitAndEvaluate(tableRuleConfig.getActualDataSources());
return DataNodeUtils.getFormatDataNodes(shardingAlgorithm.getAutoTablesAmount(), logicTable, dataSources);
}
diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
index 0f0a72af4c1..0d8a46c2de4 100644
--- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
+++ b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
@@ -32,7 +32,7 @@ import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
-import org.apache.shardingsphere.infra.expr.core.InlineExpressionParser;
+import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory;
import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
@@ -189,12 +189,13 @@ public final class ShardingTableRuleStatementChecker {
}
Collection<String> result = new LinkedHashSet<>();
tableRuleConfigs.forEach(each -> result.addAll(getDataSourceNames(each)));
- autoTableRuleConfigs.forEach(each -> result.addAll(new InlineExpressionParser().splitAndEvaluate(each.getActualDataSources())));
+ autoTableRuleConfigs.forEach(each -> result.addAll(InlineExpressionParserFactory.newInstance().splitAndEvaluate(each.getActualDataSources())));
return result;
}
private static Collection<String> getDataSourceNames(final ShardingTableRuleConfiguration shardingTableRuleConfig) {
- return new InlineExpressionParser().splitAndEvaluate(shardingTableRuleConfig.getActualDataNodes()).stream().map(each -> new DataNode(each).getDataSourceName()).collect(Collectors.toList());
+ return InlineExpressionParserFactory.newInstance()
+ .splitAndEvaluate(shardingTableRuleConfig.getActualDataNodes()).stream().map(each -> new DataNode(each).getDataSourceName()).collect(Collectors.toList());
}
private static Collection<String> getDataSourceNames(final Collection<String> actualDataNodes) {
@@ -326,7 +327,7 @@ public final class ShardingTableRuleStatementChecker {
Collection<String> result = new LinkedHashSet<>();
result.addAll(config.getAutoTables().stream().map(ShardingAutoTableRuleConfiguration::getActualDataSources)
.map(each -> Splitter.on(",").trimResults().splitToList(each)).flatMap(Collection::stream).collect(Collectors.toSet()));
- result.addAll(config.getTables().stream().map(each -> new InlineExpressionParser().splitAndEvaluate(each.getActualDataNodes()))
+ result.addAll(config.getTables().stream().map(each -> InlineExpressionParserFactory.newInstance().splitAndEvaluate(each.getActualDataNodes()))
.flatMap(Collection::stream).distinct().map(each -> new DataNode(each).getDataSourceName()).collect(Collectors.toSet()));
return result;
}
@@ -337,7 +338,7 @@ public final class ShardingTableRuleStatementChecker {
}
private static Collection<String> parseDateSource(final String dateSource) {
- return new InlineExpressionParser().splitAndEvaluate(dateSource);
+ return InlineExpressionParserFactory.newInstance().splitAndEvaluate(dateSource);
}
private static Collection<String> getLogicDataSources(final ShardingSphereDatabase database) {
diff --git a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/fixture/sharding/CoreHintShardingAlgorithmFixture.java b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/fixture/sharding/CoreHintShardingAlgorithmFixture.java
index 42efc968931..40c8865786d 100644
--- a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/fixture/sharding/CoreHintShardingAlgorithmFixture.java
+++ b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/fixture/sharding/CoreHintShardingAlgorithmFixture.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.sharding.distsql.fixture.sharding;
import com.google.common.base.Preconditions;
import groovy.lang.Closure;
import groovy.util.Expando;
-import org.apache.shardingsphere.infra.expr.core.InlineExpressionParser;
+import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory;
import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingValue;
@@ -46,7 +46,7 @@ public final class CoreHintShardingAlgorithmFixture implements HintShardingAlgor
private String getAlgorithmExpression(final Properties props) {
String algorithmExpression = props.getProperty(ALGORITHM_EXPRESSION_KEY, DEFAULT_ALGORITHM_EXPRESSION);
Preconditions.checkNotNull(algorithmExpression, "Inline sharding algorithm expression can not be null.");
- return new InlineExpressionParser().handlePlaceHolder(algorithmExpression.trim());
+ return InlineExpressionParserFactory.newInstance().handlePlaceHolder(algorithmExpression.trim());
}
@Override
@@ -61,7 +61,7 @@ public final class CoreHintShardingAlgorithmFixture implements HintShardingAlgor
}
private Closure<?> createClosure() {
- Closure<?> result = new InlineExpressionParser().evaluateClosure(algorithmExpression).rehydrate(new Expando(), null, null);
+ Closure<?> result = InlineExpressionParserFactory.newInstance().evaluateClosure(algorithmExpression).rehydrate(new Expando(), null, null);
result.setResolveStrategy(Closure.DELEGATE_ONLY);
return result;
}
diff --git a/infra/expr/core/pom.xml b/infra/expr/core/pom.xml
index fbea29c7dd8..454a3802a6d 100644
--- a/infra/expr/core/pom.xml
+++ b/infra/expr/core/pom.xml
@@ -44,6 +44,13 @@
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-test-util</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
diff --git a/infra/expr/core/src/main/java/org/apache/shardingsphere/infra/expr/core/InlineExpressionParser.java b/infra/expr/core/src/main/java/org/apache/shardingsphere/infra/expr/core/InlineExpressionParser.java
deleted file mode 100644
index 45df3230d16..00000000000
--- a/infra/expr/core/src/main/java/org/apache/shardingsphere/infra/expr/core/InlineExpressionParser.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.infra.expr.core;
-
-import groovy.lang.Closure;
-import org.apache.shardingsphere.infra.expr.spi.JVMInlineExpressionParser;
-import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
-
-import java.util.List;
-
-/**
- * Inline expression parser.
- */
-public final class InlineExpressionParser {
-
- private static final boolean IS_SUBSTRATE_VM;
-
- private final JVMInlineExpressionParser jvmInlineExpressionParser;
-
- static {
- // workaround for https://github.com/helidon-io/helidon-build-tools/issues/858
- IS_SUBSTRATE_VM = "Substrate VM".equals(System.getProperty("java.vm.name"));
- }
-
- public InlineExpressionParser() {
- jvmInlineExpressionParser = TypedSPILoader.getService(JVMInlineExpressionParser.class, IS_SUBSTRATE_VM ? "ESPRESSO" : "HOTSPOT");
- }
-
- /**
- * Replace all inline expression placeholders.
- *
- * @param inlineExpression inline expression with {@code $->}
- * @return result inline expression with {@code $}
- */
- public String handlePlaceHolder(final String inlineExpression) {
- return jvmInlineExpressionParser.handlePlaceHolder(inlineExpression);
- }
-
- /**
- * Split and evaluate inline expression.
- *
- * @param inlineExpression inline expression
- * @return result list
- */
- public List<String> splitAndEvaluate(final String inlineExpression) {
- return jvmInlineExpressionParser.splitAndEvaluate(inlineExpression);
- }
-
- /**
- * Evaluate closure.
- *
- * @param inlineExpression inline expression
- * @return closure
- */
- public Closure<?> evaluateClosure(final String inlineExpression) {
- return jvmInlineExpressionParser.evaluateClosure(inlineExpression);
- }
-}
diff --git a/infra/expr/core/src/main/java/org/apache/shardingsphere/infra/expr/core/InlineExpressionParserFactory.java b/infra/expr/core/src/main/java/org/apache/shardingsphere/infra/expr/core/InlineExpressionParserFactory.java
new file mode 100644
index 00000000000..3d65e80fdf2
--- /dev/null
+++ b/infra/expr/core/src/main/java/org/apache/shardingsphere/infra/expr/core/InlineExpressionParserFactory.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.expr.core;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.infra.expr.spi.InlineExpressionParser;
+import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
+
+/**
+ * Inline expression parser factory.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class InlineExpressionParserFactory {
+
+ // workaround for https://github.com/helidon-io/helidon-build-tools/issues/858
+ private static final boolean IS_SUBSTRATE_VM = "Substrate VM".equals(System.getProperty("java.vm.name"));
+
+ /**
+ * Create new instance of inline expression parser.
+ *
+ * @return created instance
+ */
+ public static InlineExpressionParser newInstance() {
+ return TypedSPILoader.getService(InlineExpressionParser.class, IS_SUBSTRATE_VM ? "ESPRESSO" : "HOTSPOT");
+ }
+}
diff --git a/infra/expr/core/src/test/java/org/apache/shardingsphere/infra/expr/core/InlineExpressionParserFactoryTest.java b/infra/expr/core/src/test/java/org/apache/shardingsphere/infra/expr/core/InlineExpressionParserFactoryTest.java
new file mode 100644
index 00000000000..f68bf262241
--- /dev/null
+++ b/infra/expr/core/src/test/java/org/apache/shardingsphere/infra/expr/core/InlineExpressionParserFactoryTest.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.expr.core;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+class InlineExpressionParserFactoryTest {
+
+ private String originalJavaVmName;
+
+ @BeforeEach
+ public void setUp() {
+ originalJavaVmName = System.getProperty("java.vm.name");
+ }
+
+ @AfterEach
+ public void tearDown() {
+ System.setProperty("java.vm.name", originalJavaVmName);
+ }
+
+ @Test
+ void assertNewInstance() {
+ System.setProperty("java.vm.name", "");
+ assertThat(InlineExpressionParserFactory.newInstance().getType(), is("HOTSPOT"));
+ }
+}
diff --git a/infra/expr/core/src/test/java/org/apache/shardingsphere/infra/expr/core/InlineExpressionParserTest.java b/infra/expr/core/src/test/java/org/apache/shardingsphere/infra/expr/core/InlineExpressionParserTest.java
deleted file mode 100644
index 5f3c43945fa..00000000000
--- a/infra/expr/core/src/test/java/org/apache/shardingsphere/infra/expr/core/InlineExpressionParserTest.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.infra.expr.core;
-
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.DisabledInNativeImage;
-
-import java.util.Collections;
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.hasItems;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class InlineExpressionParserTest {
-
- @Test
- void assertEvaluateForExpressionIsNull() {
- List<String> expected = new InlineExpressionParser().splitAndEvaluate(null);
- assertThat(expected, is(Collections.<String>emptyList()));
- }
-
- @Test
- void assertEvaluateForSimpleString() {
- List<String> expected = new InlineExpressionParser().splitAndEvaluate(" t_order_0, t_order_1 ");
- assertThat(expected.size(), is(2));
- assertThat(expected, hasItems("t_order_0", "t_order_1"));
- }
-
- @Test
- void assertEvaluateForNull() {
- List<String> expected = new InlineExpressionParser().splitAndEvaluate("t_order_${null}");
- assertThat(expected.size(), is(1));
- assertThat(expected, hasItems("t_order_"));
- }
-
- @Test
- void assertEvaluateForLiteral() {
- List<String> expected = new InlineExpressionParser().splitAndEvaluate("t_order_${'xx'}");
- assertThat(expected.size(), is(1));
- assertThat(expected, hasItems("t_order_xx"));
- }
-
- @Test
- void assertEvaluateForArray() {
- List<String> expected = new InlineExpressionParser().splitAndEvaluate("t_order_${[0, 1, 2]},t_order_item_${[0, 2]}");
- assertThat(expected.size(), is(5));
- assertThat(expected, hasItems("t_order_0", "t_order_1", "t_order_2", "t_order_item_0", "t_order_item_2"));
- }
-
- @Test
- void assertEvaluateForRange() {
- List<String> expected = new InlineExpressionParser().splitAndEvaluate("t_order_${0..2},t_order_item_${0..1}");
- assertThat(expected.size(), is(5));
- assertThat(expected, hasItems("t_order_0", "t_order_1", "t_order_2", "t_order_item_0", "t_order_item_1"));
- }
-
- @Test
- void assertEvaluateForComplex() {
- List<String> expected = new InlineExpressionParser().splitAndEvaluate("t_${['new','old']}_order_${1..2}, t_config");
- assertThat(expected.size(), is(5));
- assertThat(expected, hasItems("t_new_order_1", "t_new_order_2", "t_old_order_1", "t_old_order_2", "t_config"));
- }
-
- @Test
- void assertEvaluateForCalculate() {
- List<String> expected = new InlineExpressionParser().splitAndEvaluate("t_${[\"new${1+2}\",'old']}_order_${1..2}");
- assertThat(expected.size(), is(4));
- assertThat(expected, hasItems("t_new3_order_1", "t_new3_order_2", "t_old_order_1", "t_old_order_2"));
- }
-
- @Test
- void assertEvaluateForExpressionPlaceHolder() {
- List<String> expected = new InlineExpressionParser().splitAndEvaluate("t_$->{[\"new$->{1+2}\",'old']}_order_$->{1..2}");
- assertThat(expected.size(), is(4));
- assertThat(expected, hasItems("t_new3_order_1", "t_new3_order_2", "t_old_order_1", "t_old_order_2"));
- }
-
- @Test
- void assertEvaluateForLong() {
- StringBuilder expression = new StringBuilder();
- for (int i = 0; i < 1024; i++) {
- expression.append("ds_");
- expression.append(i / 64);
- expression.append(".t_user_");
- expression.append(i);
- if (i != 1023) {
- expression.append(",");
- }
- }
- List<String> expected = new InlineExpressionParser().splitAndEvaluate(expression.toString());
- assertThat(expected.size(), is(1024));
- assertThat(expected, hasItems("ds_0.t_user_0", "ds_15.t_user_1023"));
- }
-
- @Test
- void assertHandlePlaceHolder() {
- assertThat(new InlineExpressionParser().handlePlaceHolder("t_$->{[\"new$->{1+2}\"]}"), is("t_${[\"new${1+2}\"]}"));
- assertThat(new InlineExpressionParser().handlePlaceHolder("t_${[\"new$->{1+2}\"]}"), is("t_${[\"new${1+2}\"]}"));
- }
-
- /**
- * TODO
- * This method needs to avoid returning a groovy.lang.Closure class instance,
- * and instead return the result of `Closure#call`.
- * Because `org.graalvm.polyglot.Value#as` does not allow this type to be returned from the guest JVM.
- */
- @Test
- @DisabledInNativeImage
- void assertEvaluateClosure() {
- assertThat(new InlineExpressionParser().evaluateClosure("${1+2}").call().toString(), is("3"));
- }
-}
diff --git a/infra/expr/espresso/src/main/java/org/apache/shardingsphere/infra/expr/espresso/EspressoInlineExpressionParser.java b/infra/expr/espresso/src/main/java/org/apache/shardingsphere/infra/expr/espresso/EspressoInlineExpressionParser.java
index 422723d4095..9c1d28d2a69 100644
--- a/infra/expr/espresso/src/main/java/org/apache/shardingsphere/infra/expr/espresso/EspressoInlineExpressionParser.java
+++ b/infra/expr/espresso/src/main/java/org/apache/shardingsphere/infra/expr/espresso/EspressoInlineExpressionParser.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.infra.expr.espresso;
import groovy.lang.Closure;
import org.apache.shardingsphere.infra.expr.hotsopt.HotspotInlineExpressionParser;
-import org.apache.shardingsphere.infra.expr.spi.JVMInlineExpressionParser;
+import org.apache.shardingsphere.infra.expr.spi.InlineExpressionParser;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.TypeLiteral;
@@ -33,7 +33,7 @@ import java.util.Objects;
/**
* Espresso inline expression parser.
*/
-public final class EspressoInlineExpressionParser implements JVMInlineExpressionParser {
+public final class EspressoInlineExpressionParser implements InlineExpressionParser {
private static final String JAVA_CLASSPATH;
diff --git a/infra/expr/espresso/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.expr.spi.JVMInlineExpressionParser b/infra/expr/espresso/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.expr.spi.InlineExpressionParser
similarity index 100%
rename from infra/expr/espresso/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.expr.spi.JVMInlineExpressionParser
rename to infra/expr/espresso/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.expr.spi.InlineExpressionParser
diff --git a/infra/expr/hotsopt/src/main/java/org/apache/shardingsphere/infra/expr/hotsopt/HotspotInlineExpressionParser.java b/infra/expr/hotsopt/src/main/java/org/apache/shardingsphere/infra/expr/hotsopt/HotspotInlineExpressionParser.java
index f70ffdc200f..1ec58bb940c 100644
--- a/infra/expr/hotsopt/src/main/java/org/apache/shardingsphere/infra/expr/hotsopt/HotspotInlineExpressionParser.java
+++ b/infra/expr/hotsopt/src/main/java/org/apache/shardingsphere/infra/expr/hotsopt/HotspotInlineExpressionParser.java
@@ -23,7 +23,7 @@ import groovy.lang.Closure;
import groovy.lang.GString;
import groovy.lang.GroovyShell;
import groovy.lang.Script;
-import org.apache.shardingsphere.infra.expr.spi.JVMInlineExpressionParser;
+import org.apache.shardingsphere.infra.expr.spi.InlineExpressionParser;
import java.util.ArrayList;
import java.util.Collection;
@@ -38,7 +38,7 @@ import java.util.stream.Collectors;
/**
* Hotspot inline expression parser.
*/
-public final class HotspotInlineExpressionParser implements JVMInlineExpressionParser {
+public final class HotspotInlineExpressionParser implements InlineExpressionParser {
private static final char SPLITTER = ',';
diff --git a/infra/expr/hotsopt/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.expr.spi.JVMInlineExpressionParser b/infra/expr/hotsopt/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.expr.spi.InlineExpressionParser
similarity index 100%
rename from infra/expr/hotsopt/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.expr.spi.JVMInlineExpressionParser
rename to infra/expr/hotsopt/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.expr.spi.InlineExpressionParser
diff --git a/infra/expr/spi/src/main/java/org/apache/shardingsphere/infra/expr/spi/JVMInlineExpressionParser.java b/infra/expr/spi/src/main/java/org/apache/shardingsphere/infra/expr/spi/InlineExpressionParser.java
similarity index 94%
rename from infra/expr/spi/src/main/java/org/apache/shardingsphere/infra/expr/spi/JVMInlineExpressionParser.java
rename to infra/expr/spi/src/main/java/org/apache/shardingsphere/infra/expr/spi/InlineExpressionParser.java
index 9b395abcb85..cf744180f32 100644
--- a/infra/expr/spi/src/main/java/org/apache/shardingsphere/infra/expr/spi/JVMInlineExpressionParser.java
+++ b/infra/expr/spi/src/main/java/org/apache/shardingsphere/infra/expr/spi/InlineExpressionParser.java
@@ -24,10 +24,10 @@ import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPI;
import java.util.List;
/**
- * JVM inline expression parser.
+ * Inline expression parser.
*/
@SingletonSPI
-public interface JVMInlineExpressionParser extends TypedSPI {
+public interface InlineExpressionParser extends TypedSPI {
/**
* Replace all inline expression placeholders.
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShardingRuleConfigurationImportChecker.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShardingRuleConfigurationImportChecker.java
index 24a2045132b..63e4570e011 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShardingRuleConfigurationImportChecker.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShardingRuleConfigurationImportChecker.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
-import org.apache.shardingsphere.infra.expr.core.InlineExpressionParser;
+import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory;
import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
@@ -90,12 +90,12 @@ public final class ShardingRuleConfigurationImportChecker {
}
private Collection<String> getDataSourceNames(final ShardingAutoTableRuleConfiguration shardingAutoTableRuleConfig) {
- Collection<String> actualDataSources = new InlineExpressionParser().splitAndEvaluate(shardingAutoTableRuleConfig.getActualDataSources());
+ Collection<String> actualDataSources = InlineExpressionParserFactory.newInstance().splitAndEvaluate(shardingAutoTableRuleConfig.getActualDataSources());
return new HashSet<>(actualDataSources);
}
private Collection<String> getDataSourceNames(final ShardingTableRuleConfiguration shardingTableRuleConfig) {
- Collection<String> actualDataNodes = new InlineExpressionParser().splitAndEvaluate(shardingTableRuleConfig.getActualDataNodes());
+ Collection<String> actualDataNodes = InlineExpressionParserFactory.newInstance().splitAndEvaluate(shardingTableRuleConfig.getActualDataNodes());
return actualDataNodes.stream().map(each -> new DataNode(each).getDataSourceName()).collect(Collectors.toList());
}
diff --git a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/cases/dataset/DataSet.java b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/cases/dataset/DataSet.java
index 975f7a72916..032c7a8aa7c 100644
--- a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/cases/dataset/DataSet.java
+++ b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/cases/dataset/DataSet.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.test.e2e.cases.dataset;
import lombok.Getter;
import org.apache.shardingsphere.infra.datanode.DataNode;
-import org.apache.shardingsphere.infra.expr.core.InlineExpressionParser;
+import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory;
import org.apache.shardingsphere.test.e2e.cases.dataset.metadata.DataSetMetaData;
import org.apache.shardingsphere.test.e2e.cases.dataset.row.DataSetRow;
@@ -65,7 +65,7 @@ public final class DataSet {
* @return data set meta data belong to current data node
*/
public DataSetMetaData findMetaData(final DataNode dataNode) {
- Optional<DataSetMetaData> result = metaDataList.stream().filter(each -> contains(new InlineExpressionParser().splitAndEvaluate(each.getDataNodes()), dataNode)).findFirst();
+ Optional<DataSetMetaData> result = metaDataList.stream().filter(each -> contains(InlineExpressionParserFactory.newInstance().splitAndEvaluate(each.getDataNodes()), dataNode)).findFirst();
return result.orElseThrow(() -> new IllegalArgumentException(String.format("Cannot find data node: %s", dataNode)));
}
diff --git a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/composer/BatchE2EContainerComposer.java b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/composer/BatchE2EContainerComposer.java
index 0076521eb89..dafa43ee153 100644
--- a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/composer/BatchE2EContainerComposer.java
+++ b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/composer/BatchE2EContainerComposer.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.test.e2e.engine.composer;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.datanode.DataNode;
-import org.apache.shardingsphere.infra.expr.core.InlineExpressionParser;
+import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory;
import org.apache.shardingsphere.test.e2e.cases.assertion.IntegrationTestCaseAssertion;
import org.apache.shardingsphere.test.e2e.cases.dataset.DataSet;
import org.apache.shardingsphere.test.e2e.cases.dataset.DataSetLoader;
@@ -85,7 +85,7 @@ public final class BatchE2EContainerComposer extends E2EContainerComposer {
DataSet expected = getDataSet(actualUpdateCounts);
assertThat("Only support single table for DML.", expected.getMetaDataList().size(), is(1));
DataSetMetaData expectedDataSetMetaData = expected.getMetaDataList().get(0);
- for (String each : new InlineExpressionParser().splitAndEvaluate(expectedDataSetMetaData.getDataNodes())) {
+ for (String each : InlineExpressionParserFactory.newInstance().splitAndEvaluate(expectedDataSetMetaData.getDataNodes())) {
DataNode dataNode = new DataNode(each);
DataSource dataSource = getActualDataSourceMap().get(dataNode.getDataSourceName());
try (
diff --git a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/DDLE2EIT.java b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/DDLE2EIT.java
index 089595ffccb..00fbdd8d9d6 100644
--- a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/DDLE2EIT.java
+++ b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/DDLE2EIT.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.test.e2e.engine.type;
import com.google.common.base.Splitter;
import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.datanode.DataNode;
-import org.apache.shardingsphere.infra.expr.core.InlineExpressionParser;
+import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory;
import org.apache.shardingsphere.test.e2e.cases.SQLCommandType;
import org.apache.shardingsphere.test.e2e.cases.SQLExecuteType;
import org.apache.shardingsphere.test.e2e.cases.dataset.metadata.DataSetColumn;
@@ -171,7 +171,7 @@ class DDLE2EIT {
private void assertTableMetaData(final AssertionTestParameter testParam, final SingleE2EContainerComposer containerComposer) throws SQLException {
String tableName = containerComposer.getAssertion().getInitialSQL().getAffectedTable();
DataSetMetaData expected = containerComposer.getDataSet().findMetaData(tableName);
- Collection<DataNode> dataNodes = new InlineExpressionParser().splitAndEvaluate(expected.getDataNodes()).stream().map(DataNode::new).collect(Collectors.toList());
+ Collection<DataNode> dataNodes = InlineExpressionParserFactory.newInstance().splitAndEvaluate(expected.getDataNodes()).stream().map(DataNode::new).collect(Collectors.toList());
if (expected.getColumns().isEmpty()) {
assertNotContainsTable(containerComposer, dataNodes);
return;
diff --git a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dml/BaseDMLE2EIT.java b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dml/BaseDMLE2EIT.java
index 1b8cb3d9f50..24934ede98f 100644
--- a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dml/BaseDMLE2EIT.java
+++ b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dml/BaseDMLE2EIT.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.test.e2e.engine.type.dml;
import org.apache.shardingsphere.infra.datanode.DataNode;
-import org.apache.shardingsphere.infra.expr.core.InlineExpressionParser;
+import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory;
import org.apache.shardingsphere.test.e2e.cases.dataset.metadata.DataSetColumn;
import org.apache.shardingsphere.test.e2e.cases.dataset.metadata.DataSetMetaData;
import org.apache.shardingsphere.test.e2e.cases.dataset.row.DataSetRow;
@@ -85,7 +85,7 @@ public abstract class BaseDMLE2EIT {
assertThat("Only support single table for DML.", containerComposer.getDataSet().getMetaDataList().size(), is(1));
assertThat(actualUpdateCount, is(containerComposer.getDataSet().getUpdateCount()));
DataSetMetaData expectedDataSetMetaData = containerComposer.getDataSet().getMetaDataList().get(0);
- for (String each : new InlineExpressionParser().splitAndEvaluate(expectedDataSetMetaData.getDataNodes())) {
+ for (String each : InlineExpressionParserFactory.newInstance().splitAndEvaluate(expectedDataSetMetaData.getDataNodes())) {
DataNode dataNode = new DataNode(each);
DataSource dataSource = containerComposer.getActualDataSourceMap().get(dataNode.getDataSourceName());
try (
diff --git a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/env/DataSetEnvironmentManager.java b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/env/DataSetEnvironmentManager.java
index d3b3598b067..391d2c630df 100644
--- a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/env/DataSetEnvironmentManager.java
+++ b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/env/DataSetEnvironmentManager.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.infra.database.type.DatabaseTypeEngine;
import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
import org.apache.shardingsphere.infra.executor.kernel.thread.ExecutorServiceManager;
-import org.apache.shardingsphere.infra.expr.core.InlineExpressionParser;
+import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory;
import org.apache.shardingsphere.test.e2e.cases.dataset.DataSet;
import org.apache.shardingsphere.test.e2e.cases.dataset.metadata.DataSetColumn;
import org.apache.shardingsphere.test.e2e.cases.dataset.metadata.DataSetMetaData;
@@ -162,7 +162,7 @@ public final class DataSetEnvironmentManager {
private Map<String, Collection<String>> getDataNodeMap(final DataSetMetaData dataSetMetaData) {
Map<String, Collection<String>> result = new LinkedHashMap<>();
- for (String each : new InlineExpressionParser().splitAndEvaluate(dataSetMetaData.getDataNodes())) {
+ for (String each : InlineExpressionParserFactory.newInstance().splitAndEvaluate(dataSetMetaData.getDataNodes())) {
DataNode dataNode = new DataNode(each);
if (!result.containsKey(dataNode.getDataSourceName())) {
result.put(dataNode.getDataSourceName(), new LinkedList<>());