From b5f0f1f996904bca9c93a26e2ab5a516a0d77d29 Mon Sep 17 00:00:00 2001 From: Patrick Brosi Date: Wed, 3 Apr 2024 18:24:08 +0200 Subject: [PATCH] make index hash part of query hash --- src/qlever-petrimaps/GeomCache.cpp | 5 +++-- src/qlever-petrimaps/GeomCache.h | 2 +- src/qlever-petrimaps/server/Server.cpp | 8 ++++---- src/qlever-petrimaps/server/Server.h | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/qlever-petrimaps/GeomCache.cpp b/src/qlever-petrimaps/GeomCache.cpp index ff8e584..c72f6fd 100644 --- a/src/qlever-petrimaps/GeomCache.cpp +++ b/src/qlever-petrimaps/GeomCache.cpp @@ -1153,12 +1153,12 @@ std::string GeomCache::requestIndexHash() { } // _____________________________________________________________________________ -void GeomCache::load(const std::string &cacheDir) { +std::string GeomCache::load(const std::string &cacheDir) { std::lock_guard guard(_m); if (_ready) { auto indexHash = requestIndexHash(); - if (_indexHash == indexHash) return; + if (_indexHash == indexHash) return _indexHash; LOG(INFO) << "Loaded index hash (" << _indexHash << ") and remote index hash (" << indexHash << ") dont match."; _ready = false; @@ -1196,4 +1196,5 @@ void GeomCache::load(const std::string &cacheDir) { } _ready = true; + return _indexHash; } diff --git a/src/qlever-petrimaps/GeomCache.h b/src/qlever-petrimaps/GeomCache.h index 78ae691..1c197cf 100644 --- a/src/qlever-petrimaps/GeomCache.h +++ b/src/qlever-petrimaps/GeomCache.h @@ -49,7 +49,7 @@ class GeomCache { return ready; } - void load(const std::string& cacheFile); + std::string load(const std::string& cacheFile); void request(); size_t requestSize(); diff --git a/src/qlever-petrimaps/server/Server.cpp b/src/qlever-petrimaps/server/Server.cpp index e9274b4..af31d25 100755 --- a/src/qlever-petrimaps/server/Server.cpp +++ b/src/qlever-petrimaps/server/Server.cpp @@ -783,9 +783,9 @@ util::http::Answer Server::handleQueryReq(const Params& pars) const { LOG(INFO) << "[SERVER] Query is:\n" << query; createCache(backend); - loadCache(backend); + std::string indexHash = loadCache(backend); - std::string queryId = backend + "$" + query; + std::string queryId = backend + "$" + indexHash + "$" + query; std::shared_ptr reqor; std::string sessionId; @@ -1196,12 +1196,12 @@ void Server::createCache(const std::string& backend) const { } // _____________________________________________________________________________ -void Server::loadCache(const std::string& backend) const { +std::string Server::loadCache(const std::string& backend) const { // std::shared_ptr reqor; std::shared_ptr cache = _caches[backend]; try { - cache->load(_cacheDir); + return cache->load(_cacheDir); } catch (...) { std::lock_guard guard(_m); diff --git a/src/qlever-petrimaps/server/Server.h b/src/qlever-petrimaps/server/Server.h index 595836d..8239a73 100755 --- a/src/qlever-petrimaps/server/Server.h +++ b/src/qlever-petrimaps/server/Server.h @@ -43,7 +43,7 @@ class Server : public util::http::Handler { util::http::Answer handleLoadStatusReq(const Params& pars) const; void createCache(const std::string& backend) const; - void loadCache(const std::string& backend) const; + std::string loadCache(const std::string& backend) const; void clearSession(const std::string& id) const; void clearSessions() const;