From dde296b052dee3c267acdeaec514a3e3b47e5cb9 Mon Sep 17 00:00:00 2001 From: Johannes Kalmbach Date: Tue, 7 Jan 2025 16:27:14 +0100 Subject: [PATCH] Fix a small warning, to feed this to the tool. Signed-off-by: Johannes Kalmbach --- src/engine/ExistsScan.cpp | 4 ++-- src/engine/sparqlExpressions/ExistsExpression.h | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/engine/ExistsScan.cpp b/src/engine/ExistsScan.cpp index 1604e353a..651e8e61c 100644 --- a/src/engine/ExistsScan.cpp +++ b/src/engine/ExistsScan.cpp @@ -14,8 +14,8 @@ ExistsScan::ExistsScan(QueryExecutionContext* qec, : Operation{qec}, left_{std::move(left)}, right_{std::move(right)}, - existsVariable_{std::move(existsVariable)}, - joinColumns_{QueryExecutionTree::getJoinColumns(*left_, *right_)} {} + joinColumns_{QueryExecutionTree::getJoinColumns(*left_, *right_)}, + existsVariable_{std::move(existsVariable)} {} // _____________________________________________________________________________ string ExistsScan::getCacheKeyImpl() const { diff --git a/src/engine/sparqlExpressions/ExistsExpression.h b/src/engine/sparqlExpressions/ExistsExpression.h index d5eff23ba..343c195e8 100644 --- a/src/engine/sparqlExpressions/ExistsExpression.h +++ b/src/engine/sparqlExpressions/ExistsExpression.h @@ -30,10 +30,15 @@ class ExistsExpression : public SparqlExpression { //____________________________________________________________________________ [[nodiscard]] string getCacheKey( const VariableToColumnMap& varColMap) const override { - // TODO get a proper cache key here - AD_CONTRACT_CHECK(varColMap.contains(variable_)); - return absl::StrCat("EXISTS WITH COL ", - varColMap.at(variable_).columnIndex_); + if (varColMap.contains(variable_)) { + return absl::StrCat("EXISTS WITH COL ", + varColMap.at(variable_).columnIndex_); + } else { + // This means that the necessary `ExistsScan` hasn't been set up yet. + // It is not possible to cache such incomplete operations, so we return + // a random cache key. + return std::to_string(ad_utility::FastRandomIntGenerator{}()); + } } // ____________________________________________________________________________