metamodel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomatophantastico <...@git.apache.org>
Subject [GitHub] metamodel pull request #153: Collections instead of Arrays
Date Fri, 28 Jul 2017 13:00:35 GMT
Github user tomatophantastico commented on a diff in the pull request:

    https://github.com/apache/metamodel/pull/153#discussion_r130083327
  
    --- Diff: core/src/main/java/org/apache/metamodel/convert/Converters.java ---
    @@ -136,15 +135,19 @@ public static DataContext addTypeConverters(DataContext dataContext,
Map<Column,
          *         used (eg. with the {@link #addTypeConverters(DataContext, Map)}
          *         method) to decorate the DataContext with type converters.
          */
    -    public static Map<Column, TypeConverter<?, ?>> autoDetectConverters(DataContext
dataContext, Column[] columns,
    +    public static Map<Column, TypeConverter<?, ?>> autoDetectConverters(DataContext
dataContext, final List<Column> columns,
                 int sampleSize) {
    -        columns = MetaModelHelper.getColumnsBySuperType(columns, SuperColumnType.LITERAL_TYPE);
             final Map<Column, TypeConverter<?, ?>> result = new HashMap<Column,
TypeConverter<?, ?>>();
    -        Table[] tables = MetaModelHelper.getTables(columns);
    -        for (Table table : tables) {
    -            Column[] tableColumns = MetaModelHelper.getTableColumns(table, columns);
    -            autoDetectConvertersInternally(dataContext, table, tableColumns, sampleSize,
result);
    -        }
    +        columns.stream()
    +                .filter(col -> col.getType() != null)
    +                .filter(col -> col.getType().getSuperType().equals(SuperColumnType.LITERAL_TYPE))
    +                // group by table
    +                .collect(Collectors.toMap(Column::getTable,Arrays::asList))
    +                //and detect it
    +                .forEach((tab, cols) ->{
    +                    autoDetectConvertersInternally(dataContext,tab,cols,sampleSize,result);
    --- End diff --
    
    true


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message