-
Notifications
You must be signed in to change notification settings - Fork 54
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
Implement construct PrefilterExpression
from SparqlExpression
.
#1573
Implement construct PrefilterExpression
from SparqlExpression
.
#1573
Conversation
Co-authored-by: Johannes Kalmbach <[email protected]>
Co-authored-by: Johannes Kalmbach <[email protected]>
Co-authored-by: Johannes Kalmbach <[email protected]>
Co-authored-by: Johannes Kalmbach <[email protected]>
…neral implementation
Co-authored-by: Johannes Kalmbach <[email protected]>
Co-authored-by: Johannes Kalmbach <[email protected]>
…ng correct prefix in Constants.h
PrefilterExpression
from SparqlExpression
.
PrefilterExpression
from SparqlExpression
.PrefilterExpression
from SparqlExpression
.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1573 +/- ##
==========================================
- Coverage 89.21% 89.20% -0.01%
==========================================
Files 372 372
Lines 34723 35049 +326
Branches 3915 3961 +46
==========================================
+ Hits 30979 31267 +288
- Misses 2471 2490 +19
- Partials 1273 1292 +19 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A first thorough round of reviews.
The initial design looks clean and readable.
Please merge the current master in and add tests and fix bugs.
[[maybe_unused]] bool isNegated) const { | ||
return std::nullopt; | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have forgotten one case where you can apply a filter
(I also didn't tell you this).
In the RegexExpression
there is the special case of a PrefixRegex
which is applied using binary search and can basically be something like ` ?x begins with "hannes" -> ?x >= hannes && ?x " (but of course the logic is a little more involved. You can have a look at it, but maybe this can also be a separate PR as I am currently also refactoring the RegexExpression to not get conflicts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And while i am at it : The startswith
can probably also be implemented in that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two major comments:
- Consistently drop the
optional<>
- Don't use deMorgan at all, as it doesn't work well with the SPARQL semantics.
Conformance check passed ✅No test result changes. |
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The most important request
- split the PR.
- look at my comments, and then contact me for the questions/ discussions.
if (ptr) { | ||
ptr->setPrefilterExpression(prefilterVec); | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some detailed comments here:
-
You may only pass on PrefilterExpressions to a child execution tree, if the variable of the expression is visible in the variable to column map. Otherwise you have the case that subqueries filter out too much.
-
It is fishy (and leads to unexpected behavior) if you just change the
Operation
without informing theshared_ptr<ExecutionTree>
that owns it.
So what you need, is aforThisExecutionTreeAndAllDescendents(
shared_ptr) that completely replaces the shared_ptr with a completely new execution tree (via
make_sharedor respectively
ad_utility::createExecutionTree) that stores the IndexScan. Then you best have a function in the IndexScanClass that can do something like
shared_ptr makeCopyWithAddedPrefilters(Prefilters) const(we have something similar in the
TransitivePathclass called
bindLeftOrRightSide`. -
You should make two PRs out of this, one for the extraction of the prefilters out of the expression (the first part of this PR), and then this second one here which is based on that one. Because then we can merge the first part earlier (which is further in the review process), and it gets much easier to review.
This has been merged already in several other smaller PRs. |
The
SparqlExpression
base class has been extended with the methodgetPrefilterExpressionForMetadata
. This method constructs for suitable (logical) expressions a correspondingPrefilterExpression
(see PR #1503). ThosePrefilterExpression(s)
preselect the relevant data blocks with the availableCompressedBlockMetadata
over theIndexScan
procedure. This saves a lot of compute in the actual expression evaluation later on.At the moment, the following expressions provide an overriden implementation of
getPrefilterExpressionForMetadata
:logical-or
andlogical-and
(binary),logical-not
(unary) and the standardRelationalExpressions
.