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/02 14:46:08 UTC

[GitHub] [shardingsphere] strongduanmu commented on a diff in pull request #17251: Fix ORA-01795 while OracleSchemaMetaDataLoader.load tables count greater than 1000

strongduanmu commented on code in PR #17251:
URL: https://github.com/apache/shardingsphere/pull/17251#discussion_r862910546


##########
shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/loader/dialect/OracleSchemaMetaDataLoader.java:
##########
@@ -66,20 +68,37 @@ public final class OracleSchemaMetaDataLoader implements DialectSchemaMetaDataLo
     
     private static final int IDENTITY_COLUMN_START_MINOR_VERSION = 1;
     
+    private static final int BATCH_SIZE = 1000;
+    
     @Override
     public Collection<SchemaMetaData> load(final DataSource dataSource, final Collection<String> tables, final String defaultSchemaName) throws SQLException {
         Map<String, TableMetaData> tableMetaDataMap = new LinkedHashMap<>();
-        Map<String, Collection<ColumnMetaData>> columnMetaDataMap = loadColumnMetaDataMap(dataSource, tables);
+        Map<String, Collection<ColumnMetaData>> columnMetaDataMap = new HashMap<>(tables.size());
+        Collection[] splitTables = splitTables(new ArrayList(tables), BATCH_SIZE);
+        try (Connection connection = dataSource.getConnection()) {
+            for (Collection<String> subTables : splitTables) {

Review Comment:
   Please rename subTables to each.



##########
shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/loader/dialect/OracleSchemaMetaDataLoader.java:
##########
@@ -66,20 +68,37 @@ public final class OracleSchemaMetaDataLoader implements DialectSchemaMetaDataLo
     
     private static final int IDENTITY_COLUMN_START_MINOR_VERSION = 1;
     
+    private static final int BATCH_SIZE = 1000;
+    
     @Override
     public Collection<SchemaMetaData> load(final DataSource dataSource, final Collection<String> tables, final String defaultSchemaName) throws SQLException {
         Map<String, TableMetaData> tableMetaDataMap = new LinkedHashMap<>();
-        Map<String, Collection<ColumnMetaData>> columnMetaDataMap = loadColumnMetaDataMap(dataSource, tables);
+        Map<String, Collection<ColumnMetaData>> columnMetaDataMap = new HashMap<>(tables.size());
+        Collection[] splitTables = splitTables(new ArrayList(tables), BATCH_SIZE);

Review Comment:
   @cheese8 Can we use guava `Lists.partition` to replace this method? 



##########
shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/loader/dialect/OracleSchemaMetaDataLoader.java:
##########
@@ -66,20 +68,37 @@ public final class OracleSchemaMetaDataLoader implements DialectSchemaMetaDataLo
     
     private static final int IDENTITY_COLUMN_START_MINOR_VERSION = 1;
     
+    private static final int BATCH_SIZE = 1000;
+    
     @Override
     public Collection<SchemaMetaData> load(final DataSource dataSource, final Collection<String> tables, final String defaultSchemaName) throws SQLException {
         Map<String, TableMetaData> tableMetaDataMap = new LinkedHashMap<>();
-        Map<String, Collection<ColumnMetaData>> columnMetaDataMap = loadColumnMetaDataMap(dataSource, tables);
+        Map<String, Collection<ColumnMetaData>> columnMetaDataMap = new HashMap<>(tables.size());

Review Comment:
   @cheese8 Please add load factor when using new HashMap().



-- 
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