use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.
the class AggregationDataMapSchema method fillParentNameToAggregationMapping.
/**
* Method to prepare mapping of parent to list of aggregation function applied on that column
* @param listOfColumns
* child column schema list
*/
private void fillParentNameToAggregationMapping(List<ColumnSchema> listOfColumns) {
parentColumnToAggregationsMapping = new HashMap<>();
for (ColumnSchema column : listOfColumns) {
if (null != column.getAggFunction() && !column.getAggFunction().isEmpty()) {
List<ParentColumnTableRelation> parentColumnTableRelations = column.getParentColumnTableRelations();
if (null != parentColumnTableRelations && parentColumnTableRelations.size() == 1) {
String columnName = column.getParentColumnTableRelations().get(0).getColumnName();
Set<String> aggFunctions = parentColumnToAggregationsMapping.get(columnName);
if (null == aggFunctions) {
aggFunctions = new HashSet<>();
parentColumnToAggregationsMapping.put(columnName, aggFunctions);
}
aggFunctions.add(column.getAggFunction());
}
}
}
}
use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.
the class CarbonTable method readAllComplexTypeChildrens.
/**
* Read all primitive/complex children and set it as list of child carbon dimension to parent
* dimension
*
* @param dimensionOrdinal
* @param childCount
* @param listOfColumns
* @param parentDimension
* @return
*/
private int readAllComplexTypeChildrens(int dimensionOrdinal, int childCount, List<ColumnSchema> listOfColumns, CarbonDimension parentDimension, List<CarbonDimension> primitiveDimensions) {
for (int i = 0; i < childCount; i++) {
ColumnSchema columnSchema = listOfColumns.get(dimensionOrdinal);
if (columnSchema.isDimensionColumn()) {
if (columnSchema.getNumberOfChild() > 0) {
CarbonDimension complexDimension = new CarbonDimension(columnSchema, dimensionOrdinal++, columnSchema.getSchemaOrdinal(), -1, -1, -1);
complexDimension.initializeChildDimensionsList(columnSchema.getNumberOfChild());
parentDimension.getListOfChildDimensions().add(complexDimension);
dimensionOrdinal = readAllComplexTypeChildrens(dimensionOrdinal, columnSchema.getNumberOfChild(), listOfColumns, complexDimension, primitiveDimensions);
} else {
CarbonDimension carbonDimension = new CarbonDimension(columnSchema, dimensionOrdinal++, columnSchema.getSchemaOrdinal(), -1, -1, -1);
parentDimension.getListOfChildDimensions().add(carbonDimension);
primitiveDimensions.add(carbonDimension);
}
}
}
return dimensionOrdinal;
}
use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.
the class CarbonTable method fillDimensionsAndMeasuresForTables.
/**
* Fill allDimensions and allMeasures for carbon table
*
* @param tableSchema
*/
private void fillDimensionsAndMeasuresForTables(TableSchema tableSchema) {
List<CarbonDimension> primitiveDimensions = new ArrayList<CarbonDimension>();
List<CarbonDimension> implicitDimensions = new ArrayList<CarbonDimension>();
allDimensions = new ArrayList<CarbonDimension>();
allMeasures = new ArrayList<CarbonMeasure>();
this.tablePrimitiveDimensionsMap.put(this.tableUniqueName, primitiveDimensions);
this.tableImplicitDimensionsMap.put(tableSchema.getTableName(), implicitDimensions);
int dimensionOrdinal = 0;
int measureOrdinal = 0;
int keyOrdinal = 0;
int columnGroupOrdinal = -1;
int previousColumnGroupId = -1;
List<ColumnSchema> listOfColumns = tableSchema.getListOfColumns();
int complexTypeOrdinal = -1;
for (int i = 0; i < listOfColumns.size(); i++) {
ColumnSchema columnSchema = listOfColumns.get(i);
if (columnSchema.isDimensionColumn()) {
if (columnSchema.getNumberOfChild() > 0) {
CarbonDimension complexDimension = new CarbonDimension(columnSchema, dimensionOrdinal++, columnSchema.getSchemaOrdinal(), -1, -1, ++complexTypeOrdinal);
complexDimension.initializeChildDimensionsList(columnSchema.getNumberOfChild());
allDimensions.add(complexDimension);
dimensionOrdinal = readAllComplexTypeChildrens(dimensionOrdinal, columnSchema.getNumberOfChild(), listOfColumns, complexDimension, primitiveDimensions);
i = dimensionOrdinal - 1;
complexTypeOrdinal = assignComplexOrdinal(complexDimension, complexTypeOrdinal);
} else {
if (!columnSchema.isInvisible() && columnSchema.isSortColumn()) {
this.numberOfSortColumns++;
}
if (!columnSchema.getEncodingList().contains(Encoding.DICTIONARY)) {
CarbonDimension dimension = new CarbonDimension(columnSchema, dimensionOrdinal++, columnSchema.getSchemaOrdinal(), -1, -1, -1);
if (!columnSchema.isInvisible() && columnSchema.isSortColumn()) {
this.numberOfNoDictSortColumns++;
}
allDimensions.add(dimension);
primitiveDimensions.add(dimension);
} else if (columnSchema.getEncodingList().contains(Encoding.DICTIONARY) && columnSchema.getColumnGroupId() == -1) {
CarbonDimension dimension = new CarbonDimension(columnSchema, dimensionOrdinal++, columnSchema.getSchemaOrdinal(), keyOrdinal++, -1, -1);
allDimensions.add(dimension);
primitiveDimensions.add(dimension);
} else {
columnGroupOrdinal = previousColumnGroupId == columnSchema.getColumnGroupId() ? ++columnGroupOrdinal : 0;
previousColumnGroupId = columnSchema.getColumnGroupId();
CarbonDimension dimension = new CarbonDimension(columnSchema, dimensionOrdinal++, columnSchema.getSchemaOrdinal(), keyOrdinal++, columnGroupOrdinal, -1);
allDimensions.add(dimension);
primitiveDimensions.add(dimension);
}
}
} else {
allMeasures.add(new CarbonMeasure(columnSchema, measureOrdinal++, columnSchema.getSchemaOrdinal()));
}
}
fillVisibleDimensions(tableSchema.getTableName());
fillVisibleMeasures(tableSchema.getTableName());
addImplicitDimension(dimensionOrdinal, implicitDimensions);
dimensionOrdinalMax = dimensionOrdinal;
}
use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.
the class BucketingInfo method readFields.
@Override
public void readFields(DataInput input) throws IOException {
this.numOfRanges = input.readInt();
int colSchemaSize = input.readInt();
this.listOfColumns = new ArrayList<>(colSchemaSize);
for (int i = 0; i < colSchemaSize; i++) {
ColumnSchema aSchema = new ColumnSchema();
aSchema.readFields(input);
this.listOfColumns.add(aSchema);
}
}
use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.
the class DataConverterProcessorStepImpl method initializeBucketColumnPartitioner.
/**
* initialize partitioner for bucket column
*/
private void initializeBucketColumnPartitioner() {
List<Integer> indexes = new ArrayList<>();
List<ColumnSchema> columnSchemas = new ArrayList<>();
DataField[] inputDataFields = getOutput();
BucketingInfo bucketingInfo = configuration.getBucketingInfo();
for (int i = 0; i < inputDataFields.length; i++) {
for (int j = 0; j < bucketingInfo.getListOfColumns().size(); j++) {
if (inputDataFields[i].getColumn().getColName().equals(bucketingInfo.getListOfColumns().get(j).getColumnName())) {
indexes.add(i);
columnSchemas.add(inputDataFields[i].getColumn().getColumnSchema());
break;
}
}
}
// hash partitioner to dispatch rows by bucket column
this.partitioner = new HashPartitionerImpl(indexes, columnSchemas, bucketingInfo.getNumOfRanges());
}
Aggregations