Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move GenericSchemaBuilderMaterial.isSameProtocolAndStorageTypes() to GenericSchemaBuilder #33995

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.shardingsphere.infra.database.core.metadata.data.model.IndexMetaData;
import org.apache.shardingsphere.infra.database.core.metadata.data.model.SchemaMetaData;
import org.apache.shardingsphere.infra.database.core.metadata.data.model.TableMetaData;
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.database.core.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnit;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereColumn;
Expand Down Expand Up @@ -78,7 +79,7 @@ public static Map<String, ShardingSphereSchema> build(final GenericSchemaBuilder
*/
public static Map<String, ShardingSphereSchema> build(final Collection<String> tableNames, final GenericSchemaBuilderMaterial material) throws SQLException {
Map<String, SchemaMetaData> result = loadSchemas(tableNames, material);
if (!material.isSameProtocolAndStorageTypes()) {
if (!isSameProtocolAndStorageTypes(material.getProtocolType(), material.getStorageUnits())) {
result = translate(result, material);
}
return revise(result, material);
Expand All @@ -98,6 +99,10 @@ private static Map<String, SchemaMetaData> loadSchemas(final Collection<String>
return materials.isEmpty() ? Collections.emptyMap() : MetaDataLoader.load(materials);
}

private static boolean isSameProtocolAndStorageTypes(final DatabaseType protocolType, final Map<String, StorageUnit> storageUnits) {
return storageUnits.values().stream().map(StorageUnit::getStorageType).allMatch(protocolType::equals);
}

private static Map<String, SchemaMetaData> translate(final Map<String, SchemaMetaData> schemaMetaDataMap, final GenericSchemaBuilderMaterial material) {
Collection<TableMetaData> tableMetaDataList = new LinkedList<>();
for (StorageUnit each : material.getStorageUnits().values()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,4 @@ public final class GenericSchemaBuilderMaterial {
private final ConfigurationProperties props;

private final String defaultSchemaName;

/**
* Judge whether same protocol and storage database types.
*
* @return is same or not
*/
public boolean isSameProtocolAndStorageTypes() {
return storageUnits.values().stream().map(StorageUnit::getStorageType).allMatch(protocolType::equals);
}
}

This file was deleted.

Loading