Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable pre-filtering (using PrefilterExpressionIndex) of Date values over expression YEAR(). #1820

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

realHannes
Copy link
Collaborator

No description provided.

Copy link

codecov bot commented Feb 19, 2025

Codecov Report

Attention: Patch coverage is 96.00000% with 5 lines in your changes missing coverage. Please review.

Project coverage is 90.20%. Comparing base (8fe0642) to head (7a04614).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
...ine/sparqlExpressions/PrefilterExpressionIndex.cpp 96.90% 2 Missing and 1 partial ⚠️
src/engine/sparqlExpressions/NaryExpressionImpl.h 66.66% 0 Missing and 1 partial ⚠️
...engine/sparqlExpressions/RelationalExpressions.cpp 94.11% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1820      +/-   ##
==========================================
+ Coverage   90.18%   90.20%   +0.02%     
==========================================
  Files         400      400              
  Lines       38440    38526      +86     
  Branches     4306     4318      +12     
==========================================
+ Hits        34666    34753      +87     
- Misses       2479     2480       +1     
+ Partials     1295     1293       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@realHannes realHannes requested a review from joka921 February 19, 2025 18:58
Copy link
Member

@joka921 joka921 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very nice and clean, I only have a few remarks.

@sparql-conformance
Copy link

Copy link

Copy link
Member

@joka921 joka921 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is almost ready to merge,
I have very few suggestions, one of which improves the code coverage

Comment on lines +559 to +568
} else if constexpr (std::is_same_v<std::decay_t<T>,
LocalVocabEntry>) {
throw std::runtime_error(absl::StrCat(
"Provided Literal or Iri with value: ",
value.asLiteralOrIri().toStringRepresentation(),
". This is an invalid reference value for filtering date "
"values over expression YEAR. Please provide an integer "
"value as reference year."));
}
throw std::runtime_error(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this else {static_assert} instead of else if ...,
because the final throw is unreachable and because the code becomes more robust that way.

[](const IdOrLocalVocabEntry& referenceValue) {
return std::visit(
[]<typename T>(const T& value) -> ValueId {
if constexpr (std::is_same_v<std::decay_t<T>, ValueId>) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use ad_utility::SimilarTo instead of same<decay<
(shorter and more expressive.

Comment on lines +256 to +257
// Use for testing only. The definition here is necessary to call
// `makePrefilterYearImpl` with an invalid `CompOp` argument given that it is
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean This function is public s.t. we can test the corner case of...?

// needs to be applied for the creation of `PrefilterExpression`.
static std::optional<std::pair<Variable, bool>> getOptVariableAndIsYear(
const SparqlExpression* child) {
// (1) The direct child already contains the Variable.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simpler workflow:
bool isYear = false;
if (child->isYearExpression) {
isYear = true;
child = child->child; // pseudocode.
}
... // need to check teh isVariable only once.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(if overwriting the varaibel child doesn't work, introduce some additional variable.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants