/** * 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); } }
public static DataMapFactory<? extends DataMap> getDataMapFactoryByShortName( CarbonTable table, DataMapSchema dataMapSchema) throws MalformedDataMapCommandException { String providerName = dataMapSchema.getProviderName(); try { registerDataMap( DataMapClassProvider.getDataMapProviderOnName(providerName).getClassName(), DataMapClassProvider.getDataMapProviderOnName(providerName).getShortName()); } catch (UnsupportedOperationException ex) { throw new MalformedDataMapCommandException("DataMap '" + providerName + "' not found", ex); } DataMapFactory<? extends DataMap> dataMapFactory; String className = getDataMapClassName(providerName.toLowerCase()); if (className != null) { try { dataMapFactory = (DataMapFactory<? extends DataMap>) Class.forName(className).getConstructors()[0].newInstance(table, dataMapSchema); } catch (ClassNotFoundException ex) { throw new MalformedDataMapCommandException("DataMap '" + providerName + "' not found", ex); } catch (InvocationTargetException ex) { throw new MalformedDataMapCommandException(ex.getTargetException().getMessage()); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException ex) { throw new MetadataProcessException( "failed to create DataMap '" + providerName + "': " + ex.getMessage(), ex); } } else { throw new MalformedDataMapCommandException("DataMap '" + providerName + "' not found"); } return dataMapFactory; } }
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; }