Search in sources :

Example 21 with DictionaryColumnUniqueIdentifier

use of org.apache.carbondata.core.cache.dictionary.DictionaryColumnUniqueIdentifier in project carbondata by apache.

the class CarbonDictionaryReaderImplTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    columnIdentifier = new ColumnIdentifier("1", null, null);
    absoluteTableIdentifier = AbsoluteTableIdentifier.from("tablePath", new CarbonTableIdentifier("dbName", "tableName", UUID.randomUUID().toString()));
    DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier = new DictionaryColumnUniqueIdentifier(absoluteTableIdentifier, columnIdentifier, columnIdentifier.getDataType());
    carbonDictionaryReaderImpl = new CarbonDictionaryReaderImpl(dictionaryColumnUniqueIdentifier);
}
Also used : DictionaryColumnUniqueIdentifier(org.apache.carbondata.core.cache.dictionary.DictionaryColumnUniqueIdentifier) CarbonTableIdentifier(org.apache.carbondata.core.metadata.CarbonTableIdentifier) ColumnIdentifier(org.apache.carbondata.core.metadata.ColumnIdentifier) BeforeClass(org.junit.BeforeClass)

Example 22 with DictionaryColumnUniqueIdentifier

use of org.apache.carbondata.core.cache.dictionary.DictionaryColumnUniqueIdentifier in project carbondata by apache.

the class QueryUtil method getDictionaryMap.

/**
 * Below method will be used to get the column id to its dictionary mapping
 *
 * @param dictionaryColumnIdList  dictionary column list
 * @param absoluteTableIdentifier absolute table identifier
 * @return dictionary mapping
 * @throws IOException
 */
private static Map<String, Dictionary> getDictionaryMap(List<String> dictionaryColumnIdList, AbsoluteTableIdentifier absoluteTableIdentifier, TableProvider tableProvider) throws IOException {
    // if any complex dimension not present in query then return the empty map
    if (dictionaryColumnIdList.size() == 0) {
        return new HashMap<>();
    }
    // this for dictionary unique identifier
    List<DictionaryColumnUniqueIdentifier> dictionaryColumnUniqueIdentifiers = getDictionaryColumnUniqueIdentifierList(dictionaryColumnIdList, absoluteTableIdentifier.getCarbonTableIdentifier(), tableProvider);
    CacheProvider cacheProvider = CacheProvider.getInstance();
    Cache<DictionaryColumnUniqueIdentifier, Dictionary> forwardDictionaryCache = cacheProvider.createCache(CacheType.FORWARD_DICTIONARY);
    List<Dictionary> columnDictionaryList = forwardDictionaryCache.getAll(dictionaryColumnUniqueIdentifiers);
    Map<String, Dictionary> columnDictionaryMap = new HashMap<>(columnDictionaryList.size());
    for (int i = 0; i < dictionaryColumnUniqueIdentifiers.size(); i++) {
        // TODO: null check for column dictionary, if cache size is less it
        // might return null here, in that case throw exception
        columnDictionaryMap.put(dictionaryColumnUniqueIdentifiers.get(i).getColumnIdentifier().getColumnId(), columnDictionaryList.get(i));
    }
    return columnDictionaryMap;
}
Also used : Dictionary(org.apache.carbondata.core.cache.dictionary.Dictionary) DictionaryColumnUniqueIdentifier(org.apache.carbondata.core.cache.dictionary.DictionaryColumnUniqueIdentifier) HashMap(java.util.HashMap) CacheProvider(org.apache.carbondata.core.cache.CacheProvider)

Aggregations

DictionaryColumnUniqueIdentifier (org.apache.carbondata.core.cache.dictionary.DictionaryColumnUniqueIdentifier)22 Dictionary (org.apache.carbondata.core.cache.dictionary.Dictionary)14 ColumnIdentifier (org.apache.carbondata.core.metadata.ColumnIdentifier)11 CacheProvider (org.apache.carbondata.core.cache.CacheProvider)7 CarbonDimension (org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)6 CarbonDictionaryWriter (org.apache.carbondata.core.writer.CarbonDictionaryWriter)6 ArrayList (java.util.ArrayList)5 CarbonTableIdentifier (org.apache.carbondata.core.metadata.CarbonTableIdentifier)5 CarbonDictionaryWriterImpl (org.apache.carbondata.core.writer.CarbonDictionaryWriterImpl)5 CarbonDictionarySortIndexWriter (org.apache.carbondata.core.writer.sortindex.CarbonDictionarySortIndexWriter)5 CarbonTable (org.apache.carbondata.core.metadata.schema.table.CarbonTable)4 CarbonDictionarySortIndexWriterImpl (org.apache.carbondata.core.writer.sortindex.CarbonDictionarySortIndexWriterImpl)4 CarbonDictionarySortInfo (org.apache.carbondata.core.writer.sortindex.CarbonDictionarySortInfo)4 CarbonDictionarySortInfoPreparator (org.apache.carbondata.core.writer.sortindex.CarbonDictionarySortInfoPreparator)4 BufferedReader (java.io.BufferedReader)3 HashSet (java.util.HashSet)3 Set (java.util.Set)3 Cache (org.apache.carbondata.core.cache.Cache)3 AbsoluteTableIdentifier (org.apache.carbondata.core.metadata.AbsoluteTableIdentifier)3 FileReader (java.io.FileReader)2