Search in sources :

Example 1 with InvalidRecordException

use of org.apache.parquet.io.InvalidRecordException in project apex-malhar by apache.

the class ParquetFilePOJOReader method initialiseActiveFieldInfo.

/**
 * Initializes {@link #activeFieldInfos} by adding fields represented by
 * fieldMapping
 *
 * @param fieldMapping
 *          String representing Parquet field name TO POJO field field name
 *          mapping
 */
private void initialiseActiveFieldInfo(String fieldMapping) {
    String[] fields = fieldMapping.split(RECORD_SEPARATOR);
    activeFieldInfos = new ArrayList<>(fields.length);
    for (String field : fields) {
        String[] token = field.split(FIELD_SEPARATOR);
        try {
            int fieldIndex = schema.getFieldIndex(token[0]);
            PrimitiveTypeName primitiveTypeName = schema.getType(fieldIndex).asPrimitiveType().getPrimitiveTypeName();
            activeFieldInfos.add(new ActiveFieldInfo(getSetter(token[1], SupportType.valueOf(token[2])), primitiveTypeName, fieldIndex));
        } catch (InvalidRecordException e) {
            logger.error("{} not present in schema ", token[0]);
        } catch (UnsupportedOperationException e) {
            logger.error("{} not yet supported ", e.getMessage());
        }
    }
}
Also used : InvalidRecordException(org.apache.parquet.io.InvalidRecordException) PrimitiveTypeName(org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName)

Aggregations

InvalidRecordException (org.apache.parquet.io.InvalidRecordException)1 PrimitiveTypeName (org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName)1