Java Code Examples for com.google.common.cache.CacheLoader#from()
The following examples show how to use
com.google.common.cache.CacheLoader#from() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetadataFactoryImpl.java From Bats with Apache License 2.0 | 5 votes |
private static CacheLoader<Pair<Class<RelNode>, Class<Metadata>>, UnboundMetadata<Metadata>> loader(final RelMetadataProvider provider) { return CacheLoader.from(key -> { final UnboundMetadata<Metadata> function = provider.apply(key.left, key.right); // Return DUMMY, not null, so the cache knows to not ask again. return function != null ? function : DUMMY; }); }
Example 2
Source File: MetadataFactoryImpl.java From Quicksql with MIT License | 5 votes |
private static CacheLoader<Pair<Class<RelNode>, Class<Metadata>>, UnboundMetadata<Metadata>> loader(final RelMetadataProvider provider) { return CacheLoader.from(key -> { final UnboundMetadata<Metadata> function = provider.apply(key.left, key.right); // Return DUMMY, not null, so the cache knows to not ask again. return function != null ? function : DUMMY; }); }
Example 3
Source File: CachedSpecService.java From feast with Apache License 2.0 | 5 votes |
public CachedSpecService(CoreSpecService coreService, StoreProto.Store store) { this.coreService = coreService; this.store = coreService.registerStore(store); Map<String, FeatureSetSpec> featureSets = getFeatureSetMap(); featureToFeatureSetMapping = new ConcurrentHashMap<>(getFeatureToFeatureSetMapping(featureSets)); CacheLoader<String, FeatureSetSpec> featureSetCacheLoader = CacheLoader.from(featureSets::get); featureSetCache = CacheBuilder.newBuilder().maximumSize(MAX_SPEC_COUNT).build(featureSetCacheLoader); featureSetCache.putAll(featureSets); }
Example 4
Source File: CachedSimilarityMeasure.java From metanome-algorithms with Apache License 2.0 | 5 votes |
private LoadingCache<UnorderedPair<T>, Double> createCache() { CacheLoader<UnorderedPair<T>, Double> loader = CacheLoader .from(similarityMeasure::calculateSimilarity); return CacheBuilder.newBuilder() .maximumSize(maximumSize) .build(loader); }
Example 5
Source File: MetadataFactoryImpl.java From calcite with Apache License 2.0 | 5 votes |
private static CacheLoader<Pair<Class<RelNode>, Class<Metadata>>, UnboundMetadata<Metadata>> loader(final RelMetadataProvider provider) { return CacheLoader.from(key -> { final UnboundMetadata<Metadata> function = provider.apply(key.left, key.right); // Return DUMMY, not null, so the cache knows to not ask again. return function != null ? function : DUMMY; }); }
Example 6
Source File: CollectingThresholdMap.java From metanome-algorithms with Apache License 2.0 | 4 votes |
private LoadingCache<GreaterOrEqualCall, IntCollection> createCache() { CacheLoader<GreaterOrEqualCall, IntCollection> loader = CacheLoader .from(GreaterOrEqualCall::call); return CACHE_BUILDER.build(loader); }