/** * This method will remove the cache for a given key * * @param dictionaryColumnUniqueIdentifier unique identifier which contains dbName, * tableName and columnIdentifier */ @Override public void invalidate( DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier) { carbonLRUCache.remove( getLruCacheKey(dictionaryColumnUniqueIdentifier.getColumnIdentifier().getColumnId(), CacheType.FORWARD_DICTIONARY)); }
/** * 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; }
@Override public void clearAccessCount(List<DictionaryColumnUniqueIdentifier> keys) { for (DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier : keys) { Dictionary cacheable = (Dictionary) carbonLRUCache.get( getLruCacheKey(dictionaryColumnUniqueIdentifier.getColumnIdentifier().getColumnId(), CacheType.FORWARD_DICTIONARY)); cacheable.clear(); } }
/** * This method will return the value for the given key. It will not check and load * the data for the given key * * @param dictionaryColumnUniqueIdentifier unique identifier which contains dbName, * tableName and columnIdentifier * @return */ @Override public Dictionary getIfPresent( DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier) { Dictionary forwardDictionary = null; ColumnDictionaryInfo columnDictionaryInfo = (ColumnDictionaryInfo) carbonLRUCache.get( getLruCacheKey(dictionaryColumnUniqueIdentifier.getColumnIdentifier().getColumnId(), CacheType.FORWARD_DICTIONARY)); if (null != columnDictionaryInfo) { forwardDictionary = new ForwardDictionary(columnDictionaryInfo); incrementDictionaryAccessCount(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 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; }