use of org.apache.carbondata.processing.datatypes.PrimitiveDataType in project carbondata by apache.
the class FieldEncoderFactory method createComplexType.
/**
* This method may be called recursively if the carbon column is complex type.
*
* @return GenericDataType
*/
private static GenericDataType createComplexType(CarbonColumn carbonColumn, String parentName, Cache<DictionaryColumnUniqueIdentifier, Dictionary> cache, CarbonTableIdentifier carbonTableIdentifier, DictionaryClient client, Boolean useOnePass, String storePath, boolean tableInitialize, Map<Object, Integer> localCache) {
switch(carbonColumn.getDataType()) {
case ARRAY:
List<CarbonDimension> listOfChildDimensions = ((CarbonDimension) carbonColumn).getListOfChildDimensions();
// Create array parser with complex delimiter
ArrayDataType arrayDataType = new ArrayDataType(carbonColumn.getColName(), parentName, carbonColumn.getColumnId());
for (CarbonDimension dimension : listOfChildDimensions) {
arrayDataType.addChildren(createComplexType(dimension, carbonColumn.getColName(), cache, carbonTableIdentifier, client, useOnePass, storePath, tableInitialize, localCache));
}
return arrayDataType;
case STRUCT:
List<CarbonDimension> dimensions = ((CarbonDimension) carbonColumn).getListOfChildDimensions();
// Create struct parser with complex delimiter
StructDataType structDataType = new StructDataType(carbonColumn.getColName(), parentName, carbonColumn.getColumnId());
for (CarbonDimension dimension : dimensions) {
structDataType.addChildren(createComplexType(dimension, carbonColumn.getColName(), cache, carbonTableIdentifier, client, useOnePass, storePath, tableInitialize, localCache));
}
return structDataType;
case MAP:
throw new UnsupportedOperationException("Complex type Map is not supported yet");
default:
return new PrimitiveDataType(carbonColumn.getColName(), parentName, carbonColumn.getColumnId(), (CarbonDimension) carbonColumn, cache, carbonTableIdentifier, client, useOnePass, storePath, tableInitialize, localCache);
}
}
use of org.apache.carbondata.processing.datatypes.PrimitiveDataType in project carbondata by apache.
the class CarbonDataProcessorUtil method getComplexTypesMap.
// TODO: need to simplify it. Not required create string first.
public static Map<String, GenericDataType> getComplexTypesMap(DataField[] dataFields) {
String complexTypeString = getComplexTypeString(dataFields);
if (null == complexTypeString || complexTypeString.equals("")) {
return new LinkedHashMap<>();
}
Map<String, GenericDataType> complexTypesMap = new LinkedHashMap<String, GenericDataType>();
String[] hierarchies = complexTypeString.split(CarbonCommonConstants.SEMICOLON_SPC_CHARACTER);
for (int i = 0; i < hierarchies.length; i++) {
String[] levels = hierarchies[i].split(CarbonCommonConstants.HASH_SPC_CHARACTER);
String[] levelInfo = levels[0].split(CarbonCommonConstants.COLON_SPC_CHARACTER);
GenericDataType g = levelInfo[1].equals(CarbonCommonConstants.ARRAY) ? new ArrayDataType(levelInfo[0], "", levelInfo[3]) : new StructDataType(levelInfo[0], "", levelInfo[3]);
complexTypesMap.put(levelInfo[0], g);
for (int j = 1; j < levels.length; j++) {
levelInfo = levels[j].split(CarbonCommonConstants.COLON_SPC_CHARACTER);
switch(levelInfo[1]) {
case CarbonCommonConstants.ARRAY:
g.addChildren(new ArrayDataType(levelInfo[0], levelInfo[2], levelInfo[3]));
break;
case CarbonCommonConstants.STRUCT:
g.addChildren(new StructDataType(levelInfo[0], levelInfo[2], levelInfo[3]));
break;
default:
g.addChildren(new PrimitiveDataType(levelInfo[0], levelInfo[2], levelInfo[3], Integer.parseInt(levelInfo[4])));
}
}
}
return complexTypesMap;
}
Aggregations