use of org.apache.carbondata.processing.newflow.parser.impl.StructParserImpl 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();
}
}
Aggregations