This is an automated email from the ASF dual-hosted git repository.
jianglongtao 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 954c47a2332 Refactor SHOW ENCRYPT ALGORITHM IMPLEMENTATIONS (#30069)
954c47a2332 is described below
commit 954c47a2332014622dd0509a7da974407fee9a53
Author: yx9o <[email protected]>
AuthorDate: Thu Feb 8 13:46:39 2024 +0800
Refactor SHOW ENCRYPT ALGORITHM IMPLEMENTATIONS (#30069)
---
.../show-encrypt-algorithm-implementations.cn.md | 24 +++++-----
.../show-encrypt-algorithm-implementations.en.md | 22 +++++-----
...howEncryptAlgorithmImplementationsExecutor.java | 51 ----------------------
...howEncryptAlgorithmPluginsResultRowBuilder.java | 48 ++++++++++++++++++++
...stsql.handler.engine.query.DistSQLQueryExecutor | 1 -
...xecutor.ral.plugin.ShowPluginsResultRowBuilder} | 3 +-
...ncryptAlgorithmPluginsResultRowBuilderTest.java | 50 +++++++++++++++++++++
.../core/EncryptDistSQLStatementVisitor.java | 4 +-
...owEncryptAlgorithmImplementationsStatement.java | 26 -----------
9 files changed, 124 insertions(+), 105 deletions(-)
diff --git
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/show-implementation/encrypt/show-encrypt-algorithm-implementations.cn.md
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/show-implementation/encrypt/show-encrypt-algorithm-implementations.cn.md
index 27e9bc87cfb..2ebda044b06 100644
---
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/show-implementation/encrypt/show-encrypt-algorithm-implementations.cn.md
+++
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/show-implementation/encrypt/show-encrypt-algorithm-implementations.cn.md
@@ -23,11 +23,11 @@ showEncryptAlgorithmImplementations ::=
### 返回值说明
-| 列 | 说明 |
-|------|---------|
-| name | 实现类名称 |
-| type | 类型 |
-| class_path | 实现类完整路径 |
+| 列 | 说明 |
+|--------------|--------|
+| type | 类型 |
+| type_aliases | 类型别名 |
+| description | 描述 |
### 示例
@@ -39,12 +39,12 @@ SHOW ENCRYPT ALGORITHM IMPLEMENTATIONS
```sql
SHOW ENCRYPT ALGORITHM IMPLEMENTATIONS;
-+-----------------------------+------+----------------------------------------------------------------------------------+
-| name | type | class_path
|
-+-----------------------------+------+----------------------------------------------------------------------------------+
-| AESEncryptAlgorithm | AES |
org.apache.shardingsphere.encrypt.algorithm.standard.AESEncryptAlgorithm
|
-| MD5AssistedEncryptAlgorithm | MD5 |
org.apache.shardingsphere.encrypt.algorithm.assisted.MD5AssistedEncryptAlgorithm
|
-+-----------------------------+------+----------------------------------------------------------------------------------+
++------+--------------+-------------+
+| type | type_aliases | description |
++------+--------------+-------------+
+| AES | | |
+| MD5 | | |
++------+--------------+-------------+
2 rows in set (0.06 sec)
```
@@ -54,4 +54,4 @@ SHOW ENCRYPT ALGORITHM IMPLEMENTATIONS;
### 相关链接
-- [保留字](/cn/user-manual/shardingsphere-proxy/distsql/syntax/reserved-word/)
\ No newline at end of file
+- [保留字](/cn/user-manual/shardingsphere-proxy/distsql/syntax/reserved-word/)
diff --git
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/show-implementation/encrypt/show-encrypt-algorithm-implementations.en.md
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/show-implementation/encrypt/show-encrypt-algorithm-implementations.en.md
index 015d8d36110..01effc84f05 100644
---
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/show-implementation/encrypt/show-encrypt-algorithm-implementations.en.md
+++
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/show-implementation/encrypt/show-encrypt-algorithm-implementations.en.md
@@ -23,11 +23,11 @@ showEncryptAlgorithmImplementations ::=
### Return Value Description
-| Columns | Description |
-|-------------|---------------------------------------|
-| name | class name of the implementation |
-| type | type of the implementation |
-| class_path | full class name of the implementation |
+| Columns | Description |
+|--------------|--------------|
+| type | type |
+| type_aliases | type aliases |
+| description | description |
### Example
@@ -39,12 +39,12 @@ SHOW ENCRYPT ALGORITHM IMPLEMENTATIONS
```sql
SHOW ENCRYPT ALGORITHM IMPLEMENTATIONS;
-+-----------------------------+------+----------------------------------------------------------------------------------+
-| name | type | class_path
|
-+-----------------------------+------+----------------------------------------------------------------------------------+
-| AESEncryptAlgorithm | AES |
org.apache.shardingsphere.encrypt.algorithm.standard.AESEncryptAlgorithm
|
-| MD5AssistedEncryptAlgorithm | MD5 |
org.apache.shardingsphere.encrypt.algorithm.assisted.MD5AssistedEncryptAlgorithm
|
-+-----------------------------+------+----------------------------------------------------------------------------------+
++------+--------------+-------------+
+| type | type_aliases | description |
++------+--------------+-------------+
+| AES | | |
+| MD5 | | |
++------+--------------+-------------+
2 rows in set (0.06 sec)
```
diff --git
a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptAlgorithmImplementationsExecutor.java
b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptAlgorithmImplementationsExecutor.java
deleted file mode 100644
index e59227bbd38..00000000000
---
a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptAlgorithmImplementationsExecutor.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.encrypt.distsql.handler.query;
-
-import
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
-import
org.apache.shardingsphere.encrypt.distsql.statement.ShowEncryptAlgorithmImplementationsStatement;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
-import
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
-import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
-import org.apache.shardingsphere.mode.manager.ContextManager;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.stream.Collectors;
-
-/**
- * Show encrypt algorithm implementations executor.
- */
-public final class ShowEncryptAlgorithmImplementationsExecutor implements
DistSQLQueryExecutor<ShowEncryptAlgorithmImplementationsStatement> {
-
- @Override
- public Collection<String> getColumnNames() {
- return Arrays.asList("name", "type", "class_path");
- }
-
- @Override
- public Collection<LocalDataQueryResultRow> getRows(final
ShowEncryptAlgorithmImplementationsStatement sqlStatement, final ContextManager
contextManager) {
- Collection<EncryptAlgorithm> encryptAlgorithms =
ShardingSphereServiceLoader.getServiceInstances(EncryptAlgorithm.class);
- return encryptAlgorithms.stream().map(each -> new
LocalDataQueryResultRow(each.getClass().getSimpleName(), each.getType(),
each.getClass().getName())).collect(Collectors.toList());
- }
-
- @Override
- public Class<ShowEncryptAlgorithmImplementationsStatement> getType() {
- return ShowEncryptAlgorithmImplementationsStatement.class;
- }
-}
diff --git
a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptAlgorithmPluginsResultRowBuilder.java
b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptAlgorithmPluginsResultRowBuilder.java
new file mode 100644
index 00000000000..5ceeff49d4e
--- /dev/null
+++
b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptAlgorithmPluginsResultRowBuilder.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.encrypt.distsql.handler.query;
+
+import
org.apache.shardingsphere.distsql.handler.engine.query.ral.algorithm.AlgorithmMetaDataQueryResultRows;
+import
org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder;
+import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
+import
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
+
+import java.util.Collection;
+
+/**
+ * Show encrypt algorithm plugins result row builder.
+ */
+public final class ShowEncryptAlgorithmPluginsResultRowBuilder implements
ShowPluginsResultRowBuilder {
+
+ private final AlgorithmMetaDataQueryResultRows
algorithmMetaDataQueryResultRows = new
AlgorithmMetaDataQueryResultRows(EncryptAlgorithm.class);
+
+ @Override
+ public Collection<LocalDataQueryResultRow> generateRows() {
+ return algorithmMetaDataQueryResultRows.getRows();
+ }
+
+ @Override
+ public Collection<String> getColumnNames() {
+ return algorithmMetaDataQueryResultRows.getColumnNames();
+ }
+
+ @Override
+ public String getType() {
+ return "ENCRYPT_ALGORITHM";
+ }
+}
diff --git
a/features/encrypt/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
b/features/encrypt/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
index 44a71e174bc..45f51c9169f 100644
---
a/features/encrypt/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
+++
b/features/encrypt/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
@@ -16,4 +16,3 @@
#
org.apache.shardingsphere.encrypt.distsql.handler.query.ShowEncryptRuleExecutor
-org.apache.shardingsphere.encrypt.distsql.handler.query.ShowEncryptAlgorithmImplementationsExecutor
diff --git
a/features/encrypt/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
b/features/encrypt/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder
similarity index 87%
copy from
features/encrypt/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
copy to
features/encrypt/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder
index 44a71e174bc..01a13aaf1e6 100644
---
a/features/encrypt/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor
+++
b/features/encrypt/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder
@@ -15,5 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.encrypt.distsql.handler.query.ShowEncryptRuleExecutor
-org.apache.shardingsphere.encrypt.distsql.handler.query.ShowEncryptAlgorithmImplementationsExecutor
+org.apache.shardingsphere.encrypt.distsql.handler.query.ShowEncryptAlgorithmPluginsResultRowBuilder
diff --git
a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptAlgorithmPluginsResultRowBuilderTest.java
b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptAlgorithmPluginsResultRowBuilderTest.java
new file mode 100644
index 00000000000..b47e8c4b9e7
--- /dev/null
+++
b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptAlgorithmPluginsResultRowBuilderTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.encrypt.distsql.handler.query;
+
+import
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
+import org.junit.jupiter.api.Test;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+class ShowEncryptAlgorithmPluginsResultRowBuilderTest {
+
+ @Test
+ void assertGetRowData() {
+ ShowEncryptAlgorithmPluginsResultRowBuilder rowBuilder = new
ShowEncryptAlgorithmPluginsResultRowBuilder();
+ Collection<LocalDataQueryResultRow> actual = rowBuilder.generateRows();
+ assertThat(actual.size(), is(3));
+ Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
+ LocalDataQueryResultRow row = iterator.next();
+ assertThat(row.getCell(1), is("DISTSQL.FIXTURE"));
+ assertThat(row.getCell(2), is(""));
+ assertThat(row.getCell(3), is(""));
+ row = iterator.next();
+ assertThat(row.getCell(1), is("AES"));
+ assertThat(row.getCell(2), is(""));
+ assertThat(row.getCell(3), is(""));
+ row = iterator.next();
+ assertThat(row.getCell(1), is("MD5"));
+ assertThat(row.getCell(2), is(""));
+ assertThat(row.getCell(3), is(""));
+ }
+}
diff --git
a/features/encrypt/distsql/parser/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/core/EncryptDistSQLStatementVisitor.java
b/features/encrypt/distsql/parser/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/core/EncryptDistSQLStatementVisitor.java
index 05eb1e3081b..05e4408eee8 100644
---
a/features/encrypt/distsql/parser/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/core/EncryptDistSQLStatementVisitor.java
+++
b/features/encrypt/distsql/parser/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/core/EncryptDistSQLStatementVisitor.java
@@ -33,6 +33,7 @@ import
org.apache.shardingsphere.distsql.parser.autogen.EncryptDistSQLStatementP
import
org.apache.shardingsphere.distsql.parser.autogen.EncryptDistSQLStatementParser.ShowEncryptRulesContext;
import
org.apache.shardingsphere.distsql.parser.autogen.EncryptDistSQLStatementParser.TableNameContext;
import org.apache.shardingsphere.distsql.segment.AlgorithmSegment;
+import
org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowPluginsStatement;
import
org.apache.shardingsphere.distsql.statement.rql.rule.database.CountRuleStatement;
import
org.apache.shardingsphere.encrypt.distsql.segment.EncryptColumnItemSegment;
import org.apache.shardingsphere.encrypt.distsql.segment.EncryptColumnSegment;
@@ -40,7 +41,6 @@ import
org.apache.shardingsphere.encrypt.distsql.segment.EncryptRuleSegment;
import
org.apache.shardingsphere.encrypt.distsql.statement.AlterEncryptRuleStatement;
import
org.apache.shardingsphere.encrypt.distsql.statement.CreateEncryptRuleStatement;
import
org.apache.shardingsphere.encrypt.distsql.statement.DropEncryptRuleStatement;
-import
org.apache.shardingsphere.encrypt.distsql.statement.ShowEncryptAlgorithmImplementationsStatement;
import
org.apache.shardingsphere.encrypt.distsql.statement.ShowEncryptRulesStatement;
import org.apache.shardingsphere.sql.parser.api.ASTNode;
import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitor;
@@ -142,6 +142,6 @@ public final class EncryptDistSQLStatementVisitor extends
EncryptDistSQLStatemen
@Override
public ASTNode visitShowEncryptAlgorithmImplementations(final
ShowEncryptAlgorithmImplementationsContext ctx) {
- return new ShowEncryptAlgorithmImplementationsStatement();
+ return new ShowPluginsStatement("ENCRYPT_ALGORITHM");
}
}
diff --git
a/features/encrypt/distsql/statement/src/main/java/org/apache/shardingsphere/encrypt/distsql/statement/ShowEncryptAlgorithmImplementationsStatement.java
b/features/encrypt/distsql/statement/src/main/java/org/apache/shardingsphere/encrypt/distsql/statement/ShowEncryptAlgorithmImplementationsStatement.java
deleted file mode 100644
index 859efac000d..00000000000
---
a/features/encrypt/distsql/statement/src/main/java/org/apache/shardingsphere/encrypt/distsql/statement/ShowEncryptAlgorithmImplementationsStatement.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.encrypt.distsql.statement;
-
-import
org.apache.shardingsphere.distsql.statement.ral.queryable.QueryableRALStatement;
-
-/**
- * Show encrypt algorithm implementations statement.
- */
-public final class ShowEncryptAlgorithmImplementationsStatement extends
QueryableRALStatement {
-}