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

Extend PrefilterExpression for Literal and Iri #1653

Merged
merged 124 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
99da434
Added conversion str to int
realHannes Apr 25, 2024
424d023
templated function for toNumeric, add declaration to NaryExpression.h
realHannes Apr 25, 2024
0117e82
str to num for SparqlExpression implemented + added test
realHannes Apr 25, 2024
35fd0b1
Merge branch 'ad-freiburg:master' into master
realHannes Apr 26, 2024
94356c2
Update src/engine/sparqlExpressions/StringExpressions.cpp
realHannes Apr 26, 2024
decc8ba
Update src/engine/sparqlExpressions/StringExpressions.cpp
realHannes Apr 26, 2024
850152c
Update src/engine/sparqlExpressions/StringExpressions.cpp
realHannes Apr 26, 2024
d650d67
Update src/engine/sparqlExpressions/StringExpressions.cpp
realHannes Apr 26, 2024
46cc697
using now absl::from_chars() and stripping whitespaces for string to …
realHannes Apr 26, 2024
7fc5c28
added new functions to processIriFuntionCall() (for string to number)
realHannes Apr 26, 2024
efb0e24
renaming to: toIntExpression and toDoubleExpression for later more ge…
realHannes Apr 26, 2024
a88537c
made format (clang-format-16)
realHannes Apr 26, 2024
ca1e2e0
Update src/parser/sparqlParser/SparqlQleverVisitor.cpp
realHannes Apr 29, 2024
4adc831
Update src/parser/sparqlParser/SparqlQleverVisitor.cpp
realHannes Apr 29, 2024
d0f0d63
renaming in NaryExpression.h for accordance with other function, addi…
realHannes Apr 29, 2024
a118609
added test coverage for function calls makeIntExpression and make Dou…
realHannes Apr 29, 2024
062052e
toNumeric has now correct behavior and uses absl::from_chars() and st…
realHannes Apr 29, 2024
6d0f42a
made clang-format for NaryExpressionImpl.h
realHannes Apr 29, 2024
f90b8e2
Merge branch 'ad-freiburg:master' into master
realHannes May 6, 2024
fb88493
Merge branch 'ad-freiburg:master' into master
realHannes May 15, 2024
b2eb514
Merge remote-tracking branch 'upstream/master'
realHannes May 16, 2024
b165ac1
Merge branch 'ad-freiburg:master' into master
realHannes Jun 1, 2024
7a3dfb2
Merge branch 'master' of https://github.com/realHannes/qlever
realHannes Jun 1, 2024
fc0ad3a
Merge branch 'ad-freiburg:master' into master
realHannes Jun 6, 2024
f3e6086
Merge branch 'ad-freiburg:master' into master
realHannes Jun 7, 2024
fd4c351
Merge branch 'ad-freiburg:master' into master
realHannes Jun 10, 2024
220c9bf
Merge branch 'ad-freiburg:master' into master
realHannes Jun 12, 2024
a81cb8a
Merge branch 'ad-freiburg:master' into master
realHannes Jun 13, 2024
acc0109
Merge branch 'ad-freiburg:master' into master
realHannes Jun 14, 2024
cb8e560
Merge branch 'ad-freiburg:master' into master
realHannes Jun 20, 2024
2b39970
Merge branch 'ad-freiburg:master' into master
realHannes Jun 28, 2024
a0101e4
Merge branch 'ad-freiburg:master' into master
realHannes Jun 30, 2024
47dee1d
Merge branch 'ad-freiburg:master' into master
realHannes Sep 4, 2024
a8625f9
Merge branch 'ad-freiburg:master' into master
realHannes Sep 9, 2024
7f95069
Merge branch 'ad-freiburg:master' into master
realHannes Sep 12, 2024
28b8a69
Merge branch 'ad-freiburg:master' into master
realHannes Sep 13, 2024
7bb6e01
Merge branch 'ad-freiburg:master' into master
realHannes Sep 14, 2024
edc974a
Add implementation for pre-filtering blocks on their metadata
realHannes Sep 18, 2024
ca6c2ff
Merge branch 'master' into prefilter_on_metadata_relational
realHannes Sep 18, 2024
46be51a
fix spelling error
realHannes Sep 18, 2024
0385b56
add namespace for CompressedBlockPrefiltering.h
realHannes Sep 18, 2024
5707338
use std::ranges::set_union, std::ranges::upper_bound/lower_bound
realHannes Sep 18, 2024
c9687ec
move template specializations into namespace prefilterExpressions
realHannes Sep 18, 2024
d8246f7
fix
realHannes Sep 18, 2024
66b4872
hopefully fix namespace issue
realHannes Sep 18, 2024
e4eddc4
Merge branch 'ad-freiburg:master' into prefilter_on_metadata_relational
realHannes Sep 20, 2024
b5d7dd7
first adaptations regarding the comments
realHannes Sep 20, 2024
802e3aa
Merge branch 'ad-freiburg:master' into prefilter_on_metadata_relational
realHannes Sep 23, 2024
662b1d4
applied suggestions from review
realHannes Sep 24, 2024
510aa9e
fix std::move
realHannes Sep 24, 2024
0d7f75b
Merge branch 'ad-freiburg:master' into prefilter_on_metadata_relational
realHannes Sep 25, 2024
c119200
adjusted CompressedBlockPrefiltering
realHannes Sep 26, 2024
af17181
mark method with override
realHannes Sep 26, 2024
3d7238d
Merge branch 'master' into prefilter_on_metadata_relational
realHannes Oct 8, 2024
5af6138
make further changes to prefiltering procedure and its tests
realHannes Oct 8, 2024
b02dc57
add additional testing on IDs from other datatypes
realHannes Oct 8, 2024
eb86f1b
addition to test Not Expression with And and Or
realHannes Oct 8, 2024
69ed019
changes to test and fix index check fail
realHannes Oct 9, 2024
854322b
increase test coverage for Not expression
realHannes Oct 9, 2024
b2aa689
just add all mixed blocks
realHannes Oct 9, 2024
546c3b3
Merge branch 'ad-freiburg:master' into prefilter_on_metadata_relational
realHannes Oct 9, 2024
7e61cb1
remove unnecessary values in test context
realHannes Oct 9, 2024
009ebed
for sonar check
realHannes Oct 10, 2024
6c19bf6
Merge branch 'ad-freiburg:master' into prefilter_on_metadata_relational
realHannes Oct 10, 2024
bf733ce
Merge branch 'ad-freiburg:master' into environment_for_using_prefilte…
realHannes Oct 12, 2024
5b42c1f
methods to get PrefilterExpresssions from RelationalExpressions (Spar…
realHannes Oct 12, 2024
6cf6609
Completed the implementation for constructing PrefilterExpressions fr…
realHannes Oct 22, 2024
18c4c84
Merge branch 'master' into environment_for_using_prefiltering
realHannes Oct 22, 2024
e4be1fe
all builds should compile now
realHannes Oct 22, 2024
bde09cd
Merge branch 'ad-freiburg:master' into environment_for_using_prefilte…
realHannes Oct 22, 2024
74756fe
fix build issue and increase test coverage
realHannes Oct 22, 2024
1278d39
Merge branch 'master' into environment_for_using_prefiltering
realHannes Oct 22, 2024
47d3d56
Merge branch 'ad-freiburg:master' into environment_for_using_prefilte…
realHannes Oct 25, 2024
49de4d0
introduce test structure from PR1 (#1503)
realHannes Oct 25, 2024
fcefdf0
Merge branch 'master' into environment_for_using_prefiltering
realHannes Oct 28, 2024
9f0efc6
fix build
realHannes Oct 28, 2024
25f325a
implement proposed changes (2)
realHannes Oct 30, 2024
d65acc3
correction for codespell check
realHannes Oct 30, 2024
f85a96f
fix for codespell
realHannes Oct 30, 2024
0a188a5
Merge branch 'ad-freiburg:master' into environment_for_using_prefilte…
realHannes Oct 31, 2024
5f4e586
remove optionality (std::optional) for return value
realHannes Oct 31, 2024
8062753
Merge branch 'ad-freiburg:master' into environment_for_using_prefilte…
realHannes Nov 4, 2024
c06de60
implement proposed improvements (4)
realHannes Nov 4, 2024
95e9027
further adjustments + apply PrefilterExpressions in IndexScan
realHannes Nov 11, 2024
0992fab
Merge branch 'master' into environment_for_using_prefiltering
realHannes Nov 11, 2024
f489b24
few additional adaptations
realHannes Nov 11, 2024
1340021
Make `CartesianProductJoin` lazy. (#1609)
RobinTF Nov 13, 2024
23cea27
Get `PrefilterExpression` from `SparqlExpression` (#1613)
realHannes Nov 14, 2024
5144b47
Add STDEV() aggregate function (#1614)
ullingerc Nov 14, 2024
e9e6f8d
Merge located triples when performing index scans (#1597)
joka921 Nov 14, 2024
96ded86
Merge branch 'master' into implement-apply-prefilter-expressions
realHannes Nov 15, 2024
45cc1b4
changes w.r.t. comments from #1573
realHannes Nov 18, 2024
0a3f67e
Merge branch 'ad-freiburg:master' into implement-apply-prefilter-expr…
realHannes Nov 19, 2024
0b30ad3
updates from code review (1)
realHannes Nov 20, 2024
4bf0d01
Merge branch 'ad-freiburg:master' into implement-apply-prefilter-expr…
realHannes Nov 20, 2024
54c00ad
first empty prefilter scan fix
realHannes Nov 21, 2024
118ad87
Fix the bug that always disables prefilter expressions.
joka921 Nov 21, 2024
f47cc2c
Merge branch 'ad-freiburg:master' into implement-apply-prefilter-expr…
realHannes Nov 21, 2024
61a15ce
select only Variable for first column index + extend constructor
realHannes Nov 21, 2024
6ef031b
set multiplicities in IndexScan constructor
realHannes Nov 21, 2024
bef8211
changes for review (1)
realHannes Nov 23, 2024
80d54df
changes for review (2)
realHannes Nov 24, 2024
25eb418
correction for Codespell
realHannes Nov 24, 2024
83f2363
add testing
realHannes Nov 27, 2024
097e206
Merge branch 'master' into implement-apply-prefilter-expressions
realHannes Nov 27, 2024
1574860
FilterTest fix + codespell fix
realHannes Nov 27, 2024
9de745a
simplify test in IndexScanTest
realHannes Nov 27, 2024
0a7672c
more changes
realHannes Nov 28, 2024
0ff8689
test
realHannes Nov 28, 2024
bef9326
Merge branch 'master' into implement-apply-prefilter-expressions
realHannes Nov 29, 2024
6e54939
fix test error
realHannes Nov 29, 2024
2751fe1
adapt code part merge conflict
realHannes Nov 29, 2024
406e323
implement use PrefilterExpression for Iri and Literals (1)
realHannes Nov 30, 2024
36b00f3
implement use PrefilterExpression for Iri and Literals (2)
realHannes Dec 2, 2024
b242221
Fix deadlock in lazy join implementation (#1650)
RobinTF Nov 29, 2024
792dd39
Correctly handle the cache in the presence of SPARQL UPDATE (#1646)
joka921 Nov 29, 2024
1a6e5b2
Update graph info in the augmented block metadata (#1642)
joka921 Nov 29, 2024
863a337
Apply binary search filter expressions directly on the block metadata…
realHannes Dec 2, 2024
6a69fc9
Merge branch 'master' into extend-prefilter-for-literals
realHannes Dec 2, 2024
513dcd1
test prefiltering with LocalVocabEntry reference values
realHannes Dec 3, 2024
169bf08
add Literal/Iri value tests for GetPrefilterExpressionFromSparqlExpre…
realHannes Dec 3, 2024
4d7b413
changes for review (1)
realHannes Dec 4, 2024
99fb34b
changes for code review (2)
realHannes Dec 5, 2024
b88f3b1
changes for code review (3)
realHannes Dec 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/engine/sparqlExpressions/LiteralExpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ struct SingleUseExpression : public SparqlExpression {

std::span<SparqlExpression::Ptr> childrenImpl() override { return {}; }
};

} // namespace detail

/// The actual instantiations and aliases of LiteralExpressions.
Expand All @@ -224,4 +225,38 @@ using IdExpression = detail::LiteralExpression<ValueId>;
using VectorIdExpression =
detail::LiteralExpression<VectorWithMemoryLimit<ValueId>>;
using SingleUseExpression = detail::SingleUseExpression;

namespace detail {

//______________________________________________________________________________
using IdOrLocalVocabEntry = prefilterExpressions::IdOrLocalVocabEntry;
// Given a `SparqlExpression*` pointing to a `LiteralExpression`, this helper
// function retrieves a corresponding `IdOrLocalVocabEntry` variant
// (`std::variant<ValueId, LocalVocabEntry>`) for `LiteralExpression`s that
// contain a suitable type.
realHannes marked this conversation as resolved.
Show resolved Hide resolved
// Given the boolean flag `stringAndIriOnly` is set to `true`, only `Literal`s,
// `Iri`s and `ValueId`s of type `VocabIndex`/`LocalVocabIndex` are returned. If
// `stringAndIriOnly` is set to `false` (default), all `ValueId` types retrieved
// from `LiteralExpression<ValueId>` will be returned.
inline std::optional<IdOrLocalVocabEntry>
getIdOrLocalVocabEntryFromLiteralExpression(const SparqlExpression* child,
bool stringAndIriOnly = false) {
using enum Datatype;
if (const auto* idExpr = dynamic_cast<const IdExpression*>(child)) {
auto idType = idExpr->value().getDatatype();
if (stringAndIriOnly && idType != VocabIndex && idType != LocalVocabIndex) {
return std::nullopt;
}
realHannes marked this conversation as resolved.
Show resolved Hide resolved
return idExpr->value();
} else if (const auto* literalExpr =
dynamic_cast<const StringLiteralExpression*>(child)) {
return LocalVocabEntry{literalExpr->value()};
} else if (const auto* iriExpr = dynamic_cast<const IriExpression*>(child)) {
return LocalVocabEntry{iriExpr->value()};
} else {
return std::nullopt;
}
}
} // namespace detail

} // namespace sparqlExpression
121 changes: 93 additions & 28 deletions src/engine/sparqlExpressions/PrefilterExpressionIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <ranges>

#include "global/ValueIdComparators.h"
#include "util/ConstexprMap.h"
#include "util/OverloadCallOperator.h"

namespace prefilterExpressions {

Expand Down Expand Up @@ -207,34 +209,37 @@ std::vector<BlockMetadata> PrefilterExpression::evaluateAndCheckImpl(
return relevantBlocks;
}

//______________________________________________________________________________
ValueId PrefilterExpression::getValueIdFromIdOrLocalVocabEntry(
const IdOrLocalVocabEntry& referenceValue, LocalVocab& vocab) {
return std::visit(ad_utility::OverloadCallOperator{
[](const ValueId& referenceId) { return referenceId; },
[&vocab](const LocalVocabEntry& referenceLVE) {
return Id::makeFromLocalVocabIndex(
vocab.getIndexAndAddIfNotContained(referenceLVE));
}},
referenceValue);
}

// SECTION RELATIONAL OPERATIONS
//______________________________________________________________________________
template <CompOp Comparison>
std::unique_ptr<PrefilterExpression>
RelationalExpression<Comparison>::logicalComplement() const {
using enum CompOp;
switch (Comparison) {
case LT:
// Complement X < Y: X >= Y
return std::make_unique<GreaterEqualExpression>(referenceId_);
case LE:
// Complement X <= Y: X > Y
return std::make_unique<GreaterThanExpression>(referenceId_);
case EQ:
// Complement X == Y: X != Y
return std::make_unique<NotEqualExpression>(referenceId_);
case NE:
// Complement X != Y: X == Y
return std::make_unique<EqualExpression>(referenceId_);
case GE:
// Complement X >= Y: X < Y
return std::make_unique<LessThanExpression>(referenceId_);
case GT:
// Complement X > Y: X <= Y
return std::make_unique<LessEqualExpression>(referenceId_);
default:
AD_FAIL();
}
using namespace ad_utility;
using P = std::pair<CompOp, CompOp>;
// The complementation logic implemented with the following mapping procedure:
// (1) ?var < referenceValue -> ?var >= referenceValue
// (2) ?var <= referenceValue -> ?var > referenceValue
// (3) ?var >= referenceValue -> ?var < referenceValue
// (4) ?var > referenceValue -> ?var <= referenceValue
// (5) ?var = referenceValue -> ?var != referenceValue
// (6) ?var != referenceValue -> ?var = referenceValue
constexpr ConstexprMap<CompOp, CompOp, 6> complementMap(
{P{LT, GE}, P{LE, GT}, P{GE, LT}, P{GT, LE}, P{EQ, NE}, P{NE, EQ}});
return std::make_unique<RelationalExpression<complementMap.at(Comparison)>>(
rightSideReferenceValue_);
};

//______________________________________________________________________________
Expand All @@ -261,18 +266,21 @@ std::vector<BlockMetadata> RelationalExpression<Comparison>::evaluateImpl(
}
}

LocalVocab vocab{};
auto referenceId =
getValueIdFromIdOrLocalVocabEntry(rightSideReferenceValue_, vocab);
// Use getRangesForId (from valueIdComparators) to extract the ranges
// containing the relevant ValueIds.
// For pre-filtering with CompOp::EQ, we have to consider empty ranges.
// Reason: The referenceId_ could be contained within the bounds formed by
// Reason: The referenceId could be contained within the bounds formed by
// the IDs of firstTriple_ and lastTriple_ (set false flag to keep
// empty ranges).
auto relevantIdRanges =
Comparison != CompOp::EQ
? getRangesForId(valueIdsInput.begin(), valueIdsInput.end(),
referenceId_, Comparison)
referenceId, Comparison)
: getRangesForId(valueIdsInput.begin(), valueIdsInput.end(),
referenceId_, Comparison, false);
referenceId, Comparison, false);

// The vector for relevant BlockMetadata values which contain ValueIds
// defined as relevant by relevantIdRanges.
Expand Down Expand Up @@ -312,23 +320,37 @@ bool RelationalExpression<Comparison>::operator==(
if (!otherRelational) {
return false;
}
return referenceId_ == otherRelational->referenceId_;
return rightSideReferenceValue_ == otherRelational->rightSideReferenceValue_;
};

//______________________________________________________________________________
template <CompOp Comparison>
std::unique_ptr<PrefilterExpression> RelationalExpression<Comparison>::clone()
const {
return std::make_unique<RelationalExpression<Comparison>>(referenceId_);
return std::make_unique<RelationalExpression<Comparison>>(
rightSideReferenceValue_);
};

//______________________________________________________________________________
template <CompOp Comparison>
std::string RelationalExpression<Comparison>::asString(
[[maybe_unused]] size_t depth) const {
auto referenceValueToString = [](std::stringstream& stream,
const IdOrLocalVocabEntry& referenceValue) {
std::visit(
ad_utility::OverloadCallOperator{
[&stream](const ValueId& referenceId) { stream << referenceId; },
[&stream](const LocalVocabEntry& referenceValue) {
stream << referenceValue.toStringRepresentation();
}},
referenceValue);
};

std::stringstream stream;
stream << "Prefilter RelationalExpression<" << getRelationalOpStr(Comparison)
<< ">\nValueId: " << referenceId_ << std::endl;
<< ">\nreferenceValue_ : ";
referenceValueToString(stream, rightSideReferenceValue_);
stream << " ." << std::endl;
return stream.str();
};

Expand Down Expand Up @@ -456,6 +478,23 @@ template class LogicalExpression<LogicalOperator::OR>;

namespace detail {

//______________________________________________________________________________
// Returns the corresponding mirrored `RelationalExpression<mirrored
// comparison>` for the given `CompOp comparison` template argument. For
// example, the mirroring procedure will transform the relational expression
// `referenceValue > ?var` into `?var < referenceValue`.
template <CompOp comparison>
static std::unique_ptr<PrefilterExpression> makeMirroredExpression(
const IdOrLocalVocabEntry& referenceValue) {
using enum CompOp;
using namespace ad_utility;
using P = std::pair<CompOp, CompOp>;
constexpr ConstexprMap<CompOp, CompOp, 6> mirrorMap(
{P{LT, GT}, P{LE, GE}, P{GE, LE}, P{GT, LT}, P{EQ, EQ}, P{NE, NE}});
return std::make_unique<RelationalExpression<mirrorMap.at(comparison)>>(
referenceValue);
}

//______________________________________________________________________________
void checkPropertiesForPrefilterConstruction(
const std::vector<PrefilterExprVariablePair>& vec) {
Expand All @@ -473,5 +512,31 @@ void checkPropertiesForPrefilterConstruction(
}
}

//______________________________________________________________________________
template <CompOp comparison>
std::vector<PrefilterExprVariablePair> makePrefilterExpressionVec(
const IdOrLocalVocabEntry& referenceValue, const Variable& variable,
const bool mirrored) {
std::vector<PrefilterExprVariablePair> resVec{};
resVec.emplace_back(
mirrored
? makeMirroredExpression<comparison>(referenceValue)
: std::make_unique<RelationalExpression<comparison>>(referenceValue),
variable);
return resVec;
}

realHannes marked this conversation as resolved.
Show resolved Hide resolved
//______________________________________________________________________________
#define INSTANTIATE_MAKE_PREFILTER(Comparison) \
template std::vector<PrefilterExprVariablePair> \
makePrefilterExpressionVec<Comparison>(const IdOrLocalVocabEntry&, \
const Variable&, const bool);
INSTANTIATE_MAKE_PREFILTER(CompOp::LT);
INSTANTIATE_MAKE_PREFILTER(CompOp::LE);
INSTANTIATE_MAKE_PREFILTER(CompOp::GE);
INSTANTIATE_MAKE_PREFILTER(CompOp::GT);
INSTANTIATE_MAKE_PREFILTER(CompOp::EQ);
INSTANTIATE_MAKE_PREFILTER(CompOp::NE);

} // namespace detail
} // namespace prefilterExpressions
53 changes: 40 additions & 13 deletions src/engine/sparqlExpressions/PrefilterExpressionIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

namespace prefilterExpressions {

using IdOrLocalVocabEntry = std::variant<ValueId, LocalVocabEntry>;

//______________________________________________________________________________
// The maximum recursion depth for `info()` / `operator<<()`. A depth of `3`
// should be sufficient for most `PrefilterExpressions` in our use case.
Expand Down Expand Up @@ -101,16 +103,21 @@ class PrefilterExpression {
return str;
}

// Static helper to retrieve the reference `ValueId` from the
// `IdOrLocalVocabEntry` variant.
static ValueId getValueIdFromIdOrLocalVocabEntry(
const IdOrLocalVocabEntry& refernceValue, LocalVocab& vocab);

private:
// Performs the following conditional checks on the provided `BlockMetadata`
// values:
// (1) unqiueness of blocks
// (2) sorted (order)
// (3) Constant values for all columns `< evaluationColumn`
// This function subsequently invokes the `evaluateImpl` method and
// checks the corresponding result for those conditions again.
// If a respective condition is violated, the function performing the checks
// will throw a `std::runtime_error`.
// Note: Use `evaluate` for general evaluation of `PrefilterExpression`
// instead of this method.
// Performs the following conditional checks on
// the provided `BlockMetadata` values: (1) unqiueness of blocks (2) sorted
// (order) (3) Constant values for all columns `< evaluationColumn` This
// function subsequently invokes the `evaluateImpl` method and checks the
// corresponding result for those conditions again. If a respective condition
// is violated, the function performing the checks will throw a
// `std::runtime_error`.
std::vector<BlockMetadata> evaluateAndCheckImpl(
std::span<const BlockMetadata> input, size_t evaluationColumn) const;

Expand All @@ -130,12 +137,18 @@ using CompOp = valueIdComparators::Comparison;
template <CompOp Comparison>
class RelationalExpression : public PrefilterExpression {
private:
// The ValueId on which we perform the relational comparison on.
ValueId referenceId_;
// This is the right hand side value of the relational expression. The left
// hand value is indirectly supplied during the evaluation process via the
// `evaluationColumn` argument. `evaluationColumn` represents the column index
// associated with the `Variable` column of the `IndexScan`.
// E.g., a less-than expression with a value of 3 will represent the logical
// relation ?var < 3. A equal-to expression with a value of "Freiburg" will
// represent ?var = "Freiburg".
IdOrLocalVocabEntry rightSideReferenceValue_;

public:
explicit RelationalExpression(const ValueId referenceId)
: referenceId_(referenceId) {}
explicit RelationalExpression(const IdOrLocalVocabEntry& referenceValue)
: rightSideReferenceValue_(referenceValue) {}

std::unique_ptr<PrefilterExpression> logicalComplement() const override;
bool operator==(const PrefilterExpression& other) const override;
Expand Down Expand Up @@ -239,5 +252,19 @@ using PrefilterExprVariablePair =
void checkPropertiesForPrefilterConstruction(
const std::vector<PrefilterExprVariablePair>& vec);

//______________________________________________________________________________
realHannes marked this conversation as resolved.
Show resolved Hide resolved
// Creates a `RelationalExpression<comparison>` prefilter expression based on
// the templated `CompOp` comparison operation and the reference
// `IdOrLocalVocabEntry` value. With the next step, the corresponding
// `<RelationalExpression<comparison>, Variable>` pair is created, and finally
// returned in a vector. The `mirrored` flag indicates if the given
// `RelationalExpression<comparison>` should be mirrored. The mirroring
// procedure changes the (asymmetrical) comparison operations:
// e.g. `5 < ?x` is changed to `?x > 5`.
template <CompOp comparison>
std::vector<PrefilterExprVariablePair> makePrefilterExpressionVec(
const IdOrLocalVocabEntry& referenceValue, const Variable& variable,
bool mirrored);

} // namespace detail
} // namespace prefilterExpressions
Loading
Loading