This is an automated email from the ASF dual-hosted git repository.
zhaojinchao 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 22c0d993a7f Remove SingleDistSQLConstants (#30641)
22c0d993a7f is described below
commit 22c0d993a7f1378f129d83f9a2d34a51128e8cc5
Author: Raigor <[email protected]>
AuthorDate: Mon Mar 25 22:02:03 2024 +0800
Remove SingleDistSQLConstants (#30641)
---
.../handler/constant/SingleDistSQLConstants.java | 34 ----------------------
.../SingleRuleConfigurationToDistSQLConverter.java | 16 ++++++----
2 files changed, 11 insertions(+), 39 deletions(-)
diff --git
a/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/constant/SingleDistSQLConstants.java
b/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/constant/SingleDistSQLConstants.java
deleted file mode 100644
index 2ec695d5af2..00000000000
---
a/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/constant/SingleDistSQLConstants.java
+++ /dev/null
@@ -1,34 +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.single.distsql.handler.constant;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-
-/**
- * Single DistSQL constants.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class SingleDistSQLConstants {
-
- public static final String COMMA = ",";
-
- public static final String LOAD_SINGLE_TABLE = "LOAD SINGLE TABLE %s;";
-
- public static final String SET_DEFAULT_SINGLE_TABLE_STORAGE_UNIT = "SET
DEFAULT SINGLE TABLE STORAGE UNIT = %s;";
-}
diff --git
a/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/provider/SingleRuleConfigurationToDistSQLConverter.java
b/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/provider/SingleRuleConfigurationToDistSQLConverter.java
index e2d214b096a..4414420ac1c 100644
---
a/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/provider/SingleRuleConfigurationToDistSQLConverter.java
+++
b/kernel/single/distsql/handler/src/main/java/org/apache/shardingsphere/single/distsql/handler/provider/SingleRuleConfigurationToDistSQLConverter.java
@@ -20,13 +20,16 @@ package
org.apache.shardingsphere.single.distsql.handler.provider;
import com.google.common.base.Joiner;
import
org.apache.shardingsphere.distsql.handler.engine.query.ral.convert.RuleConfigurationToDistSQLConverter;
import org.apache.shardingsphere.single.api.config.SingleRuleConfiguration;
-import
org.apache.shardingsphere.single.distsql.handler.constant.SingleDistSQLConstants;
/**
* Single rule configuration to DistSQL converter.
*/
public final class SingleRuleConfigurationToDistSQLConverter implements
RuleConfigurationToDistSQLConverter<SingleRuleConfiguration> {
+ public static final String LOAD_SINGLE_TABLE = "LOAD SINGLE TABLE %s;";
+
+ public static final String SET_DEFAULT_SINGLE_TABLE_STORAGE_UNIT = "SET
DEFAULT SINGLE TABLE STORAGE UNIT = %s;";
+
@Override
public String convert(final SingleRuleConfiguration ruleConfig) {
if (ruleConfig.getTables().isEmpty() &&
!ruleConfig.getDefaultDataSource().isPresent()) {
@@ -34,20 +37,23 @@ public final class
SingleRuleConfigurationToDistSQLConverter implements RuleConf
}
StringBuilder result = new StringBuilder();
if (!ruleConfig.getTables().isEmpty()) {
-
result.append(convertLoadTable(ruleConfig)).append(System.lineSeparator()).append(System.lineSeparator());
+ result.append(convertLoadTable(ruleConfig));
}
if (ruleConfig.getDefaultDataSource().isPresent()) {
-
result.append(convertSetDefaultSingleTableStorageUnit(ruleConfig.getDefaultDataSource().get())).append(System.lineSeparator()).append(System.lineSeparator());
+ if (!ruleConfig.getTables().isEmpty()) {
+
result.append(System.lineSeparator()).append(System.lineSeparator());
+ }
+
result.append(convertSetDefaultSingleTableStorageUnit(ruleConfig.getDefaultDataSource().get()));
}
return result.toString();
}
private String convertLoadTable(final SingleRuleConfiguration ruleConfig) {
- return String.format(SingleDistSQLConstants.LOAD_SINGLE_TABLE,
Joiner.on(SingleDistSQLConstants.COMMA).join(ruleConfig.getTables()));
+ return String.format(LOAD_SINGLE_TABLE,
Joiner.on(",").join(ruleConfig.getTables()));
}
private String convertSetDefaultSingleTableStorageUnit(final String
defaultStorageUnitName) {
- return
String.format(SingleDistSQLConstants.SET_DEFAULT_SINGLE_TABLE_STORAGE_UNIT,
defaultStorageUnitName);
+ return String.format(SET_DEFAULT_SINGLE_TABLE_STORAGE_UNIT,
defaultStorageUnitName);
}
@Override