private RowIndexEntry getCachedPosition(KeyCacheKey unifiedKey, boolean updateStats) { if (keyCache != null && keyCache.getCapacity() > 0 && metadata.getCaching().keyCache.isEnabled()) { if (updateStats) { RowIndexEntry cachedEntry = keyCache.get(unifiedKey); keyCacheRequest.incrementAndGet(); if (cachedEntry != null) { keyCacheHit.incrementAndGet(); bloomFilterTracker.addTruePositive(); } return cachedEntry; } else { return keyCache.getInternal(unifiedKey); } } return null; }
public void cacheKey(DecoratedKey key, RowIndexEntry info) { CachingOptions caching = metadata.getCaching(); if (!caching.keyCache.isEnabled() || keyCache == null || keyCache.getCapacity() == 0) { return; } KeyCacheKey cacheKey = new KeyCacheKey(metadata.ksAndCFName, descriptor, key.getKey()); logger.trace("Adding cache entry for {} -> {}", cacheKey, info); keyCache.put(cacheKey, info); }
/** * Creates CFMetaData for secondary index CF. * Secondary index CF has the same CF ID as parent's. * * @param parent Parent CF where secondary index is created * @param info Column definition containing secondary index definition * @param indexComparator Comparator for secondary index * @return CFMetaData for secondary index */ public static CFMetaData newIndexMetadata(CFMetaData parent, ColumnDefinition info, CellNameType indexComparator) { // Depends on parent's cache setting, turn on its index CF's cache. // Row caching is never enabled; see CASSANDRA-5732 CachingOptions indexCaching = parent.getCaching().keyCache.isEnabled() ? CachingOptions.KEYS_ONLY : CachingOptions.NONE; return new CFMetaData(parent.ksName, parent.indexColumnFamilyName(info), ColumnFamilyType.Standard, indexComparator, parent.cfId) .keyValidator(info.type) .readRepairChance(0.0) .dcLocalReadRepairChance(0.0) .gcGraceSeconds(0) .caching(indexCaching) .speculativeRetry(parent.speculativeRetry) .compactionStrategyClass(parent.compactionStrategyClass) .compactionStrategyOptions(parent.compactionStrategyOptions) .reloadSecondaryIndexMetadata(parent) .rebuild(); }
public boolean isKeyCacheEnabled() { return metadata.getCaching().keyCache.isEnabled() && CacheService.instance.keyCache.getCapacity() > 0; }