This is an automated email from the ASF dual-hosted git repository.
zhaojinchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 0406b05cd72 Refactor ShardingSphereStatisticsCollector (#33884)
0406b05cd72 is described below
commit 0406b05cd72eb8f4a499696373f35d56bc954ffc
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Dec 2 19:30:00 2024 +0800
Refactor ShardingSphereStatisticsCollector (#33884)
* Refactor ShardingSphereStatisticsRefreshEngine
* Refactor ShardingSphereStatisticsCollector
* Refactor ShardingSphereStatisticsCollector
---
.../metadata/data/ShardingStatisticsTableCollector.java | 11 +++++------
.../metadata/data/ShardingStatisticsTableCollectorTest.java | 11 +++++++++--
.../type/MySQLShardingStatisticsTableCollectorTest.java | 7 ++++++-
.../type/OpenGaussShardingStatisticsTableCollectorTest.java | 11 +++++++++--
.../type/PostgreSQLShardingStatisticsTableCollectorTest.java | 7 ++++++-
.../collector/ShardingSphereStatisticsCollector.java | 11 ++++-------
.../statistics/collector/tables/PgClassTableCollector.java | 8 +++-----
.../collector/tables/PgNamespaceTableCollector.java | 8 +++-----
.../refresher/ShardingSphereStatisticsRefreshEngine.java | 2 +-
.../mode/fixture/StatisticsCollectorFixture.java | 7 ++-----
10 files changed, 48 insertions(+), 35 deletions(-)
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 b70c2280f3f..e0735b75a0c 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
@@ -22,9 +22,9 @@ import
org.apache.shardingsphere.infra.database.core.spi.DatabaseTypedSPILoader;
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.database.core.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.infra.datanode.DataNode;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnit;
-import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
import
org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereRowData;
import
org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereTableData;
@@ -49,15 +49,14 @@ public final class ShardingStatisticsTableCollector
implements ShardingSphereSta
private static final String SHARDING_TABLE_STATISTICS =
"sharding_table_statistics";
@Override
- public Optional<ShardingSphereTableData> collect(final String
databaseName, final ShardingSphereTable table,
- final Map<String,
ShardingSphereDatabase> databases, final RuleMetaData globalRuleMetaData)
throws SQLException {
+ public Optional<ShardingSphereTableData> collect(final String
databaseName, final ShardingSphereTable table, final ShardingSphereMetaData
metaData) throws SQLException {
ShardingSphereTableData result = new
ShardingSphereTableData(SHARDING_TABLE_STATISTICS);
- DatabaseType protocolType =
databases.values().iterator().next().getProtocolType();
+ DatabaseType protocolType =
metaData.getAllDatabases().iterator().next().getProtocolType();
DialectDatabaseMetaData dialectDatabaseMetaData = new
DatabaseTypeRegistry(protocolType).getDialectDatabaseMetaData();
if (dialectDatabaseMetaData.getDefaultSchema().isPresent()) {
- collectFromDatabase(databases.get(databaseName), result);
+ collectFromDatabase(metaData.getDatabase(databaseName), result);
} else {
- for (ShardingSphereDatabase each : databases.values()) {
+ for (ShardingSphereDatabase each : metaData.getAllDatabases()) {
collectFromDatabase(each, result);
}
}
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/data/ShardingStatisticsTableCollectorTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/data/ShardingStatisticsTableCollectorTest.java
index 9cbb9f3a030..16bb6c65e6f 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/data/ShardingStatisticsTableCollectorTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/data/ShardingStatisticsTableCollectorTest.java
@@ -17,7 +17,9 @@
package org.apache.shardingsphere.sharding.metadata.data;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData;
import
org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnit;
@@ -41,6 +43,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -65,7 +68,9 @@ class ShardingStatisticsTableCollectorTest {
void assertCollectWithoutShardingRule() throws SQLException {
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
when(database.getProtocolType()).thenReturn(databaseType);
- Optional<ShardingSphereTableData> actual =
statisticsCollector.collect("foo_db", mock(ShardingSphereTable.class),
Collections.singletonMap("foo_db", database), mock(RuleMetaData.class));
+ ShardingSphereMetaData metaData = new ShardingSphereMetaData(
+ Collections.singletonMap("foo_db", database),
mock(ResourceMetaData.class), mock(RuleMetaData.class), new
ConfigurationProperties(new Properties()));
+ Optional<ShardingSphereTableData> actual =
statisticsCollector.collect("foo_db", mock(ShardingSphereTable.class),
metaData);
assertFalse(actual.isPresent());
}
@@ -78,7 +83,9 @@ class ShardingStatisticsTableCollectorTest {
storageUnits.put("ds_1", mock(StorageUnit.class, RETURNS_DEEP_STUBS));
ShardingSphereDatabase database = new ShardingSphereDatabase(
"foo_db", databaseType, new
ResourceMetaData(Collections.emptyMap(), storageUnits), new
RuleMetaData(Collections.singleton(rule)), Collections.emptyList());
- Optional<ShardingSphereTableData> actual =
statisticsCollector.collect("foo_db", mock(ShardingSphereTable.class),
Collections.singletonMap("foo_db", database), mock(RuleMetaData.class));
+ ShardingSphereMetaData metaData = new ShardingSphereMetaData(
+ Collections.singletonMap("foo_db", database),
mock(ResourceMetaData.class), mock(RuleMetaData.class), new
ConfigurationProperties(new Properties()));
+ Optional<ShardingSphereTableData> actual =
statisticsCollector.collect("foo_db", mock(ShardingSphereTable.class),
metaData);
assertTrue(actual.isPresent());
assertThat(actual.get().getName(), is("sharding_table_statistics"));
List<ShardingSphereRowData> actualRows = new
ArrayList<>(actual.get().getRows());
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/data/dialect/type/MySQLShardingStatisticsTableCollectorTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/data/dialect/type/MySQLShardingStatisticsTableCollectorTest.java
index 2a1f38d49b6..37fe26eb1b5 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/data/dialect/type/MySQLShardingStatisticsTableCollectorTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/data/dialect/type/MySQLShardingStatisticsTableCollectorTest.java
@@ -17,7 +17,9 @@
package org.apache.shardingsphere.sharding.metadata.data.dialect.type;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData;
import
org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnit;
@@ -44,6 +46,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -72,7 +75,9 @@ class MySQLShardingStatisticsTableCollectorTest {
storageUnits.put("ds_1", mockStorageUnit(mockResultSet()));
ShardingSphereDatabase database = new ShardingSphereDatabase(
"foo_db", databaseType, new
ResourceMetaData(Collections.emptyMap(), storageUnits), new
RuleMetaData(Collections.singleton(rule)), Collections.emptyList());
- Optional<ShardingSphereTableData> actual =
statisticsCollector.collect("foo_db", mock(ShardingSphereTable.class),
Collections.singletonMap("foo_db", database), mock(RuleMetaData.class));
+ ShardingSphereMetaData metaData = new ShardingSphereMetaData(
+ Collections.singletonMap("foo_db", database),
mock(ResourceMetaData.class), mock(RuleMetaData.class), new
ConfigurationProperties(new Properties()));
+ Optional<ShardingSphereTableData> actual =
statisticsCollector.collect("foo_db", mock(ShardingSphereTable.class),
metaData);
assertTrue(actual.isPresent());
assertThat(actual.get().getName(), is("sharding_table_statistics"));
List<ShardingSphereRowData> actualRows = new
ArrayList<>(actual.get().getRows());
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/data/dialect/type/OpenGaussShardingStatisticsTableCollectorTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/data/dialect/type/OpenGaussShardingStatisticsTableCollectorTest.java
index 184cb025d21..c5fe41fa48d 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/data/dialect/type/OpenGaussShardingStatisticsTableCollectorTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/data/dialect/type/OpenGaussShardingStatisticsTableCollectorTest.java
@@ -17,7 +17,9 @@
package org.apache.shardingsphere.sharding.metadata.data.dialect.type;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData;
import
org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnit;
@@ -44,6 +46,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -73,7 +76,9 @@ class OpenGaussShardingStatisticsTableCollectorTest {
storageUnits.put("ds_1", mockStorageUnit(mockResultSet(), false));
ShardingSphereDatabase database = new ShardingSphereDatabase(
"foo_db", databaseType, new
ResourceMetaData(Collections.emptyMap(), storageUnits), new
RuleMetaData(Collections.singleton(rule)), Collections.emptyList());
- Optional<ShardingSphereTableData> actual =
statisticsCollector.collect("foo_db", mock(ShardingSphereTable.class),
Collections.singletonMap("foo_db", database), mock(RuleMetaData.class));
+ ShardingSphereMetaData metaData = new ShardingSphereMetaData(
+ Collections.singletonMap("foo_db", database),
mock(ResourceMetaData.class), mock(RuleMetaData.class), new
ConfigurationProperties(new Properties()));
+ Optional<ShardingSphereTableData> actual =
statisticsCollector.collect("foo_db", mock(ShardingSphereTable.class),
metaData);
assertTrue(actual.isPresent());
assertThat(actual.get().getName(), is("sharding_table_statistics"));
List<ShardingSphereRowData> actualRows = new
ArrayList<>(actual.get().getRows());
@@ -91,7 +96,9 @@ class OpenGaussShardingStatisticsTableCollectorTest {
storageUnits.put("ds_1", mockStorageUnit(mockResultSet(), true));
ShardingSphereDatabase database = new ShardingSphereDatabase(
"foo_db", databaseType, new
ResourceMetaData(Collections.emptyMap(), storageUnits), new
RuleMetaData(Collections.singleton(rule)), Collections.emptyList());
- Optional<ShardingSphereTableData> actual =
statisticsCollector.collect("foo_db", mock(ShardingSphereTable.class),
Collections.singletonMap("foo_db", database), mock(RuleMetaData.class));
+ ShardingSphereMetaData metaData = new ShardingSphereMetaData(
+ Collections.singletonMap("foo_db", database),
mock(ResourceMetaData.class), mock(RuleMetaData.class), new
ConfigurationProperties(new Properties()));
+ Optional<ShardingSphereTableData> actual =
statisticsCollector.collect("foo_db", mock(ShardingSphereTable.class),
metaData);
assertTrue(actual.isPresent());
assertThat(actual.get().getName(), is("sharding_table_statistics"));
List<ShardingSphereRowData> actualRows = new
ArrayList<>(actual.get().getRows());
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/data/dialect/type/PostgreSQLShardingStatisticsTableCollectorTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/data/dialect/type/PostgreSQLShardingStatisticsTableCollectorTest.java
index 1eca6b17634..2881ef0802b 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/data/dialect/type/PostgreSQLShardingStatisticsTableCollectorTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/metadata/data/dialect/type/PostgreSQLShardingStatisticsTableCollectorTest.java
@@ -17,7 +17,9 @@
package org.apache.shardingsphere.sharding.metadata.data.dialect.type;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData;
import
org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnit;
@@ -44,6 +46,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -72,7 +75,9 @@ class PostgreSQLShardingStatisticsTableCollectorTest {
storageUnits.put("ds_1", mockStorageUnit(mockResultSet()));
ShardingSphereDatabase database = new ShardingSphereDatabase(
"foo_db", databaseType, new
ResourceMetaData(Collections.emptyMap(), storageUnits), new
RuleMetaData(Collections.singleton(rule)), Collections.emptyList());
- Optional<ShardingSphereTableData> actual =
statisticsCollector.collect("foo_db", mock(ShardingSphereTable.class),
Collections.singletonMap("foo_db", database), mock(RuleMetaData.class));
+ ShardingSphereMetaData metaData = new ShardingSphereMetaData(
+ Collections.singletonMap("foo_db", database),
mock(ResourceMetaData.class), mock(RuleMetaData.class), new
ConfigurationProperties(new Properties()));
+ Optional<ShardingSphereTableData> actual =
statisticsCollector.collect("foo_db", mock(ShardingSphereTable.class),
metaData);
assertTrue(actual.isPresent());
assertThat(actual.get().getName(), is("sharding_table_statistics"));
List<ShardingSphereRowData> actualRows = new
ArrayList<>(actual.get().getRows());
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 c60fdd5ef62..e185216a1dc 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
@@ -17,15 +17,13 @@
package org.apache.shardingsphere.infra.metadata.statistics.collector;
-import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
-import
org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereTableData;
-import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
+import
org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereTableData;
import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
import java.sql.SQLException;
-import java.util.Map;
import java.util.Optional;
/**
@@ -39,10 +37,9 @@ public interface ShardingSphereStatisticsCollector extends
TypedSPI {
*
* @param databaseName database name
* @param table table
- * @param databases databases
- * @param globalRuleMetaData global rule meta data
+ * @param metaData ShardingSphere meta data
* @return ShardingSphere table data
* @throws SQLException SQL exception
*/
- Optional<ShardingSphereTableData> collect(String databaseName,
ShardingSphereTable table, Map<String, ShardingSphereDatabase> databases,
RuleMetaData globalRuleMetaData) throws SQLException;
+ Optional<ShardingSphereTableData> collect(String databaseName,
ShardingSphereTable table, ShardingSphereMetaData metaData) 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 2008dcd86d7..d5e33bf3aaa 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
@@ -18,8 +18,7 @@
package org.apache.shardingsphere.infra.metadata.statistics.collector.tables;
import com.cedarsoftware.util.CaseInsensitiveMap;
-import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
import
org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereRowData;
@@ -45,10 +44,9 @@ public final class PgClassTableCollector implements
ShardingSphereStatisticsColl
private static final Long PUBLIC_SCHEMA_OID = 0L;
@Override
- public Optional<ShardingSphereTableData> collect(final String
databaseName, final ShardingSphereTable table, final Map<String,
ShardingSphereDatabase> databases,
- final RuleMetaData
globalRuleMetaData) throws SQLException {
+ public Optional<ShardingSphereTableData> collect(final String
databaseName, final ShardingSphereTable table, final ShardingSphereMetaData
metaData) throws SQLException {
ShardingSphereTableData result = new ShardingSphereTableData(PG_CLASS);
- ShardingSphereSchema publicSchema =
databases.get(databaseName).getSchema(PUBLIC_SCHEMA);
+ ShardingSphereSchema publicSchema =
metaData.getDatabase(databaseName).getSchema(PUBLIC_SCHEMA);
if (null != publicSchema) {
result.getRows().addAll(collectForSchema(0L, PUBLIC_SCHEMA_OID,
publicSchema, table));
}
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 83d7eac9d91..fb00fd536a0 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
@@ -18,8 +18,7 @@
package org.apache.shardingsphere.infra.metadata.statistics.collector.tables;
import com.cedarsoftware.util.CaseInsensitiveMap;
-import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
import
org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereRowData;
@@ -44,11 +43,10 @@ public final class PgNamespaceTableCollector implements
ShardingSphereStatistics
private static final Long PUBLIC_SCHEMA_OID = 0L;
@Override
- public Optional<ShardingSphereTableData> collect(final String
databaseName, final ShardingSphereTable table, final Map<String,
ShardingSphereDatabase> databases,
- final RuleMetaData
globalRuleMetaData) throws SQLException {
+ public Optional<ShardingSphereTableData> collect(final String
databaseName, final ShardingSphereTable table, final ShardingSphereMetaData
metaData) throws SQLException {
ShardingSphereTableData result = new
ShardingSphereTableData(PG_NAMESPACE);
long oid = 1L;
- for (ShardingSphereSchema each :
databases.get(databaseName).getAllSchemas()) {
+ for (ShardingSphereSchema each :
metaData.getDatabase(databaseName).getAllSchemas()) {
result.getRows().add(new
ShardingSphereRowData(getRow(PUBLIC_SCHEMA.equalsIgnoreCase(each.getName()) ?
PUBLIC_SCHEMA_OID : oid++, each.getName(), table)));
}
return Optional.of(result);
diff --git
a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/ShardingSphereStatisticsRefreshEngine.java
b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/ShardingSphereStatisticsRefreshEngine.java
index 7482b8b90d1..df64f20982d 100644
---
a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/ShardingSphereStatisticsRefreshEngine.java
+++
b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/ShardingSphereStatisticsRefreshEngine.java
@@ -125,7 +125,7 @@ public final class ShardingSphereStatisticsRefreshEngine {
Optional<ShardingSphereTableData> tableData = Optional.empty();
if (statisticsCollector.isPresent()) {
try {
- tableData = statisticsCollector.get().collect(databaseName,
table, metaData.getDatabases(), metaData.getGlobalRuleMetaData());
+ tableData = statisticsCollector.get().collect(databaseName,
table, metaData);
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
diff --git
a/mode/core/src/test/java/org/apache/shardingsphere/mode/fixture/StatisticsCollectorFixture.java
b/mode/core/src/test/java/org/apache/shardingsphere/mode/fixture/StatisticsCollectorFixture.java
index 83257c6a5dc..a4835a895e4 100644
---
a/mode/core/src/test/java/org/apache/shardingsphere/mode/fixture/StatisticsCollectorFixture.java
+++
b/mode/core/src/test/java/org/apache/shardingsphere/mode/fixture/StatisticsCollectorFixture.java
@@ -17,8 +17,7 @@
package org.apache.shardingsphere.mode.fixture;
-import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
import
org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereRowData;
import
org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereTableData;
@@ -26,7 +25,6 @@ import
org.apache.shardingsphere.infra.metadata.statistics.collector.ShardingSph
import java.sql.SQLException;
import java.util.Arrays;
-import java.util.Map;
import java.util.Optional;
/**
@@ -35,8 +33,7 @@ import java.util.Optional;
public final class StatisticsCollectorFixture implements
ShardingSphereStatisticsCollector {
@Override
- public Optional<ShardingSphereTableData> collect(final String
databaseName, final ShardingSphereTable table, final Map<String,
ShardingSphereDatabase> databases,
- final RuleMetaData
globalRuleMetaData) throws SQLException {
+ public Optional<ShardingSphereTableData> collect(final String
databaseName, final ShardingSphereTable table, final ShardingSphereMetaData
metaData) throws SQLException {
ShardingSphereTableData shardingSphereTableData = new
ShardingSphereTableData("test_table");
shardingSphereTableData.getRows().add(new
ShardingSphereRowData(Arrays.asList("1", "2")));
return Optional.of(shardingSphereTableData);