jdbc-protolib/src/main/java/com/streamsets/pipeline/stage/origin/jdbc/cdc/oracle/OracleCDCSource.java
@VisibleForTesting
  String getListOfSchemasAndTables(List<SchemaAndTable> schemaAndTables) {
    Map<String, List<String>> schemas = new HashMap<>();
    for (SchemaAndTable schemaAndTable : schemaAndTables) {
      if (schemas.containsKey(schemaAndTable.getSchema())) {
        schemas.get(schemaAndTable.getSchema()).add(schemaAndTable.getTable());
      } else {
        List<String> tbls = new ArrayList<>();
        tbls.add(schemaAndTable.getTable());
        schemas.put(schemaAndTable.getSchema(), tbls);
      }
    }
    List<String> queries = new ArrayList<>();
    for (Map.Entry<String, List<String>> entry : schemas.entrySet()) {
      List<String> tables = new ArrayList<>();
      int fromIndex = 0;
      int range = 1000;
      int maxIndex = entry.getValue().size();
      int toIndex = range < maxIndex ? range : maxIndex;
      while (fromIndex < toIndex) {
        tables.add(Utils.format(
            "TABLE_NAME IN ({})", formatTableList(entry.getValue().subList(fromIndex, toIndex))));
        fromIndex = toIndex;
        toIndex = (toIndex + range) < maxIndex ? (toIndex + range) : maxIndex;
      }
      queries.add(Utils.format("(SEG_OWNER='{}' AND ({}))", entry.getKey(), String.join(" OR ", tables)));
    }
    return "( " + String.join(" OR ", queries) + " )";
  }
@VisibleForTesting
  String getListOfSchemasAndTables(List<SchemaAndTable> schemaAndTables) {
    Map<String, List<String>> schemas = new HashMap<>();
    for (SchemaAndTable schemaAndTable : schemaAndTables) {
      if (schemas.containsKey(schemaAndTable.getSchema())) {
        schemas.get(schemaAndTable.getSchema()).add(schemaAndTable.getTable());
      } else {
        List<String> tbls = new ArrayList<>();
        tbls.add(schemaAndTable.getTable());
        schemas.put(schemaAndTable.getSchema(), tbls);
      }
    }
    List<String> queries = new ArrayList<>();
    for (Map.Entry<String, List<String>> entry : schemas.entrySet()) {
      List<String> tables = new ArrayList<>();
      int fromIndex = 0;
      int range = 1000;
      int maxIndex = entry.getValue().size();
      int toIndex = range < maxIndex ? range : maxIndex;
      while (fromIndex < toIndex) {
        tables.add(Utils.format(
            "TABLE_NAME IN ({})", formatTableList(entry.getValue().subList(fromIndex, toIndex))));
        fromIndex = toIndex;
        toIndex = (toIndex + range) < maxIndex ? (toIndex + range) : maxIndex;
      }
      queries.add(Utils.format("(SEG_OWNER='{}' AND ({}))", entry.getKey(), String.join(" OR ", tables)));
    }
    return "( " + String.join(" OR ", queries) + " )";
  }
@ VisibleForTesting String getListOfSchemasAndTables ( List < SchemaAndTable > schemaAndTables ) { Map < String , List < String > > schemas = new HashMap <> ( ) ; for ( SchemaAndTable schemaAndTable : schemaAndTables ) { if ( schemas . containsKey ( schemaAndTable . getSchema ( ) ) ) { schemas . get ( schemaAndTable . getSchema ( ) ) . add ( schemaAndTable . getTable ( ) ) ; } else { List < String > tbls = new ArrayList <> ( ) ; tbls . add ( schemaAndTable . getTable ( ) ) ; schemas . put ( schemaAndTable . getSchema ( ) , tbls ) ; } } List < String > queries = new ArrayList <> ( ) ; for ( Map . Entry < String , List < String > > entry : schemas . entrySet ( ) ) { List < String > tables = new ArrayList <> ( ) ; int fromIndex = 0 ; int range = 1000 ; int maxIndex = entry . getValue ( ) . size ( ) ; int toIndex = range < maxIndex ? range : maxIndex ; while ( fromIndex < toIndex ) { tables . add ( Utils . format ( "TABLE_NAME IN ({})" , formatTableList ( entry . getValue ( ) . subList ( fromIndex , toIndex ) ) ) ) ; fromIndex = toIndex ; toIndex = ( toIndex + range ) < maxIndex ? ( toIndex + range ) : maxIndex ; } queries . add ( Utils . format ( "(SEG_OWNER='{}' AND ({}))" , entry . getKey ( ) , String . join ( " OR " , tables ) ) ) ; } return "( " + String . join ( " OR " , queries ) + " )" ; }
This method needs to get SQL like string with all required schemas and tables.
@param schemaAndTables List of SchemaAndTable objects
@return SQL string of schemas and tables
This method needs to get SQL like string with all required schemas and tables .