Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made some optimizations for the isColumnNameNotConflicts method #28465

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnItemRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
import org.apache.shardingsphere.encrypt.distsql.handler.converter.EncryptRuleStatementConverter;
import org.apache.shardingsphere.encrypt.distsql.parser.segment.EncryptColumnSegment;
import org.apache.shardingsphere.encrypt.distsql.parser.segment.EncryptRuleSegment;
import org.apache.shardingsphere.encrypt.distsql.parser.statement.AlterEncryptRuleStatement;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
Expand Down Expand Up @@ -78,15 +77,8 @@ private void checkColumnNames(final AlterEncryptRuleStatement sqlStatement) {
}

private boolean isColumnNameNotConflicts(final EncryptRuleSegment rule) {
for (EncryptColumnSegment each : rule.getColumns()) {
if (null != each.getLikeQuery() && each.getName().equals(each.getLikeQuery().getName())) {
return false;
}
if (null != each.getAssistedQuery() && each.getName().equals(each.getAssistedQuery().getName())) {
return false;
}
}
return true;
return rule.getColumns().stream().noneMatch(each -> null != each.getLikeQuery() && each.getName().equals(each.getLikeQuery().getName())
|| null != each.getAssistedQuery() && each.getName().equals(each.getAssistedQuery().getName()));
}

private void checkToBeAlteredEncryptors(final AlterEncryptRuleStatement sqlStatement) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.distsql.handler.converter.EncryptRuleStatementConverter;
import org.apache.shardingsphere.encrypt.distsql.parser.segment.EncryptColumnItemSegment;
import org.apache.shardingsphere.encrypt.distsql.parser.segment.EncryptColumnSegment;
import org.apache.shardingsphere.encrypt.distsql.parser.segment.EncryptRuleSegment;
import org.apache.shardingsphere.encrypt.distsql.parser.statement.CreateEncryptRuleStatement;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
Expand Down Expand Up @@ -96,15 +95,8 @@ private void checkColumnNames(final CreateEncryptRuleStatement sqlStatement) {
}

private boolean isColumnNameNotConflicts(final EncryptRuleSegment rule) {
for (EncryptColumnSegment each : rule.getColumns()) {
if (null != each.getLikeQuery() && each.getName().equals(each.getLikeQuery().getName())) {
return false;
}
if (null != each.getAssistedQuery() && each.getName().equals(each.getAssistedQuery().getName())) {
return false;
}
}
return true;
return rule.getColumns().stream().noneMatch(each -> null != each.getLikeQuery() && each.getName().equals(each.getLikeQuery().getName())
|| null != each.getAssistedQuery() && each.getName().equals(each.getAssistedQuery().getName()));
}

private void checkToBeCreatedEncryptors(final CreateEncryptRuleStatement sqlStatement) {
Expand Down