[ 
https://issues.apache.org/jira/browse/FLINK-1512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14356783#comment-14356783
 ] 

ASF GitHub Bot commented on FLINK-1512:
---------------------------------------

Github user fhueske commented on a diff in the pull request:

    https://github.com/apache/flink/pull/426#discussion_r26206133
  
    --- Diff: 
flink-java/src/main/java/org/apache/flink/api/java/io/CsvInputFormat.java ---
    @@ -152,6 +177,38 @@ public void setFields(boolean[] sourceFieldMask, 
Class<?>[] fieldTypes) {
        public Class<?>[] getFieldTypes() {
                return super.getGenericFieldTypes();
        }
    +
    +   public void setFieldsMap(String[] fieldsMap) {
    +           Preconditions.checkNotNull(fieldsMap);
    +           Preconditions.checkState(typeInformation instanceof 
PojoTypeInfo);
    +
    +           PojoTypeInfo<OUT> pojoTypeInfo = (PojoTypeInfo<OUT>) 
typeInformation;
    +
    +           String[] fields = pojoTypeInfo.getFieldNames();
    +           Class<?>[] fieldTypes = getFieldTypes();
    +           this.fieldsMap = Arrays.copyOfRange(fieldsMap, 0, 
fieldsMap.length);
    +
    +           boolean[] includeMask = new boolean[fieldsMap.length];
    +           Class<?>[] newFieldTypes = new Class<?>[fieldsMap.length];
    +
    +           for (int i = 0; i < fieldsMap.length; i++) {
    +                   if (fieldsMap[i] == null) {
    --- End diff --
    
    IMO, ``null`` values should not be allowed in the ``fieldsMap``. Can you 
throw an exception in that case?
    The ``fieldsMap`` should be a list of fields that are mapped to columns in 
the CSV file. As said before, the columns that are read by the format are 
defined by the ``includeMask``.


> Add CsvReader for reading into POJOs.
> -------------------------------------
>
>                 Key: FLINK-1512
>                 URL: https://issues.apache.org/jira/browse/FLINK-1512
>             Project: Flink
>          Issue Type: New Feature
>          Components: Java API, Scala API
>            Reporter: Robert Metzger
>            Assignee: Chiwan Park
>            Priority: Minor
>              Labels: starter
>
> Currently, the {{CsvReader}} supports only TupleXX types. 
> It would be nice if users were also able to read into POJOs.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to