/** * This method will check and create columnDictionaryInfo object for the given column * * @param dictionaryColumnUniqueIdentifier * @param columnIdentifier * @return */ private ColumnDictionaryInfo getColumnDictionaryInfo( DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier, String columnIdentifier) { ColumnDictionaryInfo columnDictionaryInfo = (ColumnDictionaryInfo) carbonLRUCache .get(getLruCacheKey(columnIdentifier, CacheType.FORWARD_DICTIONARY)); if (null == columnDictionaryInfo) { synchronized (dictionaryColumnUniqueIdentifier) { columnDictionaryInfo = (ColumnDictionaryInfo) carbonLRUCache .get(getLruCacheKey(columnIdentifier, CacheType.FORWARD_DICTIONARY)); if (null == columnDictionaryInfo) { columnDictionaryInfo = new ColumnDictionaryInfo(dictionaryColumnUniqueIdentifier.getDataType()); } } } return columnDictionaryInfo; }
/** * This method will get the value for the given key. If value does not exist * for the given key, it will check and load the value. * * @param dictionaryColumnUniqueIdentifier unique identifier which contains dbName, * tableName and columnIdentifier * @return dictionary * @throws IOException in case memory is not sufficient to load dictionary into memory */ private Dictionary getDictionary( DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier) throws IOException { Dictionary forwardDictionary = null; // dictionary is only for primitive data type assert (!dictionaryColumnUniqueIdentifier.getDataType().isComplexType()); String columnIdentifier = dictionaryColumnUniqueIdentifier.getColumnIdentifier().getColumnId(); ColumnDictionaryInfo columnDictionaryInfo = getColumnDictionaryInfo(dictionaryColumnUniqueIdentifier, columnIdentifier); // load sort index file in case of forward dictionary checkAndLoadDictionaryData(dictionaryColumnUniqueIdentifier, columnDictionaryInfo, getLruCacheKey(dictionaryColumnUniqueIdentifier.getColumnIdentifier().getColumnId(), CacheType.FORWARD_DICTIONARY), true); forwardDictionary = new ForwardDictionary(columnDictionaryInfo); return forwardDictionary; }
/** * This method will get the value for the given key. If value does not exist * for the given key, it will check and load the value. * * @param dictionaryColumnUniqueIdentifier unique identifier which contains dbName, * tableName and columnIdentifier * @return dictionary * @throws IOException in case memory is not sufficient to load dictionary into memory */ private Dictionary getDictionary( DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier) throws IOException { Dictionary reverseDictionary = null; // dictionary is only for primitive data type assert (!dictionaryColumnUniqueIdentifier.getDataType().isComplexType()); String columnIdentifier = dictionaryColumnUniqueIdentifier.getColumnIdentifier().getColumnId(); ColumnReverseDictionaryInfo columnReverseDictionaryInfo = getColumnReverseDictionaryInfo(dictionaryColumnUniqueIdentifier, columnIdentifier); // do not load sort index file for reverse dictionary checkAndLoadDictionaryData(dictionaryColumnUniqueIdentifier, columnReverseDictionaryInfo, getLruCacheKey(dictionaryColumnUniqueIdentifier.getColumnIdentifier().getColumnId(), CacheType.REVERSE_DICTIONARY), false); reverseDictionary = new ReverseDictionary(columnReverseDictionaryInfo); return reverseDictionary; }