QueryData generate(QueryContext& context) override { if (context.isCached("awesome_data")) { // There is cache entry for awesome data. return {{{"data", "more_awesome_data"}}}; } else { Row r = {{"data", "awesome_data"}}; context.setCache("awesome_data", r); return {r}; } }
void genHashForFile(const std::string& path, const std::string& dir, QueryContext& context, QueryData& results) { // Must provide the path, filename, directory separate from boost path->string // helpers to match any explicit (query-parsed) predicate constraints. Row r; if (context.isCached(path)) { r = context.getCache(path); } else { auto hashes = hashMultiFromFile( HASH_TYPE_MD5 | HASH_TYPE_SHA1 | HASH_TYPE_SHA256, path); r["path"] = path; r["directory"] = dir; r["md5"] = std::move(hashes.md5); r["sha1"] = std::move(hashes.sha1); r["sha256"] = std::move(hashes.sha256); context.setCache(path, r); } results.push_back(r); }