This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 9821c788f5d Refactor ShardingSphereSchema (#33807)
9821c788f5d is described below
commit 9821c788f5dbe204e19007871eb9a56ba13c59b5
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Nov 26 00:24:08 2024 +0800
Refactor ShardingSphereSchema (#33807)
* Refactor ShardingSphereSchema
* Refactor ShardingSphereSchema
---
.../schema/model/ShardingSphereSchema.java | 43 +++++++++++-----------
.../pipeline/core/util/PipelineContextUtils.java | 2 +-
2 files changed, 23 insertions(+), 22 deletions(-)
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereSchema.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereSchema.java
index fc8c93f9d2e..dd23141e344 100644
---
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereSchema.java
+++
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereSchema.java
@@ -72,20 +72,20 @@ public final class ShardingSphereSchema {
}
/**
- * Get table meta data via table name.
+ * Get table.
*
- * @param tableName tableName table name
- * @return table meta data
+ * @param tableName table name
+ * @return table
*/
public ShardingSphereTable getTable(final String tableName) {
return tables.get(tableName.toLowerCase());
}
/**
- * Get view meta data via view name.
+ * Get view.
*
- * @param viewName viewName view name
- * @return view meta data
+ * @param viewName view name
+ * @return view
*/
public ShardingSphereView getView(final String viewName) {
return views.get(viewName.toLowerCase());
@@ -116,14 +116,14 @@ public final class ShardingSphereSchema {
*
* @param tables tables
*/
- public void putAll(final Map<String, ShardingSphereTable> tables) {
+ public void putTables(final Map<String, ShardingSphereTable> tables) {
for (Entry<String, ShardingSphereTable> entry : tables.entrySet()) {
putTable(entry.getKey(), entry.getValue());
}
}
/**
- * Remove table meta data.
+ * Remove table.
*
* @param tableName table name
*/
@@ -132,7 +132,7 @@ public final class ShardingSphereSchema {
}
/**
- * Remove view meta data.
+ * Remove view.
*
* @param viewName view name
*/
@@ -141,38 +141,38 @@ public final class ShardingSphereSchema {
}
/**
- * Judge contains table from table meta data or not.
+ * Judge whether contains table.
*
* @param tableName table name
- * @return contains table from table meta data or not
+ * @return contains table or not
*/
public boolean containsTable(final String tableName) {
return tables.containsKey(tableName.toLowerCase());
}
/**
- * Judge whether contains index name.
+ * Judge whether contains index.
*
* @param tableName table name
* @param indexName index name
- * @return contains index name or not
+ * @return contains index or not
*/
public boolean containsIndex(final String tableName, final String
indexName) {
return containsTable(tableName) &&
getTable(tableName).containsIndex(indexName);
}
/**
- * Judge contains view from table meta data or not.
+ * Judge whether contains view.
*
* @param viewName view name
- * @return contains view from table meta data or not
+ * @return contains view or not
*/
public boolean containsView(final String viewName) {
return views.containsKey(viewName.toLowerCase());
}
/**
- * Get all column names via table.
+ * Get all column names.
*
* @param tableName table name
* @return column names
@@ -182,7 +182,7 @@ public final class ShardingSphereSchema {
}
/**
- * Get visible column names via table.
+ * Get visible column names.
*
* @param tableName table name
* @return visible column names
@@ -192,18 +192,19 @@ public final class ShardingSphereSchema {
}
/**
- * Get visible column name and indexe map.
+ * Get visible column and index map.
*
* @param tableName table name
- * @return visible column name and index map
+ * @return visible column and index map
*/
public Map<String, Integer> getVisibleColumnAndIndexMap(final String
tableName) {
return containsTable(tableName) ?
getTable(tableName).getVisibleColumnAndIndexMap() : Collections.emptyMap();
}
/**
- * Schema is empty or not.
- * @return true if tables and views are all empty, else false
+ * Whether empty schema.
+ *
+ * @return empty schema or not
*/
public boolean isEmpty() {
return tables.isEmpty() && views.isEmpty();
diff --git
a/test/it/pipeline/src/test/java/org/apache/shardingsphere/test/it/data/pipeline/core/util/PipelineContextUtils.java
b/test/it/pipeline/src/test/java/org/apache/shardingsphere/test/it/data/pipeline/core/util/PipelineContextUtils.java
index 1506b3fa66e..db968f5b4bd 100644
---
a/test/it/pipeline/src/test/java/org/apache/shardingsphere/test/it/data/pipeline/core/util/PipelineContextUtils.java
+++
b/test/it/pipeline/src/test/java/org/apache/shardingsphere/test/it/data/pipeline/core/util/PipelineContextUtils.java
@@ -145,7 +145,7 @@ public final class PipelineContextUtils {
new ShardingSphereColumn("user_id", Types.INTEGER, false,
false, false, true, false, false),
new ShardingSphereColumn("status", Types.VARCHAR, false,
false, false, true, false, false)),
Collections.emptyList(), Collections.emptyList()));
-
old.getMetaData().getDatabase("logic_db").getSchema("logic_db").putAll(tables);
+
old.getMetaData().getDatabase("logic_db").getSchema("logic_db").putTables(tables);
return MetaDataContextsFactory.create(persistService,
old.getMetaData());
}