Search in sources :

Example 1 with IndexSchema

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);
}
Also used : TableSchema(org.apache.carbondata.core.metadata.schema.table.TableSchema) TableBlockIndexUniqueIdentifierWrapper(org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifierWrapper) TableBlockIndexUniqueIdentifier(org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifier) TableInfo(org.apache.carbondata.core.metadata.schema.table.TableInfo) MockUp(mockit.MockUp) IndexSchema(org.apache.carbondata.core.metadata.schema.table.IndexSchema) Before(org.junit.Before)

Example 2 with IndexSchema

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;
}
Also used : ArrayList(java.util.ArrayList) IndexSchema(org.apache.carbondata.core.metadata.schema.table.IndexSchema) HashMap(java.util.HashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 3 with IndexSchema

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;
}
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

IndexSchema (org.apache.carbondata.core.metadata.schema.table.IndexSchema)3 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 MockUp (mockit.MockUp)1 MetadataProcessException (org.apache.carbondata.common.exceptions.MetadataProcessException)1 TableBlockIndexUniqueIdentifier (org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifier)1 TableBlockIndexUniqueIdentifierWrapper (org.apache.carbondata.core.indexstore.TableBlockIndexUniqueIdentifierWrapper)1 CarbonTable (org.apache.carbondata.core.metadata.schema.table.CarbonTable)1 TableInfo (org.apache.carbondata.core.metadata.schema.table.TableInfo)1 TableSchema (org.apache.carbondata.core.metadata.schema.table.TableSchema)1 Before (org.junit.Before)1