small-cache 0.0.2__tar.gz → 0.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {small_cache-0.0.2 → small_cache-0.0.3}/.github/workflows/pip.yml +1 -1
- {small_cache-0.0.2 → small_cache-0.0.3}/.github/workflows/wheels.yml +3 -3
- {small_cache-0.0.2 → small_cache-0.0.3}/CMakeLists.txt +5 -5
- {small_cache-0.0.2 → small_cache-0.0.3}/PKG-INFO +1 -1
- {small_cache-0.0.2 → small_cache-0.0.3}/pyproject.toml +1 -1
- {small_cache-0.0.2 → small_cache-0.0.3}/src/small_cache.cpp +24 -16
- {small_cache-0.0.2 → small_cache-0.0.3}/.github/dependabot.yml +0 -0
- {small_cache-0.0.2 → small_cache-0.0.3}/.gitignore +0 -0
- {small_cache-0.0.2 → small_cache-0.0.3}/README.md +0 -0
- {small_cache-0.0.2 → small_cache-0.0.3}/src/small_cache/__init__.py +0 -0
- {small_cache-0.0.2 → small_cache-0.0.3}/tests/test_basic.py +0 -0
|
@@ -11,7 +11,7 @@ jobs:
|
|
|
11
11
|
name: Build SDist
|
|
12
12
|
runs-on: ubuntu-latest
|
|
13
13
|
steps:
|
|
14
|
-
- uses: actions/checkout@
|
|
14
|
+
- uses: actions/checkout@v6
|
|
15
15
|
with:
|
|
16
16
|
submodules: true
|
|
17
17
|
|
|
@@ -36,11 +36,11 @@ jobs:
|
|
|
36
36
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
37
37
|
|
|
38
38
|
steps:
|
|
39
|
-
- uses: actions/checkout@
|
|
39
|
+
- uses: actions/checkout@v6
|
|
40
40
|
with:
|
|
41
41
|
submodules: true
|
|
42
42
|
|
|
43
|
-
- uses: pypa/cibuildwheel@v3.
|
|
43
|
+
- uses: pypa/cibuildwheel@v3.3
|
|
44
44
|
|
|
45
45
|
- name: Verify clean directory
|
|
46
46
|
run: git diff --exit-code
|
|
@@ -66,7 +66,7 @@ include(FetchContent)
|
|
|
66
66
|
FetchContent_Declare(
|
|
67
67
|
glaze
|
|
68
68
|
GIT_REPOSITORY https://github.com/stephenberry/glaze.git
|
|
69
|
-
GIT_TAG
|
|
69
|
+
GIT_TAG v6.1.0
|
|
70
70
|
GIT_SHALLOW TRUE
|
|
71
71
|
)
|
|
72
72
|
|
|
@@ -75,7 +75,7 @@ FetchContent_MakeAvailable(glaze)
|
|
|
75
75
|
FetchContent_Declare(
|
|
76
76
|
tsl_sparse_map
|
|
77
77
|
GIT_REPOSITORY https://github.com/Tessil/sparse-map
|
|
78
|
-
GIT_TAG
|
|
78
|
+
GIT_TAG v0.7.0
|
|
79
79
|
GIT_SHALLOW TRUE
|
|
80
80
|
)
|
|
81
81
|
FetchContent_MakeAvailable(tsl_sparse_map)
|
|
@@ -83,7 +83,7 @@ FetchContent_MakeAvailable(tsl_sparse_map)
|
|
|
83
83
|
FetchContent_Declare(
|
|
84
84
|
absl
|
|
85
85
|
GIT_REPOSITORY https://github.com/abseil/abseil-cpp.git
|
|
86
|
-
GIT_TAG
|
|
86
|
+
GIT_TAG 20250814.1
|
|
87
87
|
GIT_SHALLOW TRUE
|
|
88
88
|
OVERRIDE_FIND_PACKAGE TRUE
|
|
89
89
|
EXCLUDE_FROM_ALL
|
|
@@ -92,14 +92,14 @@ FetchContent_Declare(
|
|
|
92
92
|
find_package(
|
|
93
93
|
absl
|
|
94
94
|
REQUIRED
|
|
95
|
-
COMPONENTS flat_hash_map hash
|
|
95
|
+
COMPONENTS flat_hash_map flat_hash_set hash
|
|
96
96
|
)
|
|
97
97
|
|
|
98
98
|
Set(FETCHCONTENT_QUIET FALSE)
|
|
99
99
|
FetchContent_Declare(
|
|
100
100
|
Boost
|
|
101
101
|
URL https://github.com/boostorg/boost/releases/download/boost-1.88.0/boost-1.88.0-cmake.7z
|
|
102
|
-
GIT_TAG "boost-1.
|
|
102
|
+
GIT_TAG "boost-1.89.0"
|
|
103
103
|
USES_TERMINAL_DOWNLOAD TRUE
|
|
104
104
|
GIT_PROGRESS TRUE
|
|
105
105
|
DOWNLOAD_NO_EXTRACT FALSE
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
#include <tsl/sparse_map.h>
|
|
9
9
|
#include <absl/hash/hash.h>
|
|
10
10
|
#include <absl/container/flat_hash_map.h>
|
|
11
|
+
#include <absl/container/flat_hash_set.h>
|
|
11
12
|
#include <boost/flyweight.hpp>
|
|
12
13
|
#include <optional>
|
|
13
14
|
#include <algorithm>
|
|
@@ -295,7 +296,7 @@ public:
|
|
|
295
296
|
increaseIteratorVersion();
|
|
296
297
|
}
|
|
297
298
|
|
|
298
|
-
std::vector<pyAttrValue>
|
|
299
|
+
std::vector<pyAttrValue> get_one(const str &id, const strVec &attributes) {
|
|
299
300
|
if (attributes.empty()) {
|
|
300
301
|
return {};
|
|
301
302
|
}
|
|
@@ -316,36 +317,44 @@ public:
|
|
|
316
317
|
return {};
|
|
317
318
|
}
|
|
318
319
|
|
|
319
|
-
|
|
320
|
-
struct getAllResponse {
|
|
320
|
+
struct getManyResponse {
|
|
321
321
|
uint64_t iterator_version{};
|
|
322
322
|
uint64_t iterator{};
|
|
323
323
|
std::vector<std::pair<str, std::vector<pyAttrValue>>> result{};
|
|
324
324
|
};
|
|
325
325
|
|
|
326
|
-
str
|
|
327
|
-
|
|
326
|
+
str get_many(const strVec &ids, const strVec &attributes, uint64_t per_iteration = 10000,
|
|
327
|
+
uint64_t iterator_version = 0, uint64_t iterator = 0) {
|
|
328
328
|
if (transactionOpened)
|
|
329
|
-
throw std::runtime_error("Can't get
|
|
329
|
+
throw std::runtime_error("Can't get many when transaction is opened");
|
|
330
330
|
if (iterator && iterator_version == 0) {
|
|
331
331
|
throw std::runtime_error("Invalid iterator version");
|
|
332
332
|
}
|
|
333
333
|
if (iterator && iterator_version != this->iterator_version)
|
|
334
334
|
throw std::runtime_error("Iterator already invalidated");
|
|
335
|
-
|
|
336
|
-
std::vector<str> keys
|
|
335
|
+
getManyResponse resp{};
|
|
336
|
+
std::vector<str> keys;
|
|
337
|
+
if (ids.empty()) {
|
|
338
|
+
keys = cache | std::views::keys | std::ranges::to<std::vector>();
|
|
339
|
+
std::ranges::sort(keys);
|
|
340
|
+
} else {
|
|
341
|
+
absl::flat_hash_set<str> set_of_ids(ids.begin(), ids.end());
|
|
342
|
+
keys = cache | std::views::keys |
|
|
343
|
+
std::views::filter([&](const auto &key) { return set_of_ids.contains(key); }) |
|
|
344
|
+
std::ranges::to<std::vector>();
|
|
345
|
+
}
|
|
337
346
|
std::ranges::sort(keys);
|
|
338
347
|
|
|
339
|
-
uint64_t start = iterator;
|
|
340
|
-
uint64_t available = keys.size() > start ? keys.size() - start : 0;
|
|
341
|
-
uint64_t to_take = std::min<uint64_t>(available, per_iteration);
|
|
348
|
+
const uint64_t start = iterator;
|
|
349
|
+
const uint64_t available = keys.size() > start ? keys.size() - start : 0;
|
|
350
|
+
const uint64_t to_take = std::min<uint64_t>(available, per_iteration);
|
|
342
351
|
|
|
343
352
|
resp.result.reserve(to_take);
|
|
344
353
|
|
|
345
354
|
auto i = iterator;
|
|
346
355
|
while (i < iterator + per_iteration && i < keys.size()) {
|
|
347
356
|
const auto &key = keys[i];
|
|
348
|
-
resp.result.emplace_back(key,
|
|
357
|
+
resp.result.emplace_back(key, get_one(key, attributes));
|
|
349
358
|
i++;
|
|
350
359
|
}
|
|
351
360
|
resp.iterator_version = this->iterator_version;
|
|
@@ -378,8 +387,7 @@ public:
|
|
|
378
387
|
} else {
|
|
379
388
|
if (transactionShouldRemoveOldItems) {
|
|
380
389
|
it = cache.erase(it);
|
|
381
|
-
}
|
|
382
|
-
else {
|
|
390
|
+
} else {
|
|
383
391
|
++it;
|
|
384
392
|
}
|
|
385
393
|
}
|
|
@@ -434,8 +442,8 @@ NB_MODULE(_small_cache_impl, m) {
|
|
|
434
442
|
nb::arg("remove_old_items") = true)
|
|
435
443
|
.def("end_transaction", &SmallCache::end_transaction)
|
|
436
444
|
.def("add", &SmallCache::add_item, nb::arg("item_id"), nb::arg("attributes"))
|
|
437
|
-
.def("
|
|
438
|
-
.def("
|
|
445
|
+
.def("get_one", &SmallCache::get_one, nb::arg("id"), nb::arg("attributes"))
|
|
446
|
+
.def("get_many", &SmallCache::get_many, nb::arg("ids"), nb::arg("attributes"), nb::arg("per_iteration") = 10000,
|
|
439
447
|
nb::arg("iterator_version") = 0,
|
|
440
448
|
nb::arg("iterator") = 0)
|
|
441
449
|
.def("load_page", &SmallCache::load_page, nb::arg("json_text"));
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|