Interface FeatureCalculationCache<T extends FeatureInput>
- Type Parameters:
T
- feature-input
When a user calculates a a single feature, they often are calculating other features at the same time (on one or more objects). This creates possibilities for various different forms of caching of results, and different initialization strategies.
This class represents one such bunch of calculations. Different implementations provide different strategies.
Each calculation-cache may contain "child" caches for particular string identifiers. This provides a hierarchy of caches and sub-caches as many features change the underlying objects that are being calculated, and need separate space in the cache.
A call to {invalidate()
removes any existing caching (also in the children) and
guarantees the next calculation will be fresh.
- Author:
- Owen Feehan
-
Method Summary
Modifier and TypeMethodDescriptionA means of calculating feature values using this cache.<V extends FeatureInput>
FeatureCalculationCache<V> childCacheFor
(ChildCacheName childName, Class<? extends FeatureInput> inputType, CacheCreator cacheCreator) Gets/creates a child-cache for a given name.void
initialize
(FeatureInitialization initialization, Logger logger) Initializes the cache.void
Invalidates existing caches so the next calculation occurs freshly.void
invalidateExcept
(Set<ChildCacheName> childCacheNames) Invalidates existing caches so the next calculations occur freshly - except some particular child-caches who are not invalidated.
-
Method Details
-
initialize
Initializes the cache. Should always be called once before any calculations occur- Parameters:
initialization
- initialization for the feature.logger
- logger
-
invalidate
void invalidate()Invalidates existing caches so the next calculation occurs freshly. -
invalidateExcept
Invalidates existing caches so the next calculations occur freshly - except some particular child-caches who are not invalidated.- Parameters:
childCacheNames
- the names of the child-caches who are not invalidated.
-
calculator
FeatureCalculator<T> calculator()A means of calculating feature values using this cache.- Returns:
- a
FeatureCalculator
bound to this instance.
-
childCacheFor
<V extends FeatureInput> FeatureCalculationCache<V> childCacheFor(ChildCacheName childName, Class<? extends FeatureInput> inputType, CacheCreator cacheCreator) Gets/creates a child-cache for a given name.This function trusts the caller to use the correct type for the child-cache.
- Type Parameters:
V
- parameters-type of the child cache to found- Parameters:
childName
- name of the child-cache.inputType
- the type ofV
.cacheCreator
- factory for creating a cache.- Returns:
- the existing or new child cache of the given name.
-