use of org.apache.carbondata.core.metadata.schema.table.AggregationDataMapSchema in project carbondata by apache.
the class AggregateTableSelector method selectPreAggDataMapSchema.
/**
* Below method will be used to select pre aggregate tables based on query plan
* Rules for selecting the aggregate table is below:
* 1. Select all aggregate table based on projection
* 2. select aggregate table based on filter exp,
* 2. select if aggregate tables based on aggregate columns
*
* @return selected pre aggregate table schema
*/
public List<DataMapSchema> selectPreAggDataMapSchema() {
List<QueryColumn> projectionColumn = aggregateQueryPlan.getProjectionColumn();
List<QueryColumn> filterColumns = aggregateQueryPlan.getFilterColumns();
List<DataMapSchema> dataMapSchemaList = parentTable.getTableInfo().getDataMapSchemaList();
List<DataMapSchema> selectedDataMapSchema = new ArrayList<>();
boolean isMatch;
// match projection columns
if (null != projectionColumn && !projectionColumn.isEmpty()) {
for (DataMapSchema dmSchema : dataMapSchemaList) {
AggregationDataMapSchema aggregationDataMapSchema = (AggregationDataMapSchema) dmSchema;
isMatch = true;
for (QueryColumn queryColumn : projectionColumn) {
ColumnSchema columnSchemaByParentName = getColumnSchema(queryColumn, aggregationDataMapSchema);
if (null == columnSchemaByParentName) {
isMatch = false;
break;
}
}
if (isMatch) {
selectedDataMapSchema.add(dmSchema);
}
}
// if projection column is present but selected table list size is zero then
if (selectedDataMapSchema.size() == 0) {
return selectedDataMapSchema;
}
}
// match filter columns
if (null != filterColumns && !filterColumns.isEmpty()) {
List<DataMapSchema> dmSchemaToIterate = selectedDataMapSchema.isEmpty() ? dataMapSchemaList : selectedDataMapSchema;
selectedDataMapSchema = new ArrayList<>();
for (DataMapSchema dmSchema : dmSchemaToIterate) {
isMatch = true;
for (QueryColumn queryColumn : filterColumns) {
AggregationDataMapSchema aggregationDataMapSchema = (AggregationDataMapSchema) dmSchema;
ColumnSchema columnSchemaByParentName = getColumnSchema(queryColumn, aggregationDataMapSchema);
if (null == columnSchemaByParentName) {
isMatch = false;
break;
}
}
if (isMatch) {
selectedDataMapSchema.add(dmSchema);
}
}
// if filter column is present and selection size is zero then return
if (selectedDataMapSchema.size() == 0) {
return selectedDataMapSchema;
}
}
return selectedDataMapSchema;
}
Aggregations