diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/metadata/data/ShardingStatisticsTableCollector.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/metadata/data/ShardingStatisticsTableCollector.java index f10a97b238c53..802f0129b2080 100644 --- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/metadata/data/ShardingStatisticsTableCollector.java +++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/metadata/data/ShardingStatisticsTableCollector.java @@ -48,15 +48,14 @@ public final class ShardingStatisticsTableCollector implements ShardingSphereSta private static final String SHARDING_TABLE_STATISTICS = "sharding_table_statistics"; @Override - public Optional collect(final String databaseName, final ShardingSphereTable table, - final Map shardingSphereDatabases) throws SQLException { + public Optional collect(final String databaseName, final ShardingSphereTable table, final Map databases) throws SQLException { ShardingSphereTableData result = new ShardingSphereTableData(SHARDING_TABLE_STATISTICS); - DatabaseType protocolType = shardingSphereDatabases.values().iterator().next().getProtocolType(); + DatabaseType protocolType = databases.values().iterator().next().getProtocolType(); DialectDatabaseMetaData dialectDatabaseMetaData = new DatabaseTypeRegistry(protocolType).getDialectDatabaseMetaData(); if (dialectDatabaseMetaData.getDefaultSchema().isPresent()) { - collectFromDatabase(shardingSphereDatabases.get(databaseName), result); + collectFromDatabase(databases.get(databaseName), result); } else { - for (ShardingSphereDatabase each : shardingSphereDatabases.values()) { + for (ShardingSphereDatabase each : databases.values()) { collectFromDatabase(each, result); } } diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/statistics/collector/ShardingSphereStatisticsCollector.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/statistics/collector/ShardingSphereStatisticsCollector.java index e88484490c9dd..2e4a1f9dda9d7 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/statistics/collector/ShardingSphereStatisticsCollector.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/statistics/collector/ShardingSphereStatisticsCollector.java @@ -38,9 +38,9 @@ public interface ShardingSphereStatisticsCollector extends TypedSPI { * * @param databaseName database name * @param table table - * @param shardingSphereDatabases ShardingSphere databases + * @param databases databases * @return ShardingSphere table data - * @throws SQLException sql exception + * @throws SQLException SQL exception */ - Optional collect(String databaseName, ShardingSphereTable table, Map shardingSphereDatabases) throws SQLException; + Optional collect(String databaseName, ShardingSphereTable table, Map databases) throws SQLException; } diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/statistics/collector/tables/PgClassTableCollector.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/statistics/collector/tables/PgClassTableCollector.java index b72ff4290b5bb..5aa7efeedfce8 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/statistics/collector/tables/PgClassTableCollector.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/statistics/collector/tables/PgClassTableCollector.java @@ -49,11 +49,10 @@ public final class PgClassTableCollector implements ShardingSphereStatisticsColl + "AND relname NOT LIKE 'matviewmap\\_%' AND relname NOT LIKE 'mlog\\_%' AND pg_catalog.pg_table_is_visible(oid);"; @Override - public Optional collect(final String databaseName, final ShardingSphereTable table, - final Map shardingSphereDatabases) throws SQLException { - Collection rows = ShardingSphereTableDataCollectorUtils.collectRowData(shardingSphereDatabases.get(databaseName), + public Optional collect(final String databaseName, final ShardingSphereTable table, final Map databases) throws SQLException { + Collection rows = ShardingSphereTableDataCollectorUtils.collectRowData(databases.get(databaseName), table, Arrays.stream(COLUMN_NAMES.split(",")).map(String::trim).collect(Collectors.toList()), SELECT_SQL); - Collection rowData = decorateTableName(rows, table, shardingSphereDatabases.get(databaseName).getRuleMetaData().getRules()); + Collection rowData = decorateTableName(rows, table, databases.get(databaseName).getRuleMetaData().getRules()); ShardingSphereTableData result = new ShardingSphereTableData(PG_CLASS); result.getRows().addAll(rowData); return Optional.of(result); diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/statistics/collector/tables/PgNamespaceTableCollector.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/statistics/collector/tables/PgNamespaceTableCollector.java index bdea1de566bf7..ae28d64811a44 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/statistics/collector/tables/PgNamespaceTableCollector.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/statistics/collector/tables/PgNamespaceTableCollector.java @@ -43,9 +43,8 @@ public final class PgNamespaceTableCollector implements ShardingSphereStatistics private static final String SELECT_SQL = "SELECT " + COLUMN_NAMES + " FROM pg_catalog.pg_namespace"; @Override - public Optional collect(final String databaseName, final ShardingSphereTable table, - final Map shardingSphereDatabases) throws SQLException { - Collection rows = ShardingSphereTableDataCollectorUtils.collectRowData(shardingSphereDatabases.get(databaseName), + public Optional collect(final String databaseName, final ShardingSphereTable table, final Map databases) throws SQLException { + Collection rows = ShardingSphereTableDataCollectorUtils.collectRowData(databases.get(databaseName), table, Arrays.stream(COLUMN_NAMES.split(",")).map(String::trim).collect(Collectors.toList()), SELECT_SQL); ShardingSphereTableData result = new ShardingSphereTableData(PG_NAMESPACE); result.getRows().addAll(rows); diff --git a/kernel/schedule/core/src/test/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectorFixture.java b/kernel/schedule/core/src/test/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectorFixture.java index e2a8df705ffc0..c9292d19ccc91 100644 --- a/kernel/schedule/core/src/test/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectorFixture.java +++ b/kernel/schedule/core/src/test/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectorFixture.java @@ -34,8 +34,7 @@ public final class StatisticsCollectorFixture implements ShardingSphereStatisticsCollector { @Override - public Optional collect(final String databaseName, final ShardingSphereTable table, - final Map shardingSphereDatabases) throws SQLException { + public Optional collect(final String databaseName, final ShardingSphereTable table, final Map databases) throws SQLException { ShardingSphereTableData shardingSphereTableData = new ShardingSphereTableData("test_table"); shardingSphereTableData.getRows().add(new ShardingSphereRowData(Arrays.asList("1", "2"))); return Optional.of(shardingSphereTableData);