-
Notifications
You must be signed in to change notification settings - Fork 184
GH-5870: add basic RDF 1.2 support to FedX #5871
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4ebf3b5
GH-5870: add initial RDF 1.2 support to FedX query optimizer (WIP)
aschwarte10 41d4e0d
GH-5870: introduce TripleRefJoinOptimizer and TripleRefJoinGroup
aschwarte10 eaefee1
GH-5870: add end-to-end evaluation of TripleRefJoinGroup for RDF 1.2
aschwarte10 a8b2761
GH-5870: Polishing and cleanup
aschwarte10 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
Some comments aren't visible on the classic Files Changed page.
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
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
131 changes: 131 additions & 0 deletions
131
tools/federation/src/main/java/org/eclipse/rdf4j/federated/algebra/TripleRefJoinGroup.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,131 @@ | ||
| /******************************************************************************* | ||
| * Copyright (c) 2026 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.federated.algebra; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.HashSet; | ||
| import java.util.List; | ||
| import java.util.Set; | ||
|
|
||
| import org.eclipse.rdf4j.federated.structures.QueryInfo; | ||
| import org.eclipse.rdf4j.federated.util.QueryAlgebraUtil; | ||
| import org.eclipse.rdf4j.query.algebra.AbstractQueryModelNode; | ||
| import org.eclipse.rdf4j.query.algebra.QueryModelNode; | ||
| import org.eclipse.rdf4j.query.algebra.QueryModelVisitor; | ||
| import org.eclipse.rdf4j.query.algebra.StatementPattern; | ||
|
|
||
| /** | ||
| * A join group around a {@link TripleRefStatementPattern}: besides the {@link TripleRefStatementPattern} it contains | ||
| * the list of {@link StatementPattern} sharing the same subject (typically a blank node). | ||
| * | ||
| * {@link TripleRefJoinGroup} can be associated to multiple {@link StatementSource}s, where on each it gets executed in | ||
| * a single expression. | ||
| */ | ||
| public class TripleRefJoinGroup extends AbstractQueryModelNode implements FedXTupleExpr { | ||
|
|
||
| private static final long serialVersionUID = 3505148693453950138L; | ||
|
|
||
| private final TripleRefStatementPattern tripleRef; | ||
| private final List<StatementPattern> stmts; | ||
| private final List<StatementSource> statementSources; | ||
| private final QueryInfo queryInfo; | ||
|
|
||
| private Set<String> assuredBindingNames; | ||
| private List<String> freeVars; | ||
|
|
||
| public TripleRefJoinGroup(TripleRefStatementPattern tripleRef, List<StatementPattern> stmts, | ||
| List<StatementSource> statementSources, QueryInfo queryInfo) { | ||
| super(); | ||
| this.tripleRef = tripleRef; | ||
| this.stmts = stmts; | ||
| this.statementSources = statementSources; | ||
| this.queryInfo = queryInfo; | ||
| } | ||
|
|
||
| @Override | ||
| public Set<String> getBindingNames() { | ||
| return getAssuredBindingNames(); | ||
| } | ||
|
|
||
| @Override | ||
| public Set<String> getAssuredBindingNames() { | ||
| if (assuredBindingNames == null) { | ||
| assuredBindingNames = new HashSet<>(); | ||
| assuredBindingNames.addAll(tripleRef.getAssuredBindingNames()); | ||
| stmts.forEach(st -> assuredBindingNames.addAll(st.getAssuredBindingNames())); | ||
| } | ||
| return assuredBindingNames; | ||
| } | ||
|
|
||
| public List<StatementSource> getStatementSources() { | ||
| return statementSources; | ||
| } | ||
|
|
||
| public TripleRefStatementPattern getTripleRefStatementPattern() { | ||
| return this.tripleRef; | ||
| } | ||
|
|
||
| public List<StatementPattern> getStatementPatterns() { | ||
| return this.stmts; | ||
| } | ||
|
|
||
| @Override | ||
| public <X extends Exception> void visit(QueryModelVisitor<X> visitor) throws X { | ||
| visitor.meetOther(this); | ||
| } | ||
|
|
||
| @Override | ||
| public <X extends Exception> void visitChildren(QueryModelVisitor<X> visitor) throws X { | ||
|
|
||
| for (var source : statementSources) { | ||
| source.visit(visitor); | ||
| } | ||
|
|
||
| tripleRef.visit(visitor); | ||
|
|
||
| for (var stmt : stmts) { | ||
| stmt.visit(visitor); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void replaceChildNode(QueryModelNode current, QueryModelNode replacement) { | ||
| throw new UnsupportedOperationException(); | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
| public List<String> getFreeVars() { | ||
| if (freeVars == null) { | ||
| Set<String> freeVarsSet = new HashSet<>(); | ||
| freeVarsSet.addAll(tripleRef.getFreeVars()); | ||
| for (var st : stmts) { | ||
| if (st instanceof VariableExpr e) { | ||
| freeVarsSet.addAll(e.getFreeVars()); | ||
| } else { | ||
| freeVarsSet.addAll(QueryAlgebraUtil.getFreeVars(st)); | ||
| } | ||
| } | ||
| freeVars = new ArrayList<String>(freeVarsSet); | ||
| } | ||
| return freeVars; | ||
| } | ||
|
|
||
| @Override | ||
| public QueryInfo getQueryInfo() { | ||
| return queryInfo; | ||
| } | ||
|
|
||
| @Override | ||
| public TripleRefJoinGroup clone() { | ||
| return (TripleRefJoinGroup) super.clone(); | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.