/** * This method will return the value for the given key. It will not check and load * the data for the given key * * @param key * @return */ public V getIfPresent(K key) { V value = cache.getIfPresent(key); if (value != null) { segmentSet.add(key); } return value; }
@Override public List<DataMapDistributable> getAllUncachedDistributables( List<DataMapDistributable> distributables) throws IOException { List<DataMapDistributable> distributablesToBeLoaded = new ArrayList<>(distributables.size()); for (DataMapDistributable distributable : distributables) { Segment segment = distributable.getSegment(); Set<TableBlockIndexUniqueIdentifier> tableBlockIndexUniqueIdentifiers = getTableBlockIndexUniqueIdentifiers(segment); // filter out the tableBlockIndexUniqueIdentifiers based on distributable TableBlockIndexUniqueIdentifier validIdentifier = BlockletDataMapUtil .filterIdentifiersBasedOnDistributable(tableBlockIndexUniqueIdentifiers, (BlockletDataMapDistributable) distributable); if (null == cache.getIfPresent( new TableBlockIndexUniqueIdentifierWrapper(validIdentifier, this.getCarbonTable()))) { ((BlockletDataMapDistributable) distributable) .setTableBlockIndexUniqueIdentifier(validIdentifier); distributablesToBeLoaded.add(distributable); } } return distributablesToBeLoaded; } }
@Override public void clear(Segment segment) { Set<TableBlockIndexUniqueIdentifier> blockIndexes = segmentMap.remove(segment.getSegmentNo()); if (blockIndexes != null) { for (TableBlockIndexUniqueIdentifier blockIndex : blockIndexes) { TableBlockIndexUniqueIdentifierWrapper blockIndexWrapper = new TableBlockIndexUniqueIdentifierWrapper(blockIndex, this.getCarbonTable()); BlockletDataMapIndexWrapper wrapper = cache.getIfPresent(blockIndexWrapper); if (null != wrapper) { List<BlockDataMap> dataMaps = wrapper.getDataMaps(); for (DataMap dataMap : dataMaps) { if (dataMap != null) { cache.invalidate(blockIndexWrapper); dataMap.clear(); } } } } } }