Skip to content

Commit

Permalink
make index hash part of query hash
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickbr committed Apr 3, 2024
1 parent 745879c commit b5f0f1f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/qlever-petrimaps/GeomCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::mutex> 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;
Expand Down Expand Up @@ -1196,4 +1196,5 @@ void GeomCache::load(const std::string &cacheDir) {
}

_ready = true;
return _indexHash;
}
2 changes: 1 addition & 1 deletion src/qlever-petrimaps/GeomCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions src/qlever-petrimaps/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Requestor> reqor;
std::string sessionId;
Expand Down Expand Up @@ -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<Requestor> reqor;
std::shared_ptr<GeomCache> cache = _caches[backend];

try {
cache->load(_cacheDir);
return cache->load(_cacheDir);
} catch (...) {
std::lock_guard<std::mutex> guard(_m);

Expand Down
2 changes: 1 addition & 1 deletion src/qlever-petrimaps/server/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b5f0f1f

Please sign in to comment.