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);
}
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;
}
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;
}
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();
}
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());
}
Aggregations