You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by so...@apache.org on 2022/09/22 07:16:54 UTC

[shardingsphere] branch master updated: Remove redundant code (#21131)

This is an automated email from the ASF dual-hosted git repository.

soulasuna 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 1d5fcc54589 Remove redundant code (#21131)
1d5fcc54589 is described below

commit 1d5fcc5458915fa4ba25ce5cfa82b744b1ff13d3
Author: zhaojinchao <zh...@apache.org>
AuthorDate: Thu Sep 22 15:16:45 2022 +0800

    Remove redundant code (#21131)
---
 .../schema/loader/SchemaMetaDataLoaderEngine.java  |  2 -
 .../schema/loader/common/ViewMetaDataLoader.java   | 64 ----------------------
 2 files changed, 66 deletions(-)

diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/loader/SchemaMetaDataLoaderEngine.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/loader/SchemaMetaDataLoaderEngine.java
index 5504e820088..d7e2c27e7f6 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/loader/SchemaMetaDataLoaderEngine.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/loader/SchemaMetaDataLoaderEngine.java
@@ -25,7 +25,6 @@ import org.apache.shardingsphere.infra.database.type.DatabaseType;
 import org.apache.shardingsphere.infra.metadata.database.schema.loader.common.TableMetaDataLoader;
 import org.apache.shardingsphere.infra.metadata.database.schema.loader.model.SchemaMetaData;
 import org.apache.shardingsphere.infra.metadata.database.schema.loader.model.TableMetaData;
-import org.apache.shardingsphere.infra.metadata.database.schema.loader.model.ViewMetaData;
 import org.apache.shardingsphere.infra.metadata.database.schema.loader.spi.DialectSchemaMetaDataLoader;
 import org.apache.shardingsphere.infra.metadata.database.schema.loader.spi.DialectSchemaMetaDataLoaderFactory;
 import org.apache.shardingsphere.infra.util.exception.external.sql.type.generic.UnknownSQLException;
@@ -73,7 +72,6 @@ public final class SchemaMetaDataLoaderEngine {
     
     private static Map<String, SchemaMetaData> loadByDefault(final Collection<SchemaMetaDataLoaderMaterials> materials, final DatabaseType databaseType) throws SQLException {
         Collection<TableMetaData> tableMetaData = new LinkedList<>();
-        Collection<ViewMetaData> viewMetaData = new LinkedList<>();
         String defaultSchemaName = null;
         for (SchemaMetaDataLoaderMaterials each : materials) {
             defaultSchemaName = each.getDefaultSchemaName();
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/loader/common/ViewMetaDataLoader.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/loader/common/ViewMetaDataLoader.java
deleted file mode 100644
index fd5c6312413..00000000000
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/loader/common/ViewMetaDataLoader.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.infra.metadata.database.schema.loader.common;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.metadata.database.schema.loader.adapter.MetaDataLoaderConnectionAdapter;
-import org.apache.shardingsphere.infra.metadata.database.schema.loader.model.ViewMetaData;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Optional;
-
-/**
- * View meta data loader.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class ViewMetaDataLoader {
-    
-    /**
-     * Load view meta data.
-     *
-     * @param dataSource data source
-     * @param databaseType database type
-     * @return table meta data
-     * @throws SQLException SQL exception
-     */
-    public static Optional<ViewMetaData> load(final DataSource dataSource, final DatabaseType databaseType) throws SQLException {
-        try (MetaDataLoaderConnectionAdapter connectionAdapter = new MetaDataLoaderConnectionAdapter(databaseType, dataSource.getConnection())) {
-            return Optional.ofNullable(load(connectionAdapter));
-        }
-    }
-    
-    private static ViewMetaData load(final Connection connection) throws SQLException {
-        try (ResultSet resultSet = connection.getMetaData().getTables(connection.getCatalog(), connection.getSchema(), null, new String[]{"VIEW"})) {
-            while (resultSet.next()) {
-                String tableName = resultSet.getString("TABLE_NAME");
-                String viewDefinition = resultSet.getString("VIEW_DEFINITION");
-                if (null != tableName && null != viewDefinition) {
-                    return new ViewMetaData(tableName, viewDefinition);
-                }
-            }
-        }
-        return null;
-    }
-}