use of org.apache.carbondata.core.metadata.schema.table.IndexSchema in project carbondata by apache.
the class TestBlockletIndexFactory method setUp.
@Before
public void setUp() throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, InstantiationException {
tableInfo = new TableInfo();
factTable = new TableSchema();
Constructor<?> constructor = Class.forName("org.apache.carbondata.core.metadata.schema.table.CarbonTable").getDeclaredConstructors()[0];
constructor.setAccessible(true);
carbonTable = (CarbonTable) constructor.newInstance();
absoluteTableIdentifier = AbsoluteTableIdentifier.from("/opt/store/default/carbon_table/", "default", "carbon_table", UUID.randomUUID().toString());
Deencapsulation.setField(tableInfo, "identifier", absoluteTableIdentifier);
Deencapsulation.setField(tableInfo, "factTable", factTable);
Deencapsulation.setField(carbonTable, "tableInfo", tableInfo);
new MockUp<CarbonTable>() {
@Mock
public AbsoluteTableIdentifier getAbsoluteTableIdentifier() {
return absoluteTableIdentifier;
}
};
blockletIndexFactory = new BlockletIndexFactory(carbonTable, new IndexSchema());
Deencapsulation.setField(blockletIndexFactory, "cache", CacheProvider.getInstance().createCache(CacheType.DRIVER_BLOCKLET_INDEX));
tableBlockIndexUniqueIdentifier = new TableBlockIndexUniqueIdentifier("/opt/store/default/carbon_table/Fact/Part0/Segment_0", "0_batchno0-0-1521012756709.carbonindex", null, "0");
tableBlockIndexUniqueIdentifierWrapper = new TableBlockIndexUniqueIdentifierWrapper(tableBlockIndexUniqueIdentifier, carbonTable);
cache = CacheProvider.getInstance().createCache(CacheType.DRIVER_BLOCKLET_INDEX);
}
use of org.apache.carbondata.core.metadata.schema.table.IndexSchema in project carbondata by apache.
the class IndexStoreManager method getAllCGAndFGIndexes.
/**
* Collect's Coarse grain and Fine grain indexes on a table
*
* @return
*/
public List<TableIndex> getAllCGAndFGIndexes(CarbonTable carbonTable) throws IOException {
List<TableIndex> indexes = new ArrayList<>();
// get bloom indexes and lucene indexes
for (Map.Entry<String, Map<String, Map<String, String>>> providerEntry : carbonTable.getIndexesMap().entrySet()) {
for (Map.Entry<String, Map<String, String>> indexEntry : providerEntry.getValue().entrySet()) {
IndexSchema indexSchema = new IndexSchema(indexEntry.getKey(), indexEntry.getValue().get(CarbonCommonConstants.INDEX_PROVIDER));
indexSchema.setProperties(indexEntry.getValue());
indexes.add(getIndex(carbonTable, indexSchema));
}
}
return indexes;
}
use of org.apache.carbondata.core.metadata.schema.table.IndexSchema 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;
}
Aggregations