ForwardDictionaryCache extends AbstractDictionaryCache<K, V> { @Override public Dictionary get(DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier) throws CarbonUtilException { return getDictionary(dictionaryColumnUniqueIdentifier); } ForwardDictionaryCache(String carbonStorePath, CarbonLRUCache carbonLRUCache); @Override Dictionary get(DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier); @Override List<Dictionary> getAll(
      List<DictionaryColumnUniqueIdentifier> dictionaryColumnUniqueIdentifiers); @Override Dictionary getIfPresent(
      DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier); @Override void invalidate(
      DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier);  }
@Test public void get() throws Exception { deleteStorePath(); String columnIdentifier = columnIdentifiers[0]; prepareWriterAndWriteData(dataSet1, columnIdentifier); writeSortIndexFile(dataSet1, columnIdentifier); DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier = createDictionaryColumnUniqueIdentifier(columnIdentifier); Dictionary forwardDictionary = (Dictionary) forwardDictionaryCache.get(dictionaryColumnUniqueIdentifier); assertTrue(null != forwardDictionary); compareSurrogateKeyData(dataSet1, forwardDictionary); forwardDictionary.clear(); removeKeyFromLRUCache(forwardDictionaryCache); }
@Test public void testMultipleDictionaryChunks() throws Exception { deleteStorePath(); String columnIdentifier = columnIdentifiers[0]; prepareWriterAndWriteData(dataSet1, columnIdentifier); writeSortIndexFile(dataSet1, columnIdentifier); DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier = createDictionaryColumnUniqueIdentifier(columnIdentifier); Dictionary forwardDictionary = (Dictionary) forwardDictionaryCache.get(dictionaryColumnUniqueIdentifier); assertTrue(null != forwardDictionary); prepareWriterAndWriteData(dataSet2, columnIdentifier); List<String> allDictionaryChunkList = new ArrayList<>(6); allDictionaryChunkList.addAll(dataSet1); allDictionaryChunkList.addAll(dataSet2); writeSortIndexFile(allDictionaryChunkList, columnIdentifier); forwardDictionary = (Dictionary) forwardDictionaryCache.get(dictionaryColumnUniqueIdentifier); assertTrue(null != forwardDictionary); List<String> expected = new ArrayList<>(2); expected.addAll(dataSet1); expected.addAll(dataSet2); compareSurrogateKeyData(expected, forwardDictionary); forwardDictionary.clear(); removeKeyFromLRUCache(forwardDictionaryCache); }
@Test public void testSortedAndInvertedSortIndex() throws Exception { deleteStorePath(); String columnIdentifier = columnIdentifiers[0]; prepareWriterAndWriteData(dataSet3, columnIdentifier); writeSortIndexFile(dataSet3, columnIdentifier); DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier = createDictionaryColumnUniqueIdentifier(columnIdentifier); Dictionary forwardDictionary = (Dictionary) forwardDictionaryCache.get(dictionaryColumnUniqueIdentifier); assertTrue(null != forwardDictionary); compareSurrogateKeyData(dataSet3, forwardDictionary); compareDictionaryValueFromSortedIndex(dataSet3, forwardDictionary); forwardDictionary.clear(); removeKeyFromLRUCache(forwardDictionaryCache); }