Search in sources :

Example 1 with DataMapSchema

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

the class DataMapStoreManager method getAllDataMap.

/**
 * It gives all datamaps except the default datamap.
 *
 * @return
 */
public List<TableDataMap> getAllDataMap(CarbonTable carbonTable) {
    // TODO cache all schemas and update only when datamap status file updates
    List<DataMapSchema> dataMapSchemas = getAllDataMapSchemas();
    List<TableDataMap> dataMaps = new ArrayList<>();
    if (dataMapSchemas != null) {
        for (DataMapSchema dataMapSchema : dataMapSchemas) {
            RelationIdentifier identifier = dataMapSchema.getParentTables().get(0);
            if (dataMapSchema.isIndexDataMap() && identifier.getTableName().equals(carbonTable.getTableName()) && identifier.getDatabaseName().equals(carbonTable.getDatabaseName())) {
                dataMaps.add(getDataMap(carbonTable, dataMapSchema));
            }
        }
    }
    return dataMaps;
}
Also used : ArrayList(java.util.ArrayList) DataMapSchema(org.apache.carbondata.core.metadata.schema.table.DataMapSchema) RelationIdentifier(org.apache.carbondata.core.metadata.schema.table.RelationIdentifier)

Example 2 with DataMapSchema

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

the class DataMapStatusManager method enableDataMap.

public static void enableDataMap(String dataMapName) throws IOException {
    DataMapSchema dataMapSchema = validateDataMap(dataMapName, false);
    List<DataMapSchema> list = new ArrayList<>();
    if (dataMapSchema != null) {
        list.add(dataMapSchema);
    }
    storageProvider.updateDataMapStatus(list, DataMapStatus.ENABLED);
}
Also used : ArrayList(java.util.ArrayList) DataMapSchema(org.apache.carbondata.core.metadata.schema.table.DataMapSchema)

Example 3 with DataMapSchema

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

the class DataMapStatusManager method validateDataMap.

private static DataMapSchema validateDataMap(String dataMapName, boolean valdate) {
    List<DataMapSchema> allDataMapSchemas = DataMapStoreManager.getInstance().getAllDataMapSchemas();
    DataMapSchema dataMapSchema = null;
    for (DataMapSchema schema : allDataMapSchemas) {
        if (schema.getDataMapName().equalsIgnoreCase(dataMapName)) {
            dataMapSchema = schema;
        }
    }
    if (dataMapSchema == null && valdate) {
        throw new UnsupportedOperationException("Cannot be disabled non exist datamap");
    } else {
        return dataMapSchema;
    }
}
Also used : DataMapSchema(org.apache.carbondata.core.metadata.schema.table.DataMapSchema)

Example 4 with DataMapSchema

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

the class DataMapStatusManager method disableDataMap.

public static void disableDataMap(String dataMapName) throws Exception {
    DataMapSchema dataMapSchema = validateDataMap(dataMapName, false);
    List<DataMapSchema> list = new ArrayList<>();
    if (dataMapSchema != null) {
        list.add(dataMapSchema);
    }
    storageProvider.updateDataMapStatus(list, DataMapStatus.DISABLED);
}
Also used : ArrayList(java.util.ArrayList) DataMapSchema(org.apache.carbondata.core.metadata.schema.table.DataMapSchema)

Example 5 with DataMapSchema

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

the class ThriftWrapperSchemaConverterImpl method fromExternalToWrapperDataMapSchema.

@Override
public DataMapSchema fromExternalToWrapperDataMapSchema(org.apache.carbondata.format.DataMapSchema thriftDataMapSchema) {
    DataMapSchema childSchema = new DataMapSchema(thriftDataMapSchema.getDataMapName(), thriftDataMapSchema.getClassName());
    childSchema.setProperties(thriftDataMapSchema.getProperties());
    if (null != thriftDataMapSchema.getChildTableIdentifier()) {
        RelationIdentifier relationIdentifier = new RelationIdentifier(thriftDataMapSchema.getChildTableIdentifier().getDatabaseName(), thriftDataMapSchema.getChildTableIdentifier().getTableName(), thriftDataMapSchema.getChildTableIdentifier().getTableId());
        childSchema.setRelationIdentifier(relationIdentifier);
        childSchema.setChildSchema(fromExternalToWrapperTableSchema(thriftDataMapSchema.getChildTableSchema(), relationIdentifier.getTableName()));
    }
    return childSchema;
}
Also used : DataMapSchema(org.apache.carbondata.core.metadata.schema.table.DataMapSchema) RelationIdentifier(org.apache.carbondata.core.metadata.schema.table.RelationIdentifier)

Aggregations

DataMapSchema (org.apache.carbondata.core.metadata.schema.table.DataMapSchema)11 ArrayList (java.util.ArrayList)8 RelationIdentifier (org.apache.carbondata.core.metadata.schema.table.RelationIdentifier)4 IOException (java.io.IOException)1 ICarbonLock (org.apache.carbondata.core.locks.ICarbonLock)1 AggregationDataMapSchema (org.apache.carbondata.core.metadata.schema.table.AggregationDataMapSchema)1 DataMapSchemaStorageProvider (org.apache.carbondata.core.metadata.schema.table.DataMapSchemaStorageProvider)1 DiskBasedDMSchemaStorageProvider (org.apache.carbondata.core.metadata.schema.table.DiskBasedDMSchemaStorageProvider)1 ColumnSchema (org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)1