TileDB
TileDB copied to clipboard
Add a function Evaluator class with policy based caching capabilities
https://github.com/TileDB-Inc/TileDB/pull/5215 for context and previous reviews. This work evolved into something a bit more generic than the tile offsets transparent cache we originally intended to write. This PR adds:
Evaluatorclass
Evaluator<Policy<Key, Value>, decltype(cb)> eval(cb);
val = eval(key);
// where
Value cb(const Key& key);
ImmediateEvaluationpolicy Configures the evaluator to executecb(key)for any invocation ofeval(key).
Evaluator<ImmediateEvaluation<Key, Value>, Callback> eval(cb);
eval(key); // equivalent with cb(key)
eval(key); // equivalent with cb(key)
MaxEntriesCachepolicy Configures the evaluator to executecb(key)and cache the results in a LRU cache that cannot hold more thanNvalues. Caching valueN+1triggers cache eviction.
Evaluator<MaxEntriesCache<Key, Value, N>, Callback> eval(cb);
MemoryBudgetedCachepolicy Configures the evaluator to executecb(key)and cache the results in a LRU cache with a capacity ofMbytes whereMis passed during the evaluator construction.
Evaluator<MemoryBudgetedCache<Key, Value>, Callback> eval(cb, SizeFn, memory_budget);
// where `SizeFn` is a user provided function that returns the size of its argument in bytes.
[sc-51496]
TYPE: FEATURE DESC: Add a function Evaluator class with policy based caching capabilities
Note: Table-driven tests increase coverage, but each case is run in parallel. The nature of this cache testing is that many of the tests rely on serial function calls. A rewrite may be worthwhile in the future, but is overly complicated for the scope of this PR.