Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public class FedXConfig {

private boolean enableGroupedSourceSelection = true;

/**
* Enable support for RDF 1.2 triple term queries
*/
private boolean enableTripleRefSupport = false;

private String sourceSelectionCacheSpec = null;

private SourceSelectionCacheFactory sourceSelectionCacheFactory = null;
Expand Down Expand Up @@ -530,4 +535,27 @@ public FedXConfig withEnableGroupedSourceSelection(boolean flag) {
this.enableGroupedSourceSelection = flag;
return this;
}

/**
* Whether the support for RDF 1.2 triple term evaluation is enabled or not
*
* @return whether triple ref support is enabled
*/
public boolean isEnableTripleRefSupport() {
return this.enableTripleRefSupport;
}

/**
* Enable or disable the support for RDF 1.2 triple term evaluation
*
*
* @param flag to enable RDF 1.2 triple term support.
* @return the current config
* @see #isEnableTripleRefSupport()
*/
public FedXConfig withEnableTripleRefSupport(boolean flag) {
this.enableTripleRefSupport = flag;
return this;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ public <X extends Exception> void visitChildren(QueryModelVisitor<X> visitor)
}
}

public void addStatementSource(StatementSource statementSource) {
statementSources.add(statementSource);
}

@Override
public <X extends Exception> void visit(QueryModelVisitor<X> visitor)
throws X {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ public StatementSourcePattern(StatementPattern node, QueryInfo queryInfo) {
this.federationContext = queryInfo.getFederationContext();
}

public void addStatementSource(StatementSource statementSource) {
statementSources.add(statementSource);
}

@Override
public CloseableIteration<BindingSet> evaluate(BindingSet bindings)
throws QueryEvaluationException {
Expand Down
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;
Comment thread
aschwarte10 marked this conversation as resolved.

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();
}
}
Loading
Loading