Skip to content

Commit

Permalink
Refactor ShowShadowAlgorithmPluginsResultRowBuilder & ShowMaskAlgorit…
Browse files Browse the repository at this point in the history
…hmPluginsResultRowBuilder (#30079)

* Refactor ShowShadowAlgorithmPluginsResultRowBuilder

* Refactor ShowMaskAlgorithmPluginsResultRowBuilder
  • Loading branch information
RaigorJiang authored Feb 8, 2024
1 parent df78716 commit 1d727c6
Show file tree
Hide file tree
Showing 12 changed files with 138 additions and 161 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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.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();
}

@Override
public Collection<String> getColumnNames() {
return pluginMetaDataQueryResultRows.getColumnNames();
}

@Override
public String getType() {
return "MASK_ALGORITHM";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@
#

org.apache.shardingsphere.mask.distsql.handler.query.ShowMaskRuleExecutor
org.apache.shardingsphere.mask.distsql.handler.query.ShowMaskAlgorithmImplementationsExecutor
Original file line number Diff line number Diff line change
@@ -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.mask.distsql.handler.query.ShowMaskAlgorithmPluginsResultRowBuilder
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
import org.apache.shardingsphere.distsql.parser.autogen.MaskDistSQLStatementParser.ShowMaskAlgorithmImplementationsContext;
import org.apache.shardingsphere.distsql.parser.autogen.MaskDistSQLStatementParser.ShowMaskRulesContext;
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.mask.distsql.segment.MaskColumnSegment;
import org.apache.shardingsphere.mask.distsql.segment.MaskRuleSegment;
import org.apache.shardingsphere.mask.distsql.statement.AlterMaskRuleStatement;
import org.apache.shardingsphere.mask.distsql.statement.CreateMaskRuleStatement;
import org.apache.shardingsphere.mask.distsql.statement.DropMaskRuleStatement;
import org.apache.shardingsphere.mask.distsql.statement.ShowMaskAlgorithmImplementationsStatement;
import org.apache.shardingsphere.mask.distsql.statement.ShowMaskRulesStatement;
import org.apache.shardingsphere.sql.parser.api.ASTNode;
import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitor;
Expand Down Expand Up @@ -116,6 +116,6 @@ public ASTNode visitDatabaseName(final DatabaseNameContext ctx) {

@Override
public ASTNode visitShowMaskAlgorithmImplementations(final ShowMaskAlgorithmImplementationsContext ctx) {
return new ShowMaskAlgorithmImplementationsStatement();
return new ShowPluginsStatement("MASK_ALGORITHM");
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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.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 Collection<String> getColumnNames() {
return pluginMetaDataQueryResultRows.getColumnNames();
}

@Override
public String getType() {
return "SHADOW_ALGORITHM";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ org.apache.shardingsphere.shadow.distsql.handler.query.ShowShadowRuleExecutor
org.apache.shardingsphere.shadow.distsql.handler.query.ShowShadowTableRulesExecutor
org.apache.shardingsphere.shadow.distsql.handler.query.ShowShadowAlgorithmsExecutor
org.apache.shardingsphere.shadow.distsql.handler.query.ShowDefaultShadowAlgorithmExecutor
org.apache.shardingsphere.shadow.distsql.handler.query.ShowShadowAlgorithmImplementationsExecutor
Original file line number Diff line number Diff line change
@@ -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.shadow.distsql.handler.query.ShowShadowAlgorithmPluginsResultRowBuilder
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.apache.shardingsphere.distsql.parser.autogen.ShadowDistSQLStatementParser.ShowShadowRulesContext;
import org.apache.shardingsphere.distsql.parser.autogen.ShadowDistSQLStatementParser.ShowShadowTableRulesContext;
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.shadow.distsql.segment.ShadowAlgorithmSegment;
import org.apache.shardingsphere.shadow.distsql.segment.ShadowRuleSegment;
Expand All @@ -49,7 +50,6 @@
import org.apache.shardingsphere.shadow.distsql.statement.DropShadowAlgorithmStatement;
import org.apache.shardingsphere.shadow.distsql.statement.DropShadowRuleStatement;
import org.apache.shardingsphere.shadow.distsql.statement.ShowDefaultShadowAlgorithmStatement;
import org.apache.shardingsphere.shadow.distsql.statement.ShowShadowAlgorithmImplementationsStatement;
import org.apache.shardingsphere.shadow.distsql.statement.ShowShadowAlgorithmsStatement;
import org.apache.shardingsphere.shadow.distsql.statement.ShowShadowRulesStatement;
import org.apache.shardingsphere.shadow.distsql.statement.ShowShadowTableRulesStatement;
Expand Down Expand Up @@ -206,6 +206,6 @@ private String buildAlgorithmName(final String ruleName, final String tableName,

@Override
public ASTNode visitShowShadowAlgorithmImplementations(final ShowShadowAlgorithmImplementationsContext ctx) {
return new ShowShadowAlgorithmImplementationsStatement();
return new ShowPluginsStatement("SHADOW_ALGORITHM");
}
}

This file was deleted.

0 comments on commit 1d727c6

Please sign in to comment.