Commit 83e1419
Add a function Evaluator class with policy based caching capabilities (#5253)
#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:
- `Evaluator` class
```c++
Evaluator<Policy<Key, Value>, decltype(cb)> eval(cb);
val = eval(key);
// where
Value cb(const Key& key);
```
- `ImmediateEvaluation` policy
Configures the evaluator to execute `cb(key)` for any invocation of
`eval(key)`.
```c++
Evaluator<ImmediateEvaluation<Key, Value>, Callback> eval(cb);
eval(key); // equivalent with cb(key)
eval(key); // equivalent with cb(key)
```
- `MaxEntriesCache` policy
Configures the evaluator to execute `cb(key)` and cache the results in a
LRU cache
that cannot hold more than `N` values. Caching value `N+1` triggers
cache eviction.
```c++
Evaluator<MaxEntriesCache<Key, Value, N>, Callback> eval(cb);
```
- `MemoryBudgetedCache` policy
Configures the evaluator to execute `cb(key)` and cache the results in a
LRU cache
with a capacity of `M` bytes where `M` is passed during the evaluator
construction.
```c++
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
---------
Co-authored-by: Rebekah Davis <[email protected]>1 parent 4afbe56 commit 83e1419
File tree
5 files changed
+913
-1
lines changed- tiledb/common
- evaluator
- test
5 files changed
+913
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
0 commit comments