use of org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure in project carbondata by apache.
the class CarbonTable method getStreamStorageOrderColumn.
/**
* This method will give storage order column list
*/
public List<CarbonColumn> getStreamStorageOrderColumn() {
List<CarbonDimension> dimensions = visibleDimensions;
List<CarbonMeasure> measures = visibleMeasures;
List<CarbonColumn> columnList = new ArrayList<>(dimensions.size() + measures.size());
List<CarbonColumn> complexDimensionList = new ArrayList<>(dimensions.size());
for (CarbonColumn column : dimensions) {
if (column.isComplex()) {
complexDimensionList.add(column);
} else {
columnList.add(column);
}
}
columnList.addAll(complexDimensionList);
for (CarbonColumn column : measures) {
if (!(column.getColName().equals("default_dummy_measure"))) {
columnList.add(column);
}
}
return columnList;
}
use of org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure in project carbondata by apache.
the class CarbonTable method fillVisibleMeasures.
/**
* This method will all the visible allMeasures
*/
private void fillVisibleMeasures() {
List<CarbonMeasure> visibleMeasures = new ArrayList<CarbonMeasure>(allMeasures.size());
for (CarbonMeasure measure : allMeasures) {
if (!measure.isInvisible()) {
visibleMeasures.add(measure);
}
}
this.visibleMeasures = visibleMeasures;
}
use of org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure in project carbondata by apache.
the class QueryModelBuilder method projectColumns.
public QueryModelBuilder projectColumns(String[] projectionColumns) {
Objects.requireNonNull(projectionColumns);
String factTableName = table.getTableName();
QueryProjection projection = new QueryProjection();
int i = 0;
for (String projectionColumnName : projectionColumns) {
CarbonDimension dimension = table.getDimensionByName(projectionColumnName);
if (dimension != null) {
CarbonDimension complexParentDimension = dimension.getComplexParentDimension();
if (null != complexParentDimension && dimension.getDataType() == DataTypes.DATE) {
if (!isAlreadyExists(complexParentDimension, projection.getDimensions())) {
projection.addDimension(complexParentDimension, i);
i++;
}
} else {
projection.addDimension(dimension, i);
i++;
}
} else {
CarbonMeasure measure = table.getMeasureByName(projectionColumnName);
if (measure == null) {
throw new RuntimeException(projectionColumnName + " column not found in the table " + factTableName);
}
projection.addMeasure(measure, i);
i++;
}
}
projection = optimizeProjectionForComplexColumns(projection, projectionColumns, factTableName);
List<String> projectionDimensionAndMeasures = new ArrayList<>();
this.projection = projection;
for (ProjectionDimension projectionDimension : projection.getDimensions()) {
projectionDimensionAndMeasures.add(projectionDimension.getColumnName());
}
for (ProjectionMeasure projectionMeasure : projection.getMeasures()) {
projectionDimensionAndMeasures.add(projectionMeasure.getColumnName());
}
LOGGER.info("Projection Columns: " + projectionDimensionAndMeasures);
return this;
}
use of org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure in project carbondata by apache.
the class QueryModelBuilder method removeMergedDimensions.
/**
* Remove the dimensions from the projection list which are merged
*
* @param mergedDimensions
* @param projectionColumns
* @param factTableName
* @return
*/
private QueryProjection removeMergedDimensions(List<CarbonDimension> mergedDimensions, String[] projectionColumns, String factTableName) {
QueryProjection queryProjection = new QueryProjection();
int i = 0;
for (String projectionColumnName : projectionColumns) {
CarbonDimension dimension = table.getDimensionByName(projectionColumnName);
if (dimension != null) {
if (!mergedDimensions.contains(dimension)) {
if (!isAlreadyExists(dimension, queryProjection.getDimensions())) {
queryProjection.addDimension(dimension, i);
i++;
}
}
} else {
CarbonMeasure measure = table.getMeasureByName(projectionColumnName);
if (measure == null) {
throw new RuntimeException(projectionColumnName + " column not found in the table " + factTableName);
}
queryProjection.addMeasure(measure, i);
i++;
}
}
return queryProjection;
}
use of org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure in project carbondata by apache.
the class RestructureUtilTest method testToGetUpdatedQueryDimension.
@Test
public void testToGetUpdatedQueryDimension() {
BlockExecutionInfo blockExecutionInfo = new BlockExecutionInfo();
List<Encoding> encodingList = new ArrayList<Encoding>();
encodingList.add(Encoding.DICTIONARY);
ColumnSchema columnSchema1 = new ColumnSchema();
columnSchema1.setColumnName("Id");
columnSchema1.setDataType(DataTypes.STRING);
columnSchema1.setColumnUniqueId(UUID.randomUUID().toString());
columnSchema1.setEncodingList(encodingList);
ColumnSchema columnSchema2 = new ColumnSchema();
columnSchema2.setColumnName("Name");
columnSchema2.setDataType(DataTypes.STRING);
columnSchema2.setColumnUniqueId(UUID.randomUUID().toString());
columnSchema2.setEncodingList(encodingList);
ColumnSchema columnSchema3 = new ColumnSchema();
columnSchema3.setColumnName("Age");
columnSchema3.setDataType(DataTypes.INT);
columnSchema3.setColumnUniqueId(UUID.randomUUID().toString());
columnSchema3.setEncodingList(encodingList);
ColumnSchema columnSchema4 = new ColumnSchema();
columnSchema4.setColumnName("Salary");
columnSchema4.setDataType(DataTypes.INT);
columnSchema4.setColumnUniqueId(UUID.randomUUID().toString());
columnSchema4.setEncodingList(encodingList);
ColumnSchema columnSchema5 = new ColumnSchema();
columnSchema5.setColumnName("Address");
columnSchema5.setDataType(DataTypes.STRING);
columnSchema5.setColumnUniqueId(UUID.randomUUID().toString());
columnSchema5.setEncodingList(encodingList);
CarbonDimension tableBlockDimension1 = new CarbonDimension(columnSchema1, 1, 1, 1);
CarbonDimension tableBlockDimension2 = new CarbonDimension(columnSchema2, 5, 5, 5);
List<CarbonDimension> tableBlockDimensions = Arrays.asList(tableBlockDimension1, tableBlockDimension2);
CarbonDimension tableComplexDimension1 = new CarbonDimension(columnSchema3, 4, 4, 4);
CarbonDimension tableComplexDimension2 = new CarbonDimension(columnSchema4, 2, 2, 2);
List<CarbonDimension> tableComplexDimensions = Arrays.asList(tableComplexDimension1, tableComplexDimension2);
ProjectionDimension queryDimension1 = new ProjectionDimension(tableBlockDimension1);
ProjectionDimension queryDimension2 = new ProjectionDimension(tableComplexDimension2);
ProjectionDimension queryDimension3 = new ProjectionDimension(new CarbonDimension(columnSchema5, 3, 3, 3));
ProjectionMeasure queryMeasure1 = new ProjectionMeasure(new CarbonMeasure(columnSchema3, 2));
ProjectionMeasure queryMeasure2 = new ProjectionMeasure(new CarbonMeasure(columnSchema4, 4));
List<ProjectionMeasure> queryMeasures = Arrays.asList(queryMeasure1, queryMeasure2);
ProjectionDimension[] queryDimensions = new ProjectionDimension[] { queryDimension1, queryDimension2, queryDimension3 };
List<ProjectionDimension> result = null;
result = RestructureUtil.createDimensionInfoAndGetCurrentBlockQueryDimension(blockExecutionInfo, queryDimensions, tableBlockDimensions, tableComplexDimensions, queryMeasures.size(), true, QueryModel.newInstance(new CarbonTable()));
List<CarbonDimension> resultDimension = new ArrayList<>(result.size());
for (ProjectionDimension queryDimension : result) {
resultDimension.add(queryDimension.getDimension());
}
assertThat(resultDimension, is(equalTo(Arrays.asList(queryDimension1.getDimension(), queryDimension2.getDimension()))));
}
Aggregations