Skip to content

Commit

Permalink
* Made some optimizations for the isColumnNameNotConflicts method
Browse files Browse the repository at this point in the history
  • Loading branch information
daleyzou committed Sep 19, 2023
1 parent adedf9a commit f992dde
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
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

0 comments on commit f992dde

Please sign in to comment.