-
Notifications
You must be signed in to change notification settings - Fork 169
Gh 5286 leftjoin skip rhs execution #5318
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
Open
jasperiq
wants to merge
7
commits into
eclipse-rdf4j:main
Choose a base branch
from
web-iq:GH-5286-leftjoin-skip-rhs-execution
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1d5e29c
GH-5286 Added benchmarks for optional with filters
jasperiq f796e41
GH-5286 Fixed typo
jasperiq b6a114b
GH-5286 Improve right hand side evaluation of LeftJoin
jasperiq b402101
GH-5286 Moving filter logic to separate concepts
jasperiq ec2d444
GH-5286 Pushing tests to individual LeftJoin...FilterEvaluationSteps
jasperiq a8ae08b
GH-5286 Determine right hand side evaluation type for well designed q…
jasperiq db12fd1
GH-5286 Generalize concepts for evaluation steps and condition
jasperiq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...se/rdf4j/query/algebra/evaluation/impl/evaluationsteps/PostFilterQueryEvaluationStep.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 Eclipse RDF4J contributors. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Distribution License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*******************************************************************************/ | ||
package org.eclipse.rdf4j.query.algebra.evaluation.impl.evaluationsteps; | ||
|
||
import java.util.function.Predicate; | ||
|
||
import org.eclipse.rdf4j.common.iteration.CloseableIteration; | ||
import org.eclipse.rdf4j.common.iteration.FilterIteration; | ||
import org.eclipse.rdf4j.query.BindingSet; | ||
import org.eclipse.rdf4j.query.algebra.evaluation.QueryEvaluationStep; | ||
import org.eclipse.rdf4j.query.algebra.evaluation.QueryValueEvaluationStep; | ||
|
||
public class PostFilterQueryEvaluationStep implements QueryEvaluationStep { | ||
|
||
private final QueryEvaluationStep wrapped; | ||
private final Predicate<BindingSet> condition; | ||
|
||
public PostFilterQueryEvaluationStep(QueryEvaluationStep wrapped, | ||
QueryValueEvaluationStep condition) { | ||
this.wrapped = wrapped; | ||
this.condition = condition.asPredicate(); | ||
} | ||
|
||
@Override | ||
public CloseableIteration<BindingSet> evaluate(BindingSet leftBindings) { | ||
var rightIteration = wrapped.evaluate(leftBindings); | ||
|
||
if (rightIteration == QueryEvaluationStep.EMPTY_ITERATION) { | ||
return rightIteration; | ||
} | ||
|
||
return new FilterIteration<>(rightIteration) { | ||
|
||
@Override | ||
protected boolean accept(BindingSet bindings) { | ||
return condition.test(bindings); | ||
} | ||
|
||
@Override | ||
protected void handleClose() { | ||
// Nothing to close | ||
JervenBolleman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
}; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...pse/rdf4j/query/algebra/evaluation/impl/evaluationsteps/PreFilterQueryEvaluationStep.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 Eclipse RDF4J contributors. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Distribution License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*******************************************************************************/ | ||
package org.eclipse.rdf4j.query.algebra.evaluation.impl.evaluationsteps; | ||
|
||
import java.util.function.Predicate; | ||
|
||
import org.eclipse.rdf4j.common.iteration.CloseableIteration; | ||
import org.eclipse.rdf4j.query.BindingSet; | ||
import org.eclipse.rdf4j.query.algebra.evaluation.QueryEvaluationStep; | ||
import org.eclipse.rdf4j.query.algebra.evaluation.QueryValueEvaluationStep; | ||
|
||
public class PreFilterQueryEvaluationStep implements QueryEvaluationStep { | ||
|
||
private final QueryEvaluationStep wrapped; | ||
private final Predicate<BindingSet> condition; | ||
|
||
public PreFilterQueryEvaluationStep(QueryEvaluationStep wrapped, | ||
QueryValueEvaluationStep condition) { | ||
this.wrapped = wrapped; | ||
this.condition = condition.asPredicate(); | ||
} | ||
|
||
@Override | ||
public CloseableIteration<BindingSet> evaluate(BindingSet leftBindings) { | ||
if (!condition.test(leftBindings)) { | ||
// Usage of this method assume this instance is returned | ||
return QueryEvaluationStep.EMPTY_ITERATION; | ||
} | ||
|
||
return wrapped.evaluate(leftBindings); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
.../query/algebra/evaluation/impl/evaluationsteps/values/ScopedQueryValueEvaluationStep.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 Eclipse RDF4J contributors. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Distribution License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*******************************************************************************/ | ||
package org.eclipse.rdf4j.query.algebra.evaluation.impl.evaluationsteps.values; | ||
|
||
import java.util.Set; | ||
|
||
import org.eclipse.rdf4j.model.Value; | ||
import org.eclipse.rdf4j.query.Binding; | ||
import org.eclipse.rdf4j.query.BindingSet; | ||
import org.eclipse.rdf4j.query.algebra.evaluation.QueryBindingSet; | ||
import org.eclipse.rdf4j.query.algebra.evaluation.QueryValueEvaluationStep; | ||
|
||
public class ScopedQueryValueEvaluationStep implements QueryValueEvaluationStep { | ||
|
||
/** | ||
* The set of binding names that are "in scope" for the filter. The filter must not include bindings that are (only) | ||
* included because of the depth-first evaluation strategy in the evaluation of the constraint. | ||
*/ | ||
private final Set<String> scopeBindingNames; | ||
private final QueryValueEvaluationStep wrapped; | ||
|
||
public ScopedQueryValueEvaluationStep(Set<String> scopeBindingNames, QueryValueEvaluationStep condition) { | ||
this.scopeBindingNames = scopeBindingNames; | ||
this.wrapped = condition; | ||
} | ||
|
||
@Override | ||
public Value evaluate(BindingSet bindings) { | ||
BindingSet scopeBindings = createScopeBindings(scopeBindingNames, bindings); | ||
|
||
return wrapped.evaluate(scopeBindings); | ||
} | ||
|
||
private BindingSet createScopeBindings(Set<String> scopeBindingNames, BindingSet bindings) { | ||
QueryBindingSet scopeBindings = new QueryBindingSet(scopeBindingNames.size()); | ||
for (String scopeBindingName : scopeBindingNames) { | ||
Binding binding = bindings.getBinding(scopeBindingName); | ||
if (binding != null) { | ||
scopeBindings.addBinding(binding); | ||
} | ||
} | ||
|
||
return scopeBindings; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Note for myself: did we start using var in the code base?
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.
I'm fine with var. I've started using it where it makes sense. Best use case for me so far has been for connections or iterators that are wrapped in a try-with-resource, much easier to read.