Search in sources :

Example 1 with MetadataProcessException

use of org.apache.carbondata.common.exceptions.MetadataProcessException in project carbondata by apache.

the class IndexRegistry method getIndexFactoryByShortName.

public static IndexFactory<? extends Index> getIndexFactoryByShortName(CarbonTable table, IndexSchema indexSchema) throws MalformedIndexCommandException {
    String providerName = indexSchema.getProviderName();
    try {
        registerIndex(IndexType.get(providerName).getClassName(), IndexType.get(providerName).getIndexProviderName());
    } catch (UnsupportedOperationException ex) {
        throw new MalformedIndexCommandException("Index '" + providerName + "' not found", ex);
    }
    IndexFactory<? extends Index> indexFactory;
    String className = getIndexClassName(providerName.toLowerCase());
    if (className != null) {
        try {
            indexFactory = (IndexFactory<? extends Index>) Class.forName(className).getConstructors()[0].newInstance(table, indexSchema);
        } catch (ClassNotFoundException ex) {
            throw new MalformedIndexCommandException("Index '" + providerName + "' not found", ex);
        } catch (InvocationTargetException ex) {
            throw new MalformedIndexCommandException(ex.getTargetException().getMessage());
        } catch (InstantiationException | IllegalAccessException | IllegalArgumentException ex) {
            throw new MetadataProcessException("failed to create Index '" + providerName + "': " + ex.getMessage(), ex);
        }
    } else {
        throw new MalformedIndexCommandException("Index '" + providerName + "' not found");
    }
    return indexFactory;
}
Also used : MalformedIndexCommandException(org.apache.carbondata.common.exceptions.sql.MalformedIndexCommandException) MetadataProcessException(org.apache.carbondata.common.exceptions.MetadataProcessException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 2 with MetadataProcessException

use of org.apache.carbondata.common.exceptions.MetadataProcessException in project carbondata by apache.

the class DataMapStoreManager method createAndRegisterDataMap.

/**
 * Return a new datamap instance and registered in the store manager.
 * The datamap is created using datamap name, datamap factory class and table identifier.
 */
// TODO: make it private
public TableDataMap createAndRegisterDataMap(CarbonTable table, DataMapSchema dataMapSchema) throws MalformedDataMapCommandException, IOException {
    DataMapFactory dataMapFactory;
    try {
        // try to create datamap by reflection to test whether it is a valid DataMapFactory class
        Class<? extends DataMapFactory> factoryClass = (Class<? extends DataMapFactory>) Class.forName(dataMapSchema.getProviderName());
        dataMapFactory = factoryClass.newInstance();
    } catch (ClassNotFoundException e) {
        throw new MalformedDataMapCommandException("DataMap '" + dataMapSchema.getProviderName() + "' not found");
    } catch (Throwable e) {
        throw new MetadataProcessException("failed to create DataMap '" + dataMapSchema.getProviderName() + "'", e);
    }
    return registerDataMap(table, dataMapSchema, dataMapFactory);
}
Also used : MetadataProcessException(org.apache.carbondata.common.exceptions.MetadataProcessException) MalformedDataMapCommandException(org.apache.carbondata.common.exceptions.sql.MalformedDataMapCommandException) BlockletDataMapFactory(org.apache.carbondata.core.indexstore.blockletindex.BlockletDataMapFactory) DataMapFactory(org.apache.carbondata.core.datamap.dev.DataMapFactory)

Example 3 with MetadataProcessException

use of org.apache.carbondata.common.exceptions.MetadataProcessException in project carbondata by apache.

the class IndexDataMapProvider method createIndexDataMapFactory.

private DataMapFactory createIndexDataMapFactory(DataMapSchema dataMapSchema) throws MalformedDataMapCommandException {
    DataMapFactory dataMapFactory;
    try {
        // try to create DataMapClassProvider instance by taking providerName as class name
        Class<? extends DataMapFactory> providerClass = (Class<? extends DataMapFactory>) Class.forName(dataMapSchema.getProviderName());
        dataMapFactory = providerClass.newInstance();
    } catch (ClassNotFoundException e) {
        // try to create DataMapClassProvider instance by taking providerName as short name
        dataMapFactory = getDataMapFactoryByShortName(dataMapSchema.getProviderName());
    } catch (Throwable e) {
        throw new MetadataProcessException("failed to create DataMapClassProvider '" + dataMapSchema.getProviderName() + "'", e);
    }
    return dataMapFactory;
}
Also used : MetadataProcessException(org.apache.carbondata.common.exceptions.MetadataProcessException) DataMapFactory(org.apache.carbondata.core.datamap.dev.DataMapFactory)

Example 4 with MetadataProcessException

use of org.apache.carbondata.common.exceptions.MetadataProcessException in project carbondata by apache.

the class IndexDataMapProvider method getDataMapFactoryByShortName.

private DataMapFactory getDataMapFactoryByShortName(String providerName) throws MalformedDataMapCommandException {
    DataMapFactory dataMapFactory;
    String className = DataMapRegistry.getDataMapClassName(providerName);
    if (className != null) {
        try {
            Class<? extends DataMapFactory> datamapClass = (Class<? extends DataMapFactory>) Class.forName(providerName);
            dataMapFactory = datamapClass.newInstance();
        } catch (ClassNotFoundException ex) {
            throw new MalformedDataMapCommandException("DataMap '" + providerName + "' not found", ex);
        } catch (Throwable ex) {
            throw new MetadataProcessException("failed to create DataMap '" + providerName + "'", ex);
        }
    } else {
        throw new MalformedDataMapCommandException("DataMap '" + providerName + "' not found");
    }
    return dataMapFactory;
}
Also used : MetadataProcessException(org.apache.carbondata.common.exceptions.MetadataProcessException) MalformedDataMapCommandException(org.apache.carbondata.common.exceptions.sql.MalformedDataMapCommandException) DataMapFactory(org.apache.carbondata.core.datamap.dev.DataMapFactory)

Example 5 with MetadataProcessException

use of org.apache.carbondata.common.exceptions.MetadataProcessException in project carbondata by apache.

the class IndexProvider method createIndexFactory.

private IndexFactory<? extends Index> createIndexFactory() throws MalformedIndexCommandException {
    CarbonTable mainTable = getMainTable();
    IndexSchema indexSchema = getIndexSchema();
    IndexFactory<? extends Index> indexFactory;
    try {
        // try to create IndexClassProvider instance by taking providerName as class name
        indexFactory = (IndexFactory<? extends Index>) Class.forName(indexSchema.getProviderName()).getConstructors()[0].newInstance(mainTable, indexSchema);
    } catch (ClassNotFoundException e) {
        // try to create IndexClassProvider instance by taking providerName as short name
        indexFactory = IndexRegistry.getIndexFactoryByShortName(mainTable, indexSchema);
    } catch (Throwable e) {
        throw new MetadataProcessException("failed to create IndexClassProvider '" + indexSchema.getProviderName() + "'", e);
    }
    return indexFactory;
}
Also used : CarbonTable(org.apache.carbondata.core.metadata.schema.table.CarbonTable) MetadataProcessException(org.apache.carbondata.common.exceptions.MetadataProcessException) IndexSchema(org.apache.carbondata.core.metadata.schema.table.IndexSchema)

Aggregations

MetadataProcessException (org.apache.carbondata.common.exceptions.MetadataProcessException)5 DataMapFactory (org.apache.carbondata.core.datamap.dev.DataMapFactory)3 MalformedDataMapCommandException (org.apache.carbondata.common.exceptions.sql.MalformedDataMapCommandException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 MalformedIndexCommandException (org.apache.carbondata.common.exceptions.sql.MalformedIndexCommandException)1 BlockletDataMapFactory (org.apache.carbondata.core.indexstore.blockletindex.BlockletDataMapFactory)1 CarbonTable (org.apache.carbondata.core.metadata.schema.table.CarbonTable)1 IndexSchema (org.apache.carbondata.core.metadata.schema.table.IndexSchema)1