public static CachingOptions fromMap(Map<String, String> cacheConfig) throws ConfigurationException { validateCacheConfig(cacheConfig); if (!cacheConfig.containsKey("keys") && !cacheConfig.containsKey("rows_per_partition")) return CachingOptions.NONE; if (!cacheConfig.containsKey("keys")) return new CachingOptions(new KeyCache(KeyCache.Type.NONE), RowCache.fromString(cacheConfig.get("rows_per_partition"))); if (!cacheConfig.containsKey("rows_per_partition")) return CachingOptions.KEYS_ONLY; return new CachingOptions(KeyCache.fromString(cacheConfig.get("keys")), RowCache.fromString(cacheConfig.get("rows_per_partition"))); }
public static CachingOptions fromThrift(String caching, String cellsPerRow) throws ConfigurationException { RowCache rc = new RowCache(RowCache.Type.NONE); KeyCache kc = new KeyCache(KeyCache.Type.ALL); // if we get a caching string from thrift it is legacy, "ALL", "KEYS_ONLY" etc, fromString handles those if (caching != null) { CachingOptions givenOptions = CachingOptions.fromString(caching); rc = givenOptions.rowCache; kc = givenOptions.keyCache; } // if we get cells_per_row from thrift, it is either "ALL" or "<number of cells to cache>". if (cellsPerRow != null && rc.isEnabled()) rc = RowCache.fromString(cellsPerRow); return new CachingOptions(kc, rc); }