This is an automated email from the ASF dual-hosted git repository.

duanzhengqiang 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 504477ccb44 Refactor ShowKeyGenerateAlgorithmPluginsResultRowBuilder 
(#30076)
504477ccb44 is described below

commit 504477ccb4433094773880ccac33e1535cda6e3e
Author: Raigor <[email protected]>
AuthorDate: Thu Feb 8 17:21:13 2024 +0800

    Refactor ShowKeyGenerateAlgorithmPluginsResultRowBuilder (#30076)
---
 infra/distsql-handler/pom.xml                      |  5 +++
 ...eyGenerateAlgorithmPluginsResultRowBuilder.java | 48 ++++++++++++++++++++
 ...executor.ral.plugin.ShowPluginsResultRowBuilder | 18 ++++++++
 .../core/kernel/KernelDistSQLStatementVisitor.java |  3 +-
 ...yGenerateAlgorithmImplementationsStatement.java | 26 -----------
 ...eyGenerateAlgorithmImplementationsExecutor.java | 51 ----------------------
 ...stsql.handler.engine.query.DistSQLQueryExecutor |  1 -
 7 files changed, 72 insertions(+), 80 deletions(-)

diff --git a/infra/distsql-handler/pom.xml b/infra/distsql-handler/pom.xml
index e548a7ee515..0a3d472ae91 100644
--- a/infra/distsql-handler/pom.xml
+++ b/infra/distsql-handler/pom.xml
@@ -32,6 +32,11 @@
             <artifactId>shardingsphere-infra-merge</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-infra-key-generator-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
         <dependency>
             <groupId>org.apache.shardingsphere</groupId>
             <artifactId>shardingsphere-mode-core</artifactId>
diff --git 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/plugin/ShowKeyGenerateAlgorithmPluginsResultRowBuilder.java
 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/plugin/ShowKeyGenerateAlgorithmPluginsResultRowBuilder.java
new file mode 100644
index 00000000000..6d20d84e344
--- /dev/null
+++ 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/plugin/ShowKeyGenerateAlgorithmPluginsResultRowBuilder.java
@@ -0,0 +1,48 @@
+/*
+ * 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.distsql.handler.executor.ral.plugin;
+
+import 
org.apache.shardingsphere.distsql.handler.engine.query.ral.plugin.PluginMetaDataQueryResultRows;
+import 
org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowPluginsStatement;
+import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
+import org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm;
+
+import java.util.Collection;
+
+/**
+ * Show key generate algorithm plugins result row builder.
+ */
+public final class ShowKeyGenerateAlgorithmPluginsResultRowBuilder implements 
ShowPluginsResultRowBuilder {
+    
+    private final PluginMetaDataQueryResultRows pluginMetaDataQueryResultRows 
= new PluginMetaDataQueryResultRows(KeyGenerateAlgorithm.class);
+    
+    @Override
+    public Collection<LocalDataQueryResultRow> generateRows(final 
ShowPluginsStatement sqlStatement) {
+        return pluginMetaDataQueryResultRows.getRows();
+    }
+    
+    @Override
+    public Collection<String> getColumnNames() {
+        return pluginMetaDataQueryResultRows.getColumnNames();
+    }
+    
+    @Override
+    public String getType() {
+        return "KEY_GENERATE_ALGORITHM";
+    }
+}
diff --git 
a/infra/distsql-handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder
 
b/infra/distsql-handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder
new file mode 100644
index 00000000000..cc7a6f79af0
--- /dev/null
+++ 
b/infra/distsql-handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowKeyGenerateAlgorithmPluginsResultRowBuilder
diff --git 
a/parser/distsql/engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/kernel/KernelDistSQLStatementVisitor.java
 
b/parser/distsql/engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/kernel/KernelDistSQLStatementVisitor.java
index 6ad24ff53eb..f8ca21bd83e 100644
--- 
a/parser/distsql/engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/kernel/KernelDistSQLStatementVisitor.java
+++ 
b/parser/distsql/engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/kernel/KernelDistSQLStatementVisitor.java
@@ -85,7 +85,6 @@ import 
org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowComput
 import 
org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowComputeNodesStatement;
 import 
org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowDistVariableStatement;
 import 
org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowDistVariablesStatement;
-import 
org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowKeyGenerateAlgorithmImplementationsStatement;
 import 
org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowMigrationRuleStatement;
 import 
org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowPluginsStatement;
 import 
org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowTableMetaDataStatement;
@@ -413,6 +412,6 @@ public final class KernelDistSQLStatementVisitor extends 
KernelDistSQLStatementB
     
     @Override
     public ASTNode visitShowKeyGenerateAlgorithmImplementations(final 
ShowKeyGenerateAlgorithmImplementationsContext ctx) {
-        return new ShowKeyGenerateAlgorithmImplementationsStatement();
+        return new ShowPluginsStatement("KEY_GENERATE_ALGORITHM");
     }
 }
diff --git 
a/parser/distsql/statement/src/main/java/org/apache/shardingsphere/distsql/statement/ral/queryable/show/ShowKeyGenerateAlgorithmImplementationsStatement.java
 
b/parser/distsql/statement/src/main/java/org/apache/shardingsphere/distsql/statement/ral/queryable/show/ShowKeyGenerateAlgorithmImplementationsStatement.java
deleted file mode 100644
index f5ede7c2aad..00000000000
--- 
a/parser/distsql/statement/src/main/java/org/apache/shardingsphere/distsql/statement/ral/queryable/show/ShowKeyGenerateAlgorithmImplementationsStatement.java
+++ /dev/null
@@ -1,26 +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.distsql.statement.ral.queryable.show;
-
-import 
org.apache.shardingsphere.distsql.statement.ral.queryable.QueryableRALStatement;
-
-/**
- * Show key generate algorithm implementations statement.
- */
-public final class ShowKeyGenerateAlgorithmImplementationsStatement extends 
QueryableRALStatement {
-}
diff --git 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowKeyGenerateAlgorithmImplementationsExecutor.java
 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowKeyGenerateAlgorithmImplementationsExecutor.java
deleted file mode 100644
index cb73195518b..00000000000
--- 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowKeyGenerateAlgorithmImplementationsExecutor.java
+++ /dev/null
@@ -1,51 +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.proxy.backend.handler.distsql.ral.queryable;
-
-import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
-import 
org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowKeyGenerateAlgorithmImplementationsStatement;
-import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
-import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
-import org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm;
-import org.apache.shardingsphere.mode.manager.ContextManager;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.stream.Collectors;
-
-/**
- * Show key generate algorithm implementations executor.
- */
-public final class ShowKeyGenerateAlgorithmImplementationsExecutor implements 
DistSQLQueryExecutor<ShowKeyGenerateAlgorithmImplementationsStatement> {
-    
-    @Override
-    public Collection<String> getColumnNames() {
-        return Arrays.asList("name", "type", "class_path");
-    }
-    
-    @Override
-    public Collection<LocalDataQueryResultRow> getRows(final 
ShowKeyGenerateAlgorithmImplementationsStatement sqlStatement, final 
ContextManager contextManager) {
-        Collection<KeyGenerateAlgorithm> keyGenerateAlgorithms = 
ShardingSphereServiceLoader.getServiceInstances(KeyGenerateAlgorithm.class);
-        return keyGenerateAlgorithms.stream().map(each -> new 
LocalDataQueryResultRow(each.getClass().getSimpleName(), each.getType(), 
each.getClass().getName())).collect(Collectors.toList());
-    }
-    
-    @Override
-    public Class<ShowKeyGenerateAlgorithmImplementationsStatement> getType() {
-        return ShowKeyGenerateAlgorithmImplementationsStatement.class;
-    }
-}
diff --git 
a/proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
 
b/proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
index 52ec378bec1..951c8248f9e 100644
--- 
a/proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
+++ 
b/proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
@@ -26,7 +26,6 @@ 
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.ShowDistVa
 
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.ShowDistVariablesExecutor
 
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.ShowTableMetaDataExecutor
 
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.ShowMigrationRuleExecutor
-org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.ShowKeyGenerateAlgorithmImplementationsExecutor
 org.apache.shardingsphere.proxy.backend.handler.distsql.rul.FormatSQLExecutor
 
org.apache.shardingsphere.proxy.backend.handler.distsql.rul.ParseDistSQLExecutor
 org.apache.shardingsphere.proxy.backend.handler.distsql.rul.PreviewExecutor

Reply via email to