Search in sources :

Example 1 with CarbonSessionInfo

use of org.apache.carbondata.core.util.CarbonSessionInfo in project carbondata by apache.

the class CarbonTable method getAllVisibleIndexes.

/**
 * It only gives the visible Indexes
 */
public List<TableIndex> getAllVisibleIndexes() throws IOException {
    CarbonSessionInfo sessionInfo = ThreadLocalSessionInfo.getCarbonSessionInfo();
    List<TableIndex> allIndexes = IndexStoreManager.getInstance().getAllCGAndFGIndexes(this);
    Iterator<TableIndex> indexIterator = allIndexes.iterator();
    while (indexIterator.hasNext()) {
        TableIndex index = indexIterator.next();
        String dbName = this.getDatabaseName();
        String tableName = this.getTableName();
        String indexName = index.getIndexSchema().getIndexName();
        // TODO: need support get the visible status of Index without sessionInfo in the future
        if (sessionInfo != null) {
            boolean isIndexVisible = sessionInfo.getSessionParams().getProperty(String.format("%s%s.%s.%s", CarbonCommonConstants.CARBON_INDEX_VISIBLE, dbName, tableName, indexName), "true").trim().equalsIgnoreCase("true");
            if (!isIndexVisible) {
                LOGGER.warn(String.format("Ignore invisible index %s on table %s.%s", indexName, dbName, tableName));
                indexIterator.remove();
            }
        } else {
            String message = "Carbon session info is null";
            LOGGER.info(message);
        }
    }
    return allIndexes;
}
Also used : TableIndex(org.apache.carbondata.core.index.TableIndex) CarbonSessionInfo(org.apache.carbondata.core.util.CarbonSessionInfo)

Aggregations

TableIndex (org.apache.carbondata.core.index.TableIndex)1 CarbonSessionInfo (org.apache.carbondata.core.util.CarbonSessionInfo)1