use of org.apache.carbondata.core.datamap.dev.DataMapFactory in project carbondata by apache.
the class DataMapWriterListener method registerAllWriter.
/**
* register all datamap writer for specified table and segment
*/
public void registerAllWriter(CarbonTable carbonTable, String segmentId, String dataWritePath) {
List<TableDataMap> tableIndices = DataMapStoreManager.getInstance().getAllDataMap(carbonTable);
if (tableIndices != null) {
for (TableDataMap tableDataMap : tableIndices) {
DataMapFactory factory = tableDataMap.getDataMapFactory();
register(factory, segmentId, dataWritePath);
}
}
}
use of org.apache.carbondata.core.datamap.dev.DataMapFactory 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);
}
use of org.apache.carbondata.core.datamap.dev.DataMapFactory in project carbondata by apache.
the class IndexDataMapProvider method initMeta.
@Override
public void initMeta(CarbonTable mainTable, DataMapSchema dataMapSchema, String ctasSqlStatement) throws MalformedDataMapCommandException, IOException {
if (mainTable == null) {
throw new MalformedDataMapCommandException("Parent table is required to create index datamap");
}
ArrayList<RelationIdentifier> relationIdentifiers = new ArrayList<>();
dataMapSchema.setParentTables(relationIdentifiers);
relationIdentifiers.add(new RelationIdentifier(mainTable.getDatabaseName(), mainTable.getTableName(), mainTable.getTableInfo().getFactTable().getTableId()));
DataMapFactory dataMapFactory = createIndexDataMapFactory(dataMapSchema);
DataMapStoreManager.getInstance().registerDataMap(mainTable, dataMapSchema, dataMapFactory);
storageProvider.saveSchema(dataMapSchema);
}
use of org.apache.carbondata.core.datamap.dev.DataMapFactory 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;
}
use of org.apache.carbondata.core.datamap.dev.DataMapFactory 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;
}
Aggregations