Search in sources :

Example 76 with ColumnSchema

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());
            }
        }
    }
}
Also used : ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) ParentColumnTableRelation(org.apache.carbondata.core.metadata.schema.table.column.ParentColumnTableRelation)

Example 77 with ColumnSchema

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;
}
Also used : ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)

Example 78 with ColumnSchema

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;
}
Also used : CarbonMeasure(org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure) ArrayList(java.util.ArrayList) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)

Example 79 with ColumnSchema

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);
    }
}
Also used : ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)

Example 80 with ColumnSchema

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());
}
Also used : BucketingInfo(org.apache.carbondata.core.metadata.schema.BucketingInfo) DataField(org.apache.carbondata.processing.loading.DataField) HashPartitionerImpl(org.apache.carbondata.processing.loading.partition.impl.HashPartitionerImpl) ArrayList(java.util.ArrayList) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)

Aggregations

ColumnSchema (org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)164 ArrayList (java.util.ArrayList)80 Test (org.junit.Test)63 Encoding (org.apache.carbondata.core.metadata.encoder.Encoding)61 CarbonDimension (org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)33 MockUp (mockit.MockUp)29 TableSchema (org.apache.carbondata.core.metadata.schema.table.TableSchema)14 DataFileFooter (org.apache.carbondata.core.metadata.blocklet.DataFileFooter)13 HashMap (java.util.HashMap)12 SchemaEvolutionEntry (org.apache.carbondata.core.metadata.schema.SchemaEvolutionEntry)11 TableInfo (org.apache.carbondata.core.metadata.schema.table.TableInfo)10 CarbonMeasure (org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure)10 SchemaEvolution (org.apache.carbondata.core.metadata.schema.SchemaEvolution)9 SegmentProperties (org.apache.carbondata.core.datastore.block.SegmentProperties)8 CarbonTable (org.apache.carbondata.core.metadata.schema.table.CarbonTable)8 Map (java.util.Map)7 SegmentInfo (org.apache.carbondata.core.metadata.blocklet.SegmentInfo)7 BlockletInfo (org.apache.carbondata.core.metadata.blocklet.BlockletInfo)6 BlockletIndex (org.apache.carbondata.core.metadata.blocklet.index.BlockletIndex)6 ThriftWrapperSchemaConverterImpl (org.apache.carbondata.core.metadata.converter.ThriftWrapperSchemaConverterImpl)6