sync optimisations, DBQuery no longer loads eventPayload

- It is now up to the caller to do so
- QueryScheduler now can optionally not bother to ensure that the events are fresh
This commit is contained in:
Doug Hoyte
2023-07-29 01:14:38 -04:00
parent 94a60c3ad2
commit 206b14a473
8 changed files with 59 additions and 35 deletions

View File

@ -57,18 +57,24 @@ void cmd_sync(const std::vector<std::string> &subArgs) {
auto txn = env.txn_ro();
uint64_t numEvents = 0;
std::vector<uint64_t> levIds;
while (1) {
bool complete = query.process(txn, [&](const auto &sub, uint64_t levId, std::string_view eventPayload){
auto ev = lookupEventByLevId(txn, levId);
ne.addItem(ev.flat_nested()->created_at(), sv(ev.flat_nested()->id()).substr(0, ne.idSize));
bool complete = query.process(txn, [&](const auto &sub, uint64_t levId){
levIds.push_back(levId);
numEvents++;
});
if (complete) break;
}
std::sort(levIds.begin(), levIds.end());
for (auto levId : levIds) {
auto ev = lookupEventByLevId(txn, levId);
ne.addItem(ev.flat_nested()->created_at(), sv(ev.flat_nested()->id()).substr(0, ne.idSize));
}
LI << "Filter matches " << numEvents << " events";
}