You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/05/18 09:12:18 UTC
[GitHub] [shardingsphere] sandynz commented on a diff in pull request #17778: Refactor PipelineTableMetaDataLoader and fix typo in PipelineTableMetaData
sandynz commented on code in PR #17778:
URL: https://github.com/apache/shardingsphere/pull/17778#discussion_r875660952
##########
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/metadata/loader/PipelineTableMetaDataLoader.java:
##########
@@ -49,13 +49,30 @@ public final class PipelineTableMetaDataLoader {
private final Map<TableName, PipelineTableMetaData> tableMetaDataMap = new ConcurrentHashMap<>();
/**
- * Load table metadata.
+ * Get table metadata, load if it does not exist.
*
- * @param schemaName schema name
- * @param tableNamePattern table name pattern
- * @throws SQLException if loading failure
+ * @param schemaName schema name. nullable
+ * @param tableName dedicated table name, not table name pattern
+ * @return table metadata
*/
- public void loadTableMetaData(final String schemaName, final String tableNamePattern) throws SQLException {
+ public PipelineTableMetaData getTableMetaData(final String schemaName, final String tableName) {
+ PipelineTableMetaData result = tableMetaDataMap.get(new TableName(tableName));
+ if (null != result) {
+ return result;
+ }
+ try {
+ loadTableMetaData(schemaName, tableName);
+ } catch (final SQLException ex) {
+ throw new RuntimeException(String.format("Load metadata for table '%s' failed", tableName), ex);
+ }
+ result = tableMetaDataMap.get(new TableName(tableName));
+ if (null == result) {
+ log.warn("getTableMetaData, can not load metadata for table '{}'", tableName);
+ }
+ return result;
+ }
+
+ private void loadTableMetaData(final String schemaName, final String tableNamePattern) throws SQLException {
Review Comment:
When set `tableNamePattern` to `%`, we could use it to speed up metadata loading. But the invocation was removed for now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org