From 8e959eb1d028639f19fec3f51b0c92cbe770c95f Mon Sep 17 00:00:00 2001 From: terrymanu Date: Sat, 25 May 2024 18:19:34 +0800 Subject: [PATCH] Remove useless codes --- .../infra/rewrite/sql/token/pojo/Attachable.java | 7 ------- .../statement/doris/segment/ACLAttributeEnum.java | 2 +- .../statement/mysql/segment/ACLAttributeEnum.java | 2 +- .../executor/AbstractDatabaseMetaDataExecutor.java | 14 ++++---------- 4 files changed, 6 insertions(+), 19 deletions(-) diff --git a/infra/rewrite/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/pojo/Attachable.java b/infra/rewrite/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/pojo/Attachable.java index d3b2ff424cea4..d1882492f9e92 100644 --- a/infra/rewrite/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/pojo/Attachable.java +++ b/infra/rewrite/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/pojo/Attachable.java @@ -21,11 +21,4 @@ * Attach available. */ public interface Attachable { - - /** - * Get start index. - * - * @return start index - */ - int getStartIndex(); } diff --git a/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/doris/segment/ACLAttributeEnum.java b/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/doris/segment/ACLAttributeEnum.java index cbf7237eb41b5..5d6ce4623b61e 100644 --- a/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/doris/segment/ACLAttributeEnum.java +++ b/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/doris/segment/ACLAttributeEnum.java @@ -19,5 +19,5 @@ public enum ACLAttributeEnum { - UNCHANGED, DEFAULT, YES, NO + DEFAULT, YES, NO } diff --git a/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/segment/ACLAttributeEnum.java b/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/segment/ACLAttributeEnum.java index 6540a7bc8bd60..73ef9a897bd14 100644 --- a/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/segment/ACLAttributeEnum.java +++ b/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/mysql/segment/ACLAttributeEnum.java @@ -19,5 +19,5 @@ public enum ACLAttributeEnum { - UNCHANGED, DEFAULT, YES, NO + DEFAULT, YES, NO } diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/executor/AbstractDatabaseMetaDataExecutor.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/executor/AbstractDatabaseMetaDataExecutor.java index b1884b4f2b4d5..6cc9f9b34e49e 100644 --- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/executor/AbstractDatabaseMetaDataExecutor.java +++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/admin/executor/AbstractDatabaseMetaDataExecutor.java @@ -70,7 +70,6 @@ public abstract class AbstractDatabaseMetaDataExecutor implements DatabaseAdminQ public final void execute(final ConnectionSession connectionSession) throws SQLException { Collection databaseNames = getDatabaseNames(connectionSession); for (String databaseName : databaseNames) { - initDatabaseData(databaseName); processMetaData(databaseName, resultSet -> handleResultSet(databaseName, resultSet)); } postProcess(); @@ -82,9 +81,10 @@ public final void execute(final ConnectionSession connectionSession) throws SQLE private void handleResultSet(final String databaseName, final ResultSet resultSet) { ResultSetMetaData metaData = resultSet.getMetaData(); while (resultSet.next()) { - Map rowMap = new LinkedHashMap<>(); - Map aliasMap = new LinkedHashMap<>(); - for (int i = 1; i < metaData.getColumnCount() + 1; i++) { + int columnCount = metaData.getColumnCount(); + Map rowMap = new LinkedHashMap<>(columnCount, 1F); + Map aliasMap = new LinkedHashMap<>(columnCount, 1F); + for (int i = 1; i < columnCount + 1; i++) { aliasMap.put(metaData.getColumnName(i), metaData.getColumnLabel(i)); rowMap.put(metaData.getColumnLabel(i), resultSet.getString(i)); } @@ -100,8 +100,6 @@ private void handleResultSet(final String databaseName, final ResultSet resultSe } } - protected abstract void initDatabaseData(String databaseName); - protected abstract Collection getDatabaseNames(ConnectionSession connectionSession); protected abstract void preProcess(String databaseName, Map rows, Map alias); @@ -144,10 +142,6 @@ public static class DefaultDatabaseMetaDataExecutor extends AbstractDatabaseMeta private final List parameters; - @Override - protected void initDatabaseData(final String databaseName) { - } - @Override protected Collection getDatabaseNames(final ConnectionSession connectionSession) { Optional database = ProxyContext.getInstance().getAllDatabaseNames().stream().filter(each -> isAuthorized(each, connectionSession.getGrantee()))