From 4d732f489e2bfe8ab4d3aea5cadef6afcfbe77be Mon Sep 17 00:00:00 2001 From: duanzhengqiang Date: Mon, 4 Nov 2024 09:11:09 +0800 Subject: [PATCH] Remove EqualsAndHashCode in SubstitutableColumnNameToken and change related LinkedHashSet ti LinkedList --- .../predicate/EncryptPredicateColumnTokenGenerator.java | 4 ++-- .../generator/projection/EncryptProjectionTokenGenerator.java | 3 +-- .../generator/select/EncryptGroupByItemTokenGenerator.java | 3 +-- .../common/pojo/generic/SubstitutableColumnNameToken.java | 3 --- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/predicate/EncryptPredicateColumnTokenGenerator.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/predicate/EncryptPredicateColumnTokenGenerator.java index 5b7af3cfeb0be..9b2bd6706f1ff 100644 --- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/predicate/EncryptPredicateColumnTokenGenerator.java +++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/predicate/EncryptPredicateColumnTokenGenerator.java @@ -47,7 +47,7 @@ import java.util.Collection; import java.util.Collections; -import java.util.LinkedHashSet; +import java.util.LinkedList; import java.util.Map; import java.util.Optional; @@ -81,7 +81,7 @@ public Collection generateSQLTokens(final SQLStatementContext sqlState private Collection generateSQLTokens(final Collection columnSegments, final Map columnExpressionTableNames, final Collection whereSegments, final DatabaseType databaseType) { - Collection result = new LinkedHashSet<>(columnSegments.size(), 1F); + Collection result = new LinkedList<>(); for (ColumnSegment each : columnSegments) { String tableName = columnExpressionTableNames.getOrDefault(each.getExpression(), ""); Optional encryptTable = encryptRule.findEncryptTable(tableName); diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/projection/EncryptProjectionTokenGenerator.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/projection/EncryptProjectionTokenGenerator.java index bb001274e5e83..36f25e0d232ab 100644 --- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/projection/EncryptProjectionTokenGenerator.java +++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/projection/EncryptProjectionTokenGenerator.java @@ -43,7 +43,6 @@ import java.util.Collection; import java.util.Collections; -import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Optional; @@ -68,7 +67,7 @@ public final class EncryptProjectionTokenGenerator { * @return generated SQL tokens */ public Collection generateSQLTokens(final SelectStatementContext selectStatementContext) { - Collection result = new LinkedHashSet<>(generateSelectSQLTokens(selectStatementContext)); + Collection result = new LinkedList<>(generateSelectSQLTokens(selectStatementContext)); selectStatementContext.getSubqueryContexts().values().stream().map(this::generateSQLTokens).forEach(result::addAll); return result; } diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/select/EncryptGroupByItemTokenGenerator.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/select/EncryptGroupByItemTokenGenerator.java index 3316c7bdad57d..1c0ead5073316 100644 --- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/select/EncryptGroupByItemTokenGenerator.java +++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/select/EncryptGroupByItemTokenGenerator.java @@ -42,7 +42,6 @@ import java.util.Collection; import java.util.Collections; -import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.Map; import java.util.Optional; @@ -82,7 +81,7 @@ private boolean containsGroupByItem(final SelectStatementContext sqlStatementCon @Override public Collection generateSQLTokens(final SelectStatementContext sqlStatementContext) { - Collection result = new LinkedHashSet<>(); + Collection result = new LinkedList<>(); ShardingSphereSchema schema = sqlStatementContext.getTablesContext().getSchemaName().map(schemas::get).orElseGet(() -> defaultSchema); for (OrderByItem each : getGroupByItems(sqlStatementContext)) { if (each.getSegment() instanceof ColumnOrderByItemSegment) { diff --git a/infra/rewrite/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/pojo/generic/SubstitutableColumnNameToken.java b/infra/rewrite/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/pojo/generic/SubstitutableColumnNameToken.java index 659dc64f152c5..af2836cbeb75f 100644 --- a/infra/rewrite/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/pojo/generic/SubstitutableColumnNameToken.java +++ b/infra/rewrite/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/pojo/generic/SubstitutableColumnNameToken.java @@ -18,7 +18,6 @@ package org.apache.shardingsphere.infra.rewrite.sql.token.common.pojo.generic; import com.cedarsoftware.util.CaseInsensitiveMap; -import lombok.EqualsAndHashCode; import lombok.Getter; import org.apache.shardingsphere.infra.binder.context.segment.select.projection.Projection; import org.apache.shardingsphere.infra.binder.context.segment.select.projection.impl.ColumnProjection; @@ -39,8 +38,6 @@ /** * Substitutable column name token. */ -// TODO remove @EqualsAndHashCode in token rewriter -@EqualsAndHashCode(callSuper = false, exclude = "projections") public final class SubstitutableColumnNameToken extends SQLToken implements Substitutable, RouteUnitAware { private static final String COLUMN_NAME_SPLITTER = ", ";