Skip to content

Commit

Permalink
* Made some optimizations for the isColumnNameNotConflicts method (#2…
Browse files Browse the repository at this point in the history
  • Loading branch information
daleyzou authored Sep 19, 2023
1 parent bbc2b19 commit c13d957
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 c13d957

Please sign in to comment.