Skip to content

Commit

Permalink
Rename ShardingSphereIdentifier (#33947)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored Dec 6, 2024
1 parent 7eb662e commit eab8cd6
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
import org.apache.shardingsphere.infra.metadata.identifier.ShardingSphereMetaDataIdentifier;
import org.apache.shardingsphere.infra.metadata.identifier.ShardingSphereIdentifier;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.rule.attribute.datasource.StaticDataSourceRuleAttribute;
import org.apache.shardingsphere.infra.rule.scope.GlobalRule;
Expand All @@ -48,7 +48,7 @@
public final class ShardingSphereMetaData {

@Getter(AccessLevel.NONE)
private final Map<ShardingSphereMetaDataIdentifier, ShardingSphereDatabase> databases;
private final Map<ShardingSphereIdentifier, ShardingSphereDatabase> databases;

private final ResourceMetaData globalResourceMetaData;

Expand All @@ -64,7 +64,7 @@ public ShardingSphereMetaData() {

public ShardingSphereMetaData(final Collection<ShardingSphereDatabase> databases, final ResourceMetaData globalResourceMetaData,
final RuleMetaData globalRuleMetaData, final ConfigurationProperties props) {
this.databases = new ConcurrentHashMap<>(databases.stream().collect(Collectors.toMap(each -> new ShardingSphereMetaDataIdentifier(each.getName()), each -> each)));
this.databases = new ConcurrentHashMap<>(databases.stream().collect(Collectors.toMap(each -> new ShardingSphereIdentifier(each.getName()), each -> each)));
this.globalResourceMetaData = globalResourceMetaData;
this.globalRuleMetaData = globalRuleMetaData;
this.props = props;
Expand All @@ -87,7 +87,7 @@ public Collection<ShardingSphereDatabase> getAllDatabases() {
* @return contains database from meta data or not
*/
public boolean containsDatabase(final String databaseName) {
return databases.containsKey(new ShardingSphereMetaDataIdentifier(databaseName));
return databases.containsKey(new ShardingSphereIdentifier(databaseName));
}

/**
Expand All @@ -97,7 +97,7 @@ public boolean containsDatabase(final String databaseName) {
* @return meta data database
*/
public ShardingSphereDatabase getDatabase(final String databaseName) {
return databases.get(new ShardingSphereMetaDataIdentifier(databaseName));
return databases.get(new ShardingSphereIdentifier(databaseName));
}

/**
Expand All @@ -109,7 +109,7 @@ public ShardingSphereDatabase getDatabase(final String databaseName) {
*/
public void addDatabase(final String databaseName, final DatabaseType protocolType, final ConfigurationProperties props) {
ShardingSphereDatabase database = ShardingSphereDatabase.create(databaseName, protocolType, props);
databases.put(new ShardingSphereMetaDataIdentifier(database.getName()), database);
databases.put(new ShardingSphereIdentifier(database.getName()), database);
globalRuleMetaData.getRules().forEach(each -> ((GlobalRule) each).refresh(databases.values(), GlobalRuleChangedType.DATABASE_CHANGED));
}

Expand All @@ -119,7 +119,7 @@ public void addDatabase(final String databaseName, final DatabaseType protocolTy
* @param database database
*/
public void putDatabase(final ShardingSphereDatabase database) {
databases.put(new ShardingSphereMetaDataIdentifier(database.getName()), database);
databases.put(new ShardingSphereIdentifier(database.getName()), database);
}

/**
Expand All @@ -128,7 +128,7 @@ public void putDatabase(final ShardingSphereDatabase database) {
* @param databaseName database name
*/
public void dropDatabase(final String databaseName) {
cleanResources(databases.remove(new ShardingSphereMetaDataIdentifier(databaseName)));
cleanResources(databases.remove(new ShardingSphereIdentifier(databaseName)));
}

@SneakyThrows(Exception.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.apache.shardingsphere.infra.metadata.database.schema.builder.GenericSchemaBuilderMaterial;
import org.apache.shardingsphere.infra.metadata.database.schema.builder.SystemSchemaBuilder;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import org.apache.shardingsphere.infra.metadata.identifier.ShardingSphereMetaDataIdentifier;
import org.apache.shardingsphere.infra.metadata.identifier.ShardingSphereIdentifier;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.rule.attribute.datanode.MutableDataNodeRuleAttribute;
import org.apache.shardingsphere.infra.rule.builder.database.DatabaseRulesBuilder;
Expand Down Expand Up @@ -62,15 +62,15 @@ public final class ShardingSphereDatabase {
private final RuleMetaData ruleMetaData;

@Getter(AccessLevel.NONE)
private final Map<ShardingSphereMetaDataIdentifier, ShardingSphereSchema> schemas;
private final Map<ShardingSphereIdentifier, ShardingSphereSchema> schemas;

public ShardingSphereDatabase(final String name, final DatabaseType protocolType, final ResourceMetaData resourceMetaData,
final RuleMetaData ruleMetaData, final Collection<ShardingSphereSchema> schemas) {
this.name = name;
this.protocolType = protocolType;
this.resourceMetaData = resourceMetaData;
this.ruleMetaData = ruleMetaData;
this.schemas = new ConcurrentHashMap<>(schemas.stream().collect(Collectors.toMap(each -> new ShardingSphereMetaDataIdentifier(each.getName()), each -> each)));
this.schemas = new ConcurrentHashMap<>(schemas.stream().collect(Collectors.toMap(each -> new ShardingSphereIdentifier(each.getName()), each -> each)));
}

/**
Expand Down Expand Up @@ -142,7 +142,7 @@ public Collection<ShardingSphereSchema> getAllSchemas() {
* @return contains schema from database or not
*/
public boolean containsSchema(final String schemaName) {
return schemas.containsKey(new ShardingSphereMetaDataIdentifier(schemaName));
return schemas.containsKey(new ShardingSphereIdentifier(schemaName));
}

/**
Expand All @@ -152,7 +152,7 @@ public boolean containsSchema(final String schemaName) {
* @return schema
*/
public ShardingSphereSchema getSchema(final String schemaName) {
return schemas.get(new ShardingSphereMetaDataIdentifier(schemaName));
return schemas.get(new ShardingSphereIdentifier(schemaName));
}

/**
Expand All @@ -161,7 +161,7 @@ public ShardingSphereSchema getSchema(final String schemaName) {
* @param schema schema
*/
public void addSchema(final ShardingSphereSchema schema) {
schemas.put(new ShardingSphereMetaDataIdentifier(schema.getName()), schema);
schemas.put(new ShardingSphereIdentifier(schema.getName()), schema);
}

/**
Expand All @@ -170,7 +170,7 @@ public void addSchema(final ShardingSphereSchema schema) {
* @param schemaName schema name
*/
public void dropSchema(final String schemaName) {
schemas.remove(new ShardingSphereMetaDataIdentifier(schemaName));
schemas.remove(new ShardingSphereIdentifier(schemaName));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.apache.shardingsphere.infra.metadata.database.schema.model;

import lombok.Getter;
import org.apache.shardingsphere.infra.metadata.identifier.ShardingSphereMetaDataIdentifier;
import org.apache.shardingsphere.infra.metadata.identifier.ShardingSphereIdentifier;

import java.util.Collection;
import java.util.Collections;
Expand All @@ -34,9 +34,9 @@ public final class ShardingSphereSchema {
@Getter
private final String name;

private final Map<ShardingSphereMetaDataIdentifier, ShardingSphereTable> tables;
private final Map<ShardingSphereIdentifier, ShardingSphereTable> tables;

private final Map<ShardingSphereMetaDataIdentifier, ShardingSphereView> views;
private final Map<ShardingSphereIdentifier, ShardingSphereView> views;

@SuppressWarnings("CollectionWithoutInitialCapacity")
public ShardingSphereSchema(final String name) {
Expand All @@ -49,8 +49,8 @@ public ShardingSphereSchema(final String name, final Collection<ShardingSphereTa
this.name = name;
this.tables = new ConcurrentHashMap<>(tables.size(), 1F);
this.views = new ConcurrentHashMap<>(views.size(), 1F);
tables.forEach(each -> this.tables.put(new ShardingSphereMetaDataIdentifier(each.getName()), each));
views.forEach(each -> this.views.put(new ShardingSphereMetaDataIdentifier(each.getName()), each));
tables.forEach(each -> this.tables.put(new ShardingSphereIdentifier(each.getName()), each));
views.forEach(each -> this.views.put(new ShardingSphereIdentifier(each.getName()), each));
}

/**
Expand All @@ -69,7 +69,7 @@ public Collection<ShardingSphereTable> getAllTables() {
* @return contains table or not
*/
public boolean containsTable(final String tableName) {
return tables.containsKey(new ShardingSphereMetaDataIdentifier(tableName));
return tables.containsKey(new ShardingSphereIdentifier(tableName));
}

/**
Expand All @@ -79,7 +79,7 @@ public boolean containsTable(final String tableName) {
* @return table
*/
public ShardingSphereTable getTable(final String tableName) {
return tables.get(new ShardingSphereMetaDataIdentifier(tableName));
return tables.get(new ShardingSphereIdentifier(tableName));
}

/**
Expand All @@ -88,7 +88,7 @@ public ShardingSphereTable getTable(final String tableName) {
* @param table table
*/
public void putTable(final ShardingSphereTable table) {
tables.put(new ShardingSphereMetaDataIdentifier(table.getName()), table);
tables.put(new ShardingSphereIdentifier(table.getName()), table);
}

/**
Expand All @@ -97,7 +97,7 @@ public void putTable(final ShardingSphereTable table) {
* @param tableName table name
*/
public void removeTable(final String tableName) {
tables.remove(new ShardingSphereMetaDataIdentifier(tableName));
tables.remove(new ShardingSphereIdentifier(tableName));
}

/**
Expand All @@ -116,7 +116,7 @@ public Collection<ShardingSphereView> getAllViews() {
* @return contains view or not
*/
public boolean containsView(final String viewName) {
return views.containsKey(new ShardingSphereMetaDataIdentifier(viewName));
return views.containsKey(new ShardingSphereIdentifier(viewName));
}

/**
Expand All @@ -126,7 +126,7 @@ public boolean containsView(final String viewName) {
* @return view
*/
public ShardingSphereView getView(final String viewName) {
return views.get(new ShardingSphereMetaDataIdentifier(viewName));
return views.get(new ShardingSphereIdentifier(viewName));
}

/**
Expand All @@ -135,7 +135,7 @@ public ShardingSphereView getView(final String viewName) {
* @param view view
*/
public void putView(final ShardingSphereView view) {
views.put(new ShardingSphereMetaDataIdentifier(view.getName()), view);
views.put(new ShardingSphereIdentifier(view.getName()), view);
}

/**
Expand All @@ -144,7 +144,7 @@ public void putView(final ShardingSphereView view) {
* @param viewName view name
*/
public void removeView(final String viewName) {
views.remove(new ShardingSphereMetaDataIdentifier(viewName));
views.remove(new ShardingSphereIdentifier(viewName));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import lombok.Getter;
import lombok.ToString;
import org.apache.shardingsphere.infra.database.core.metadata.database.enums.TableType;
import org.apache.shardingsphere.infra.metadata.identifier.ShardingSphereMetaDataIdentifier;
import org.apache.shardingsphere.infra.metadata.identifier.ShardingSphereIdentifier;

import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -43,7 +43,7 @@ public final class ShardingSphereTable {
private final String name;

@Getter(AccessLevel.NONE)
private final Map<ShardingSphereMetaDataIdentifier, ShardingSphereColumn> columns;
private final Map<ShardingSphereIdentifier, ShardingSphereColumn> columns;

private final List<String> columnNames = new ArrayList<>();

Expand All @@ -54,10 +54,10 @@ public final class ShardingSphereTable {
private final Map<String, Integer> visibleColumnAndIndexMap = new CaseInsensitiveMap<>();

@Getter(AccessLevel.NONE)
private final Map<ShardingSphereMetaDataIdentifier, ShardingSphereIndex> indexes;
private final Map<ShardingSphereIdentifier, ShardingSphereIndex> indexes;

@Getter(AccessLevel.NONE)
private final Map<ShardingSphereMetaDataIdentifier, ShardingSphereConstraint> constraints;
private final Map<ShardingSphereIdentifier, ShardingSphereConstraint> constraints;

private final TableType type;

Expand All @@ -75,11 +75,11 @@ public ShardingSphereTable(final String name, final Collection<ShardingSphereCol
this.type = type;
}

private Map<ShardingSphereMetaDataIdentifier, ShardingSphereColumn> createColumns(final Collection<ShardingSphereColumn> columns) {
Map<ShardingSphereMetaDataIdentifier, ShardingSphereColumn> result = new LinkedHashMap<>(columns.size(), 1F);
private Map<ShardingSphereIdentifier, ShardingSphereColumn> createColumns(final Collection<ShardingSphereColumn> columns) {
Map<ShardingSphereIdentifier, ShardingSphereColumn> result = new LinkedHashMap<>(columns.size(), 1F);
int index = 0;
for (ShardingSphereColumn each : columns) {
result.put(new ShardingSphereMetaDataIdentifier(each.getName()), each);
result.put(new ShardingSphereIdentifier(each.getName()), each);
columnNames.add(each.getName());
if (each.isPrimaryKey()) {
primaryKeyColumns.add(each.getName());
Expand All @@ -92,13 +92,13 @@ private Map<ShardingSphereMetaDataIdentifier, ShardingSphereColumn> createColumn
return result;
}

private Map<ShardingSphereMetaDataIdentifier, ShardingSphereIndex> createIndexes(final Collection<ShardingSphereIndex> indexes) {
return indexes.stream().collect(Collectors.toMap(each -> new ShardingSphereMetaDataIdentifier(each.getName()), each -> each, (a, b) -> b, () -> new LinkedHashMap<>(indexes.size(), 1F)));
private Map<ShardingSphereIdentifier, ShardingSphereIndex> createIndexes(final Collection<ShardingSphereIndex> indexes) {
return indexes.stream().collect(Collectors.toMap(each -> new ShardingSphereIdentifier(each.getName()), each -> each, (a, b) -> b, () -> new LinkedHashMap<>(indexes.size(), 1F)));
}

private Map<ShardingSphereMetaDataIdentifier, ShardingSphereConstraint> createConstraints(final Collection<ShardingSphereConstraint> constraints) {
private Map<ShardingSphereIdentifier, ShardingSphereConstraint> createConstraints(final Collection<ShardingSphereConstraint> constraints) {
return constraints.stream()
.collect(Collectors.toMap(each -> new ShardingSphereMetaDataIdentifier(each.getName()), each -> each, (a, b) -> b, () -> new LinkedHashMap<>(constraints.size(), 1F)));
.collect(Collectors.toMap(each -> new ShardingSphereIdentifier(each.getName()), each -> each, (a, b) -> b, () -> new LinkedHashMap<>(constraints.size(), 1F)));
}

/**
Expand All @@ -108,7 +108,7 @@ private Map<ShardingSphereMetaDataIdentifier, ShardingSphereConstraint> createCo
* @return contains column or not
*/
public boolean containsColumn(final String columnName) {
return null != columnName && columns.containsKey(new ShardingSphereMetaDataIdentifier(columnName));
return null != columnName && columns.containsKey(new ShardingSphereIdentifier(columnName));
}

/**
Expand All @@ -118,7 +118,7 @@ public boolean containsColumn(final String columnName) {
* @return column
*/
public ShardingSphereColumn getColumn(final String columnName) {
return columns.get(new ShardingSphereMetaDataIdentifier(columnName));
return columns.get(new ShardingSphereIdentifier(columnName));
}

/**
Expand All @@ -137,7 +137,7 @@ public Collection<ShardingSphereColumn> getAllColumns() {
* @return contains index or not
*/
public boolean containsIndex(final String indexName) {
return null != indexName && indexes.containsKey(new ShardingSphereMetaDataIdentifier(indexName));
return null != indexName && indexes.containsKey(new ShardingSphereIdentifier(indexName));
}

/**
Expand All @@ -155,7 +155,7 @@ public Collection<ShardingSphereIndex> getAllIndexes() {
* @param index index
*/
public void putIndex(final ShardingSphereIndex index) {
indexes.put(new ShardingSphereMetaDataIdentifier(index.getName()), index);
indexes.put(new ShardingSphereIdentifier(index.getName()), index);
}

/**
Expand All @@ -164,7 +164,7 @@ public void putIndex(final ShardingSphereIndex index) {
* @param indexName index name
*/
public void removeIndex(final String indexName) {
indexes.remove(new ShardingSphereMetaDataIdentifier(indexName));
indexes.remove(new ShardingSphereIdentifier(indexName));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;

/**
* Database dialect meta data identifier handler.
* Database dialect identifier handler.
*/
@SingletonSPI
public interface DatabaseDialectMetaDataIdentifierHandler extends DatabaseTypedSPI {
public interface DatabaseDialectIdentifierHandler extends DatabaseTypedSPI {

/**
* Whether identifier is case-sensitive.
Expand Down
Loading

0 comments on commit eab8cd6

Please sign in to comment.