/** * Return a new datamap instance and registered in the store manager. * The datamap is created using datamap name, datamap factory class and table identifier. */ public DataMapFactory getDataMapFactoryClass(CarbonTable table, DataMapSchema dataMapSchema) throws MalformedDataMapCommandException { try { // try to create datamap by reflection to test whether it is a valid DataMapFactory class return (DataMapFactory) Class.forName(dataMapSchema.getProviderName()).getConstructors()[0] .newInstance(table, dataMapSchema); } catch (ClassNotFoundException e) { // try to create DataMapClassProvider instance by taking providerName as short name return DataMapRegistry.getDataMapFactoryByShortName(table, dataMapSchema); } catch (Throwable e) { throw new MetadataProcessException( "failed to get DataMap factory for'" + dataMapSchema.getProviderName() + "'", e); } }
private DataMapFactory<? extends DataMap> createDataMapFactory() throws MalformedDataMapCommandException { CarbonTable mainTable = getMainTable(); DataMapSchema dataMapSchema = getDataMapSchema(); DataMapFactory<? extends DataMap> dataMapFactory; try { // try to create DataMapClassProvider instance by taking providerName as class name dataMapFactory = (DataMapFactory<? extends DataMap>) Class.forName(dataMapSchema.getProviderName()).getConstructors()[0] .newInstance(mainTable, dataMapSchema); } catch (ClassNotFoundException e) { // try to create DataMapClassProvider instance by taking providerName as short name dataMapFactory = DataMapRegistry.getDataMapFactoryByShortName(mainTable, dataMapSchema); } catch (Throwable e) { throw new MetadataProcessException( "failed to create DataMapClassProvider '" + dataMapSchema.getProviderName() + "'", e); } return dataMapFactory; }