This is an automated email from the ASF dual-hosted git repository.
wuweijie 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 694943c57f9 Remove ShowPluginsResultRowBuilder.generateRows() (#30091)
694943c57f9 is described below
commit 694943c57f9c73828183047b948d1bb68fee31a5
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Feb 11 21:06:45 2024 +0800
Remove ShowPluginsResultRowBuilder.generateRows() (#30091)
* Refactor ShowPluginsExecutor
* Remove ShowPluginsResultRowBuilder.generateRows()
* Remove ShowPluginsResultRowBuilder.generateRows()
---
...howEncryptAlgorithmPluginsResultRowBuilder.java | 12 ---
...ncryptAlgorithmPluginsResultRowBuilderTest.java | 52 -----------
.../ShowMaskAlgorithmPluginsResultRowBuilder.java | 12 ---
...oadBalanceAlgorithmPluginsResultRowBuilder.java | 12 ---
...alanceAlgorithmPluginsResultRowBuilderTest.java | 56 ------------
...ShowShadowAlgorithmPluginsResultRowBuilder.java | 12 ---
...owShardingAlgorithmPluginsResultRowBuilder.java | 12 ---
...ardingAlgorithmPluginsResultRowBuilderTest.java | 101 ---------------------
.../ral/plugin/PluginMetaDataQueryResultRows.java | 10 +-
.../executor/ral/plugin/ShowPluginsExecutor.java | 36 +++++++-
.../ral/plugin/ShowPluginsResultRowBuilder.java | 12 ---
.../type/ShowCommonPluginsResultRowBuilder.java | 25 +++--
...eyGenerateAlgorithmPluginsResultRowBuilder.java | 12 ---
.../ral/queryable/show/ShowPluginsStatement.java | 11 +++
.../ShowCommonPluginsResultRowBuilder.java | 60 ------------
...executor.ral.plugin.ShowPluginsResultRowBuilder | 2 +-
16 files changed, 59 insertions(+), 378 deletions(-)
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
index d81568a9c99..abef9c09354 100644
---
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
@@ -17,26 +17,14 @@
package org.apache.shardingsphere.encrypt.distsql.handler.query;
-import
org.apache.shardingsphere.distsql.handler.engine.query.ral.plugin.PluginMetaDataQueryResultRows;
import
org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder;
-import
org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowPluginsStatement;
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 PluginMetaDataQueryResultRows pluginMetaDataQueryResultRows
= new PluginMetaDataQueryResultRows(EncryptAlgorithm.class);
-
- @Override
- public Collection<LocalDataQueryResultRow> generateRows(final
ShowPluginsStatement sqlStatement) {
- return pluginMetaDataQueryResultRows.getRows();
- }
-
@Override
public Class<EncryptAlgorithm> getPluginClass() {
return EncryptAlgorithm.class;
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
deleted file mode 100644
index f72461ab1e2..00000000000
---
a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptAlgorithmPluginsResultRowBuilderTest.java
+++ /dev/null
@@ -1,52 +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.statement.ral.queryable.show.ShowPluginsStatement;
-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;
-import static org.mockito.Mockito.mock;
-
-class ShowEncryptAlgorithmPluginsResultRowBuilderTest {
-
- @Test
- void assertGetRowData() {
- ShowEncryptAlgorithmPluginsResultRowBuilder rowBuilder = new
ShowEncryptAlgorithmPluginsResultRowBuilder();
- Collection<LocalDataQueryResultRow> actual =
rowBuilder.generateRows(mock(ShowPluginsStatement.class));
- 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/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskAlgorithmPluginsResultRowBuilder.java
b/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskAlgorithmPluginsResultRowBuilder.java
index d421806e07c..b19c6b828f4 100644
---
a/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskAlgorithmPluginsResultRowBuilder.java
+++
b/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskAlgorithmPluginsResultRowBuilder.java
@@ -17,26 +17,14 @@
package org.apache.shardingsphere.mask.distsql.handler.query;
-import
org.apache.shardingsphere.distsql.handler.engine.query.ral.plugin.PluginMetaDataQueryResultRows;
import
org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder;
-import
org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowPluginsStatement;
-import
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
-import java.util.Collection;
-
/**
* Show mask algorithm plugins result row builder.
*/
public final class ShowMaskAlgorithmPluginsResultRowBuilder implements
ShowPluginsResultRowBuilder {
- private final PluginMetaDataQueryResultRows pluginMetaDataQueryResultRows
= new PluginMetaDataQueryResultRows(MaskAlgorithm.class);
-
- @Override
- public Collection<LocalDataQueryResultRow> generateRows(final
ShowPluginsStatement sqlStatement) {
- return pluginMetaDataQueryResultRows.getRows();
- }
-
@SuppressWarnings("rawtypes")
@Override
public Class<MaskAlgorithm> getPluginClass() {
diff --git
a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowReadQueryLoadBalanceAlgorithmPluginsResultRowBuilder.java
b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowReadQueryLoadBalanceAlgorithmPluginsResultRowBuilder.java
index 82de3dd8e1f..0927866e593 100644
---
a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowReadQueryLoadBalanceAlgorithmPluginsResultRowBuilder.java
+++
b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowReadQueryLoadBalanceAlgorithmPluginsResultRowBuilder.java
@@ -17,26 +17,14 @@
package org.apache.shardingsphere.readwritesplitting.distsql.handler.query;
-import
org.apache.shardingsphere.distsql.handler.engine.query.ral.plugin.PluginMetaDataQueryResultRows;
import
org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder;
-import
org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowPluginsStatement;
-import
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
import
org.apache.shardingsphere.readwritesplitting.spi.ReadQueryLoadBalanceAlgorithm;
-import java.util.Collection;
-
/**
* Show read query load balance algorithm plugins result row builder.
*/
public final class ShowReadQueryLoadBalanceAlgorithmPluginsResultRowBuilder
implements ShowPluginsResultRowBuilder {
- private final PluginMetaDataQueryResultRows pluginMetaDataQueryResultRows
= new PluginMetaDataQueryResultRows(ReadQueryLoadBalanceAlgorithm.class);
-
- @Override
- public Collection<LocalDataQueryResultRow> generateRows(final
ShowPluginsStatement sqlStatement) {
- return pluginMetaDataQueryResultRows.getRows();
- }
-
@Override
public Class<ReadQueryLoadBalanceAlgorithm> getPluginClass() {
return ReadQueryLoadBalanceAlgorithm.class;
diff --git
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowReadQueryLoadBalanceAlgorithmPluginsResultRowBuilderTest.java
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowReadQueryLoadBalanceAlgorithmPluginsResultRowBuilderTest.java
deleted file mode 100644
index fae32381f54..00000000000
---
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowReadQueryLoadBalanceAlgorithmPluginsResultRowBuilderTest.java
+++ /dev/null
@@ -1,56 +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.readwritesplitting.distsql.handler.query;
-
-import
org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowPluginsStatement;
-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;
-import static org.mockito.Mockito.mock;
-
-class ShowReadQueryLoadBalanceAlgorithmPluginsResultRowBuilderTest {
-
- @Test
- void assertGetRowData() {
- ShowReadQueryLoadBalanceAlgorithmPluginsResultRowBuilder rowBuilder =
new ShowReadQueryLoadBalanceAlgorithmPluginsResultRowBuilder();
- Collection<LocalDataQueryResultRow> actual =
rowBuilder.generateRows(mock(ShowPluginsStatement.class));
- assertThat(actual.size(), is(4));
- 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("ROUND_ROBIN"));
- assertThat(row.getCell(2), is(""));
- assertThat(row.getCell(3), is(""));
- row = iterator.next();
- assertThat(row.getCell(1), is("RANDOM"));
- assertThat(row.getCell(2), is(""));
- assertThat(row.getCell(3), is(""));
- row = iterator.next();
- assertThat(row.getCell(1), is("WEIGHT"));
- assertThat(row.getCell(2), is(""));
- assertThat(row.getCell(3), is(""));
- }
-}
diff --git
a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShowShadowAlgorithmPluginsResultRowBuilder.java
b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShowShadowAlgorithmPluginsResultRowBuilder.java
index bd40b1d2608..6e9a14293c7 100644
---
a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShowShadowAlgorithmPluginsResultRowBuilder.java
+++
b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/ShowShadowAlgorithmPluginsResultRowBuilder.java
@@ -17,26 +17,14 @@
package org.apache.shardingsphere.shadow.distsql.handler.query;
-import
org.apache.shardingsphere.distsql.handler.engine.query.ral.plugin.PluginMetaDataQueryResultRows;
import
org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder;
-import
org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowPluginsStatement;
-import
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
import org.apache.shardingsphere.shadow.spi.ShadowAlgorithm;
-import java.util.Collection;
-
/**
* Show shadow algorithm plugins result row builder.
*/
public final class ShowShadowAlgorithmPluginsResultRowBuilder implements
ShowPluginsResultRowBuilder {
- private final PluginMetaDataQueryResultRows pluginMetaDataQueryResultRows
= new PluginMetaDataQueryResultRows(ShadowAlgorithm.class);
-
- @Override
- public Collection<LocalDataQueryResultRow> generateRows(final
ShowPluginsStatement sqlStatement) {
- return pluginMetaDataQueryResultRows.getRows();
- }
-
@Override
public Class<ShadowAlgorithm> getPluginClass() {
return ShadowAlgorithm.class;
diff --git
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingAlgorithmPluginsResultRowBuilder.java
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingAlgorithmPluginsResultRowBuilder.java
index c47a38916fc..131059cf7fd 100644
---
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingAlgorithmPluginsResultRowBuilder.java
+++
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingAlgorithmPluginsResultRowBuilder.java
@@ -17,26 +17,14 @@
package org.apache.shardingsphere.sharding.distsql.handler.query;
-import
org.apache.shardingsphere.distsql.handler.engine.query.ral.plugin.PluginMetaDataQueryResultRows;
import
org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder;
-import
org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowPluginsStatement;
-import
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm;
-import java.util.Collection;
-
/**
* Show sharding algorithm plugins result row builder.
*/
public final class ShowShardingAlgorithmPluginsResultRowBuilder implements
ShowPluginsResultRowBuilder {
- private final PluginMetaDataQueryResultRows pluginMetaDataQueryResultRows
= new PluginMetaDataQueryResultRows(ShardingAlgorithm.class);
-
- @Override
- public Collection<LocalDataQueryResultRow> generateRows(final
ShowPluginsStatement sqlStatement) {
- return pluginMetaDataQueryResultRows.getRows();
- }
-
@Override
public Class<ShardingAlgorithm> getPluginClass() {
return ShardingAlgorithm.class;
diff --git
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingAlgorithmPluginsResultRowBuilderTest.java
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingAlgorithmPluginsResultRowBuilderTest.java
deleted file mode 100644
index baf9a4d502d..00000000000
---
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingAlgorithmPluginsResultRowBuilderTest.java
+++ /dev/null
@@ -1,101 +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.sharding.distsql.query;
-
-import
org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowPluginsStatement;
-import
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
-import
org.apache.shardingsphere.sharding.distsql.handler.query.ShowShardingAlgorithmPluginsResultRowBuilder;
-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;
-import static org.mockito.Mockito.mock;
-
-class ShowShardingAlgorithmPluginsResultRowBuilderTest {
-
- @Test
- void assertGetRowData() {
- ShowShardingAlgorithmPluginsResultRowBuilder rowBuilder = new
ShowShardingAlgorithmPluginsResultRowBuilder();
- Collection<LocalDataQueryResultRow> actual =
rowBuilder.generateRows(mock(ShowPluginsStatement.class));
- assertThat(actual.size(), is(15));
- Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
- LocalDataQueryResultRow row = iterator.next();
- assertThat(row.getCell(1), is("FOO.DISTSQL.FIXTURE"));
- assertThat(row.getCell(2), is(""));
- assertThat(row.getCell(3), is(""));
- row = iterator.next();
- assertThat(row.getCell(1), is("BAR.DISTSQL.FIXTURE"));
- assertThat(row.getCell(2), is(""));
- assertThat(row.getCell(3), is(""));
- row = iterator.next();
- assertThat(row.getCell(1), is("CORE.HINT.FIXTURE"));
- assertThat(row.getCell(2), is(""));
- assertThat(row.getCell(3), is(""));
- row = iterator.next();
- assertThat(row.getCell(1), is("CORE.AUTO.FIXTURE"));
- assertThat(row.getCell(2), is(""));
- assertThat(row.getCell(3), is(""));
- row = iterator.next();
- assertThat(row.getCell(1), is("CORE.STANDARD.FIXTURE"));
- assertThat(row.getCell(2), is(""));
- assertThat(row.getCell(3), is(""));
- row = iterator.next();
- assertThat(row.getCell(1), is("MOD"));
- assertThat(row.getCell(2), is(""));
- assertThat(row.getCell(3), is(""));
- row = iterator.next();
- assertThat(row.getCell(1), is("HASH_MOD"));
- assertThat(row.getCell(2), is(""));
- assertThat(row.getCell(3), is(""));
- row = iterator.next();
- assertThat(row.getCell(1), is("VOLUME_RANGE"));
- assertThat(row.getCell(2), is(""));
- assertThat(row.getCell(3), is(""));
- row = iterator.next();
- assertThat(row.getCell(1), is("BOUNDARY_RANGE"));
- assertThat(row.getCell(2), is(""));
- assertThat(row.getCell(3), is(""));
- row = iterator.next();
- assertThat(row.getCell(1), is("AUTO_INTERVAL"));
- assertThat(row.getCell(2), is(""));
- assertThat(row.getCell(3), is(""));
- row = iterator.next();
- assertThat(row.getCell(1), is("INTERVAL"));
- assertThat(row.getCell(2), is(""));
- assertThat(row.getCell(3), is(""));
- row = iterator.next();
- assertThat(row.getCell(1), is("CLASS_BASED"));
- assertThat(row.getCell(2), is(""));
- assertThat(row.getCell(3), is(""));
- row = iterator.next();
- assertThat(row.getCell(1), is("INLINE"));
- assertThat(row.getCell(2), is(""));
- assertThat(row.getCell(3), is(""));
- row = iterator.next();
- assertThat(row.getCell(1), is("COMPLEX_INLINE"));
- assertThat(row.getCell(2), is(""));
- assertThat(row.getCell(3), is(""));
- row = iterator.next();
- assertThat(row.getCell(1), is("HINT_INLINE"));
- assertThat(row.getCell(2), is(""));
- assertThat(row.getCell(3), is(""));
- }
-}
diff --git
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/query/ral/plugin/PluginMetaDataQueryResultRows.java
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/query/ral/plugin/PluginMetaDataQueryResultRows.java
index c5b3f5bf487..de5ac9062aa 100644
---
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/query/ral/plugin/PluginMetaDataQueryResultRows.java
+++
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/engine/query/ral/plugin/PluginMetaDataQueryResultRows.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.distsql.handler.engine.query.ral.plugin;
+import lombok.RequiredArgsConstructor;
import
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
@@ -27,13 +28,10 @@ import java.util.stream.Collectors;
/**
* Plugin meta data query result rows.
*/
+@RequiredArgsConstructor
public final class PluginMetaDataQueryResultRows {
- private final Collection<PluginMetaDataQueryResultRow> rows;
-
- public PluginMetaDataQueryResultRows(final Class<? extends TypedSPI>
pluginClass) {
- rows =
ShardingSphereServiceLoader.getServiceInstances(pluginClass).stream().map(PluginMetaDataQueryResultRow::new).collect(Collectors.toList());
- }
+ private final Class<? extends TypedSPI> pluginClass;
/**
* Get rows.
@@ -41,6 +39,6 @@ public final class PluginMetaDataQueryResultRows {
* @return rows
*/
public Collection<LocalDataQueryResultRow> getRows() {
- return
rows.stream().map(PluginMetaDataQueryResultRow::toLocalDataQueryResultRow).collect(Collectors.toList());
+ return
ShardingSphereServiceLoader.getServiceInstances(pluginClass).stream().map(each
-> new
PluginMetaDataQueryResultRow(each).toLocalDataQueryResultRow()).collect(Collectors.toList());
}
}
diff --git
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/plugin/ShowPluginsExecutor.java
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/plugin/ShowPluginsExecutor.java
index de0bad0b1fd..72cde233e2b 100644
---
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/plugin/ShowPluginsExecutor.java
+++
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/plugin/ShowPluginsExecutor.java
@@ -18,16 +18,21 @@
package org.apache.shardingsphere.distsql.handler.executor.ral.plugin;
import
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecutor;
+import
org.apache.shardingsphere.distsql.handler.engine.query.ral.plugin.PluginMetaDataQueryResultRow;
+import
org.apache.shardingsphere.distsql.handler.exception.plugin.PluginNotFoundException;
import
org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowPluginsStatement;
import
org.apache.shardingsphere.infra.database.core.spi.DatabaseSupportedTypedSPI;
+import
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
+import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.mode.manager.ContextManager;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
-import java.util.Optional;
+import java.util.List;
+import java.util.stream.Collectors;
/**
* Show plugins executor.
@@ -36,15 +41,36 @@ public final class ShowPluginsExecutor implements
DistSQLQueryExecutor<ShowPlugi
@Override
public Collection<String> getColumnNames(final ShowPluginsStatement
sqlStatement) {
- Optional<ShowPluginsResultRowBuilder> rowBuilder =
TypedSPILoader.findService(ShowPluginsResultRowBuilder.class,
sqlStatement.getType());
- return rowBuilder.isPresent() &&
DatabaseSupportedTypedSPI.class.isAssignableFrom(rowBuilder.get().getPluginClass())
+ return getColumnNames(getPluginClass(sqlStatement));
+ }
+
+ private List<String> getColumnNames(final Class<? extends TypedSPI>
pluginClass) {
+ return DatabaseSupportedTypedSPI.class.isAssignableFrom(pluginClass)
? Arrays.asList("type", "type_aliases",
"supported_database_types", "description")
: Arrays.asList("type", "type_aliases", "description");
}
+ private Class<? extends TypedSPI> getPluginClass(final
ShowPluginsStatement sqlStatement) {
+ return sqlStatement.getPluginClass().isPresent()
+ ? getPluginClass(sqlStatement.getPluginClass().get())
+ : TypedSPILoader.getService(ShowPluginsResultRowBuilder.class,
sqlStatement.getType()).getPluginClass();
+ }
+
+ @SuppressWarnings("unchecked")
+ private Class<? extends TypedSPI> getPluginClass(final String pluginClass)
{
+ try {
+ Class<?> result = Class.forName(pluginClass);
+
ShardingSpherePreconditions.checkState(TypedSPI.class.isAssignableFrom(result),
() -> new UnsupportedOperationException("The plugin class to be queried must
extend TypedSPI."));
+ return (Class<? extends TypedSPI>) result;
+ } catch (final ClassNotFoundException ignored) {
+ throw new PluginNotFoundException(pluginClass);
+ }
+ }
+
@Override
public Collection<LocalDataQueryResultRow> getRows(final
ShowPluginsStatement sqlStatement, final ContextManager contextManager) {
- return TypedSPILoader.findService(ShowPluginsResultRowBuilder.class,
sqlStatement.getType()).map(optional ->
optional.generateRows(sqlStatement)).orElse(Collections.emptyList());
+ return
ShardingSphereServiceLoader.getServiceInstances(getPluginClass(sqlStatement)).stream()
+ .map(each -> new
PluginMetaDataQueryResultRow(each).toLocalDataQueryResultRow()).collect(Collectors.toList());
}
@Override
diff --git
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/plugin/ShowPluginsResultRowBuilder.java
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/plugin/ShowPluginsResultRowBuilder.java
index 1d1e0422321..de161de1192 100644
---
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/plugin/ShowPluginsResultRowBuilder.java
+++
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/plugin/ShowPluginsResultRowBuilder.java
@@ -17,27 +17,15 @@
package org.apache.shardingsphere.distsql.handler.executor.ral.plugin;
-import
org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowPluginsStatement;
-import
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
-import java.util.Collection;
-
/**
* Show plugins result row builder.
*/
@SingletonSPI
public interface ShowPluginsResultRowBuilder extends TypedSPI {
- /**
- * Generate rows.
- *
- * @param sqlStatement SQL statement
- * @return generated rows
- */
- Collection<LocalDataQueryResultRow> generateRows(ShowPluginsStatement
sqlStatement);
-
/**
* Get plugin class.
*
diff --git
a/parser/distsql/statement/src/main/java/org/apache/shardingsphere/distsql/statement/ral/queryable/show/ShowPluginsStatement.java
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/plugin/type/ShowCommonPluginsResultRowBuilder.java
similarity index 60%
copy from
parser/distsql/statement/src/main/java/org/apache/shardingsphere/distsql/statement/ral/queryable/show/ShowPluginsStatement.java
copy to
infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/plugin/type/ShowCommonPluginsResultRowBuilder.java
index bc42a6fd2de..9433efac444 100644
---
a/parser/distsql/statement/src/main/java/org/apache/shardingsphere/distsql/statement/ral/queryable/show/ShowPluginsStatement.java
+++
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/plugin/type/ShowCommonPluginsResultRowBuilder.java
@@ -15,24 +15,23 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.distsql.statement.ral.queryable.show;
+package org.apache.shardingsphere.distsql.handler.executor.ral.plugin.type;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import
org.apache.shardingsphere.distsql.statement.ral.queryable.QueryableRALStatement;
+import
org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
/**
- * Show plugins statement.
+ * Show common plugins result row builder.
*/
-@RequiredArgsConstructor
-@Getter
-public final class ShowPluginsStatement extends QueryableRALStatement {
+public final class ShowCommonPluginsResultRowBuilder implements
ShowPluginsResultRowBuilder {
- private final String type;
-
- private final String pluginClass;
+ @Override
+ public Class<TypedSPI> getPluginClass() {
+ return TypedSPI.class;
+ }
- public ShowPluginsStatement(final String type) {
- this(type, null);
+ @Override
+ public String getType() {
+ return "COMMON";
}
}
diff --git
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/plugin/type/ShowKeyGenerateAlgorithmPluginsResultRowBuilder.java
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/plugin/type/ShowKeyGenerateAlgorithmPluginsResultRowBuilder.java
index 79c4315048a..f1521c6efa8 100644
---
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/plugin/type/ShowKeyGenerateAlgorithmPluginsResultRowBuilder.java
+++
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/ral/plugin/type/ShowKeyGenerateAlgorithmPluginsResultRowBuilder.java
@@ -17,26 +17,14 @@
package org.apache.shardingsphere.distsql.handler.executor.ral.plugin.type;
-import
org.apache.shardingsphere.distsql.handler.engine.query.ral.plugin.PluginMetaDataQueryResultRows;
import
org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder;
-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 Class<KeyGenerateAlgorithm> getPluginClass() {
return KeyGenerateAlgorithm.class;
diff --git
a/parser/distsql/statement/src/main/java/org/apache/shardingsphere/distsql/statement/ral/queryable/show/ShowPluginsStatement.java
b/parser/distsql/statement/src/main/java/org/apache/shardingsphere/distsql/statement/ral/queryable/show/ShowPluginsStatement.java
index bc42a6fd2de..cd28d67307d 100644
---
a/parser/distsql/statement/src/main/java/org/apache/shardingsphere/distsql/statement/ral/queryable/show/ShowPluginsStatement.java
+++
b/parser/distsql/statement/src/main/java/org/apache/shardingsphere/distsql/statement/ral/queryable/show/ShowPluginsStatement.java
@@ -21,6 +21,8 @@ import lombok.Getter;
import lombok.RequiredArgsConstructor;
import
org.apache.shardingsphere.distsql.statement.ral.queryable.QueryableRALStatement;
+import java.util.Optional;
+
/**
* Show plugins statement.
*/
@@ -35,4 +37,13 @@ public final class ShowPluginsStatement extends
QueryableRALStatement {
public ShowPluginsStatement(final String type) {
this(type, null);
}
+
+ /**
+ * Get plugin class.
+ *
+ * @return plugin class
+ */
+ public Optional<String> getPluginClass() {
+ return Optional.ofNullable(pluginClass);
+ }
}
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowCommonPluginsResultRowBuilder.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowCommonPluginsResultRowBuilder.java
deleted file mode 100644
index 9a4f52ca6a4..00000000000
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowCommonPluginsResultRowBuilder.java
+++ /dev/null
@@ -1,60 +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.ral.plugin.PluginMetaDataQueryResultRows;
-import
org.apache.shardingsphere.distsql.handler.exception.plugin.PluginNotFoundException;
-import
org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder;
-import
org.apache.shardingsphere.distsql.statement.ral.queryable.show.ShowPluginsStatement;
-import
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
-import
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
-
-import java.util.Collection;
-
-/**
- * Show common plugins result row builder.
- */
-public final class ShowCommonPluginsResultRowBuilder implements
ShowPluginsResultRowBuilder {
-
- @Override
- public Collection<LocalDataQueryResultRow> generateRows(final
ShowPluginsStatement sqlStatement) {
- return new
PluginMetaDataQueryResultRows(getPluginClass(sqlStatement)).getRows();
- }
-
- @SuppressWarnings("unchecked")
- private static Class<? extends TypedSPI> getPluginClass(final
ShowPluginsStatement sqlStatement) {
- try {
- Class<?> result = Class.forName(sqlStatement.getPluginClass());
-
ShardingSpherePreconditions.checkState(TypedSPI.class.isAssignableFrom(result),
() -> new UnsupportedOperationException("The plugin class to be queried must
extend TypedSPI."));
- return (Class<? extends TypedSPI>) result;
- } catch (final ClassNotFoundException ignore) {
- throw new PluginNotFoundException(sqlStatement.getPluginClass());
- }
- }
-
- @Override
- public Class<TypedSPI> getPluginClass() {
- return TypedSPI.class;
- }
-
- @Override
- public String getType() {
- return "COMMON";
- }
-}
diff --git
a/proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder
b/proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder
index b6aacec7a43..31d43e657d6 100644
---
a/proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder
+++
b/proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.ral.plugin.ShowPluginsResultRowBuilder
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.ShowCommonPluginsResultRowBuilder
+org.apache.shardingsphere.distsql.handler.executor.ral.plugin.type.ShowCommonPluginsResultRowBuilder