Search in sources :

Example 1 with PrimitiveParserImpl

use of org.apache.carbondata.processing.newflow.parser.impl.PrimitiveParserImpl in project carbondata by apache.

the class CarbonParserFactory method createParser.

/**
   * This method may be called recursively if the carbon column is complex type.
   *
   * @param carbonColumn
   * @param complexDelimiters, these delimiters which are used to separate the complex data types.
   * @param depth              It is like depth of tree, if column has children then depth is 1,
   *                           And depth becomes 2 if children has children.
   *                           This depth is used select the complex
   *                           delimiters
   * @return GenericParser
   */
private static GenericParser createParser(CarbonColumn carbonColumn, String[] complexDelimiters, String nullFormat, int depth) {
    switch(carbonColumn.getDataType()) {
        case ARRAY:
            List<CarbonDimension> listOfChildDimensions = ((CarbonDimension) carbonColumn).getListOfChildDimensions();
            // Create array parser with complex delimiter
            ArrayParserImpl arrayParser = new ArrayParserImpl(complexDelimiters[depth], nullFormat);
            for (CarbonDimension dimension : listOfChildDimensions) {
                arrayParser.addChildren(createParser(dimension, complexDelimiters, nullFormat, depth + 1));
            }
            return arrayParser;
        case STRUCT:
            List<CarbonDimension> dimensions = ((CarbonDimension) carbonColumn).getListOfChildDimensions();
            // Create struct parser with complex delimiter
            StructParserImpl parser = new StructParserImpl(complexDelimiters[depth], nullFormat);
            for (CarbonDimension dimension : dimensions) {
                parser.addChildren(createParser(dimension, complexDelimiters, nullFormat, depth + 1));
            }
            return parser;
        case MAP:
            throw new UnsupportedOperationException("Complex type Map is not supported yet");
        default:
            return new PrimitiveParserImpl();
    }
}
Also used : StructParserImpl(org.apache.carbondata.processing.newflow.parser.impl.StructParserImpl) ArrayParserImpl(org.apache.carbondata.processing.newflow.parser.impl.ArrayParserImpl) PrimitiveParserImpl(org.apache.carbondata.processing.newflow.parser.impl.PrimitiveParserImpl) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)

Aggregations

CarbonDimension (org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)1 ArrayParserImpl (org.apache.carbondata.processing.newflow.parser.impl.ArrayParserImpl)1 PrimitiveParserImpl (org.apache.carbondata.processing.newflow.parser.impl.PrimitiveParserImpl)1 StructParserImpl (org.apache.carbondata.processing.newflow.parser.impl.StructParserImpl)1