Skip to content

Commit 83e1419

Browse files
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

5 files changed

+913
-1
lines changed

tiledb/common/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# The MIT License
55
#
6-
# Copyright (c) 2021-2022 TileDB, Inc.
6+
# Copyright (c) 2021-2024 TileDB, Inc.
77
#
88
# Permission is hereby granted, free of charge, to any person obtaining a copy
99
# of this software and associated documentation files (the "Software"), to deal
@@ -40,6 +40,7 @@ endif()
4040
# Subdirectories
4141
#
4242
add_subdirectory(dynamic_memory)
43+
add_subdirectory(evaluator)
4344
add_subdirectory(exception)
4445
add_subdirectory(governor)
4546
add_subdirectory(interval)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#
2+
# tiledb/common/evaluator/CMakeLists.txt
3+
#
4+
# The MIT License
5+
#
6+
# Copyright (c) 2024 TileDB, Inc.
7+
#
8+
# Permission is hereby granted, free of charge, to any person obtaining a copy
9+
# of this software and associated documentation files (the "Software"), to deal
10+
# in the Software without restriction, including without limitation the rights
11+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
# copies of the Software, and to permit persons to whom the Software is
13+
# furnished to do so, subject to the following conditions:
14+
#
15+
# The above copyright notice and this permission notice shall be included in
16+
# all copies or substantial portions of the Software.
17+
#
18+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
# THE SOFTWARE.
25+
#
26+
27+
# This is a header-only component, an object library is not needed
28+
29+
include(common NO_POLICY_SCOPE)
30+
31+
add_test_subdirectory()

0 commit comments

Comments
 (0)