Search in sources :

Example 11 with CarbonDimension

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

Example 12 with CarbonDimension

use of org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension 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 13 with CarbonDimension

use of org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension in project carbondata by apache.

the class CarbonTable method assignComplexOrdinal.

/**
   * Read all primitive/complex children and set it as list of child carbon dimension to parent
   * dimension
   */
private int assignComplexOrdinal(CarbonDimension parentDimension, int complexDimensionOrdianl) {
    for (int i = 0; i < parentDimension.getNumberOfChild(); i++) {
        CarbonDimension dimension = parentDimension.getListOfChildDimensions().get(i);
        if (dimension.getNumberOfChild() > 0) {
            dimension.setComplexTypeOridnal(++complexDimensionOrdianl);
            complexDimensionOrdianl = assignComplexOrdinal(dimension, complexDimensionOrdianl);
        } else {
            parentDimension.getListOfChildDimensions().get(i).setComplexTypeOridnal(++complexDimensionOrdianl);
        }
    }
    return complexDimensionOrdianl;
}
Also used : CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)

Example 14 with CarbonDimension

use of org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension in project carbondata by apache.

the class TableDictionaryGenerator method size.

public Integer size(DictionaryMessage key) {
    CarbonMetadata metadata = CarbonMetadata.getInstance();
    CarbonTable carbonTable = metadata.getCarbonTable(key.getTableUniqueName());
    CarbonDimension dimension = carbonTable.getPrimitiveDimensionByName(key.getTableUniqueName(), key.getColumnName());
    DictionaryGenerator<Integer, String> generator = columnMap.get(dimension.getColumnId());
    return ((BiDictionary) generator).size();
}
Also used : CarbonTable(org.apache.carbondata.core.metadata.schema.table.CarbonTable) CarbonMetadata(org.apache.carbondata.core.metadata.CarbonMetadata) BiDictionary(org.apache.carbondata.core.devapi.BiDictionary) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)

Example 15 with CarbonDimension

use of org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension in project carbondata by apache.

the class TableDictionaryGenerator method generateKey.

@Override
public Integer generateKey(DictionaryMessage value) throws DictionaryGenerationException {
    CarbonMetadata metadata = CarbonMetadata.getInstance();
    CarbonTable carbonTable = metadata.getCarbonTable(value.getTableUniqueName());
    CarbonDimension dimension = carbonTable.getPrimitiveDimensionByName(value.getTableUniqueName(), value.getColumnName());
    DictionaryGenerator<Integer, String> generator = columnMap.get(dimension.getColumnId());
    return generator.generateKey(value.getData());
}
Also used : CarbonTable(org.apache.carbondata.core.metadata.schema.table.CarbonTable) CarbonMetadata(org.apache.carbondata.core.metadata.CarbonMetadata) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)

Aggregations

CarbonDimension (org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)85 ColumnSchema (org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)31 ArrayList (java.util.ArrayList)26 Test (org.junit.Test)23 CarbonMeasure (org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure)15 CarbonTable (org.apache.carbondata.core.metadata.schema.table.CarbonTable)13 QueryDimension (org.apache.carbondata.core.scan.model.QueryDimension)9 CarbonMetadata (org.apache.carbondata.core.metadata.CarbonMetadata)7 HashSet (java.util.HashSet)6 List (java.util.List)5 ColumnExpression (org.apache.carbondata.core.scan.expression.ColumnExpression)5 Expression (org.apache.carbondata.core.scan.expression.Expression)5 RangeExpression (org.apache.carbondata.core.scan.expression.logical.RangeExpression)5 FilterOptimizer (org.apache.carbondata.core.scan.filter.intf.FilterOptimizer)5 FilterOptimizerBasic (org.apache.carbondata.core.scan.filter.intf.FilterOptimizerBasic)5 RangeFilterOptmizer (org.apache.carbondata.core.scan.filter.optimizer.RangeFilterOptmizer)5 Map (java.util.Map)4 SortedMap (java.util.SortedMap)4 TreeMap (java.util.TreeMap)4 TableInfo (org.apache.carbondata.core.metadata.schema.table.TableInfo)4