Skip to content

Commit 095d478

Browse files
committed
GH-5151: use VALUES clause for FedX bind join with no free vars
For evaluation of bind joins the implementation for quite some time makes use of a VALUES clause query. Except for one code-path: for bind joins - where in the join all arguments are bound - it was still using the old UNION query approach. This approach is error prone and no longer required, i.e. the check join can be executed with the same logic as the regular VALUES clause. Note: an additional unit test for covering bind joins with no free vars is added. This change also marks a number of methods and classes used for the old UNION based approach as deprecated. The implementations are internal to the FedX engine and can be removed in the next major release.
1 parent 3e4f94f commit 095d478

File tree

9 files changed

+49
-8
lines changed

9 files changed

+49
-8
lines changed

tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/FederationEvalStrategy.java

+3
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,10 @@ public abstract CloseableIteration<BindingSet> evaluateBoundJoinStatementPattern
935935
* @param bindings
936936
* @return the result iteration
937937
* @throws QueryEvaluationException
938+
* @deprecated with VALUES implementation, control flow goes via
939+
* {@link #evaluateBoundJoinStatementPattern(StatementTupleExpr, List)}
938940
*/
941+
@Deprecated(forRemoval = true)
939942
public abstract CloseableIteration<BindingSet> evaluateGroupedCheck(
940943
CheckStatementPattern stmt, final List<BindingSet> bindings) throws QueryEvaluationException;
941944

tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/SparqlFederationEvalStrategy.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ public CloseableIteration<BindingSet> evaluateBoundJoinStatementPattern(
118118
/**
119119
* Alternative evaluation implementation using UNION. Nowadays we use a VALUES clause based implementation
120120
*
121-
* @deprecated
121+
* @deprecated no longer used
122122
*/
123+
@Deprecated(forRemoval = true)
123124
protected CloseableIteration<BindingSet> evaluateBoundJoinStatementPattern_UNION(
124125
StatementTupleExpr stmt, List<BindingSet> bindings)
125126
throws QueryEvaluationException {

tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/join/ControlledWorkerBindJoin.java

+2-6
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,7 @@ protected TaskCreator determineTaskCreator(TupleExpr expr, BindingSet bs) {
4545
final TaskCreator taskCreator;
4646
if (expr instanceof StatementTupleExpr) {
4747
StatementTupleExpr stmt = (StatementTupleExpr) expr;
48-
if (stmt.hasFreeVarsFor(bs)) {
49-
taskCreator = new BoundJoinTaskCreator(strategy, stmt);
50-
} else {
51-
expr = new CheckStatementPattern(stmt, queryInfo);
52-
taskCreator = new CheckJoinTaskCreator(strategy, (CheckStatementPattern) expr);
53-
}
48+
taskCreator = new BoundJoinTaskCreator(strategy, stmt);
5449
} else if (expr instanceof FedXService) {
5550
taskCreator = new FedXServiceJoinTaskCreator(strategy, (FedXService) expr);
5651
} else {
@@ -77,6 +72,7 @@ public ParallelTask<BindingSet> getTask(ParallelExecutor<BindingSet> control, Li
7772
}
7873
}
7974

75+
@Deprecated(forRemoval = true)
8076
protected class CheckJoinTaskCreator implements TaskCreator {
8177
protected final FederationEvalStrategy _strategy;
8278
protected final CheckStatementPattern _expr;

tools/federation/src/main/java/org/eclipse/rdf4j/federated/evaluation/join/ParallelCheckJoinTask.java

+2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
* {@link FederationEvalStrategy#evaluateGroupedCheck(CheckStatementPattern, List)} for further details.
2525
*
2626
* @author Andreas Schwarte
27+
* @deprecated now integrated in {@link ParallelBoundJoinTask} (with VALUES clause)
2728
*/
29+
@Deprecated(forRemoval = true)
2830
public class ParallelCheckJoinTask extends ParallelTaskBase<BindingSet> {
2931

3032
protected final FederationEvalStrategy strategy;

tools/federation/src/test/java/org/eclipse/rdf4j/federated/BoundJoinTests.java

+8
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,12 @@ public void testBoundJoin_FailingEndpoint() throws Exception {
4545
execute("/tests/boundjoin/query01.rq", "/tests/boundjoin/query01.srx", false, true);
4646
});
4747
}
48+
49+
@Test
50+
public void testBoundCheck() throws Exception {
51+
52+
/* test with VALUES clause based bound join, check join */
53+
prepareTest(Arrays.asList("/tests/data/data1.ttl", "/tests/data/data2.ttl"));
54+
execute("/tests/boundjoin/query02_checkJoin.rq", "/tests/boundjoin/query02_checkJoin.srx", false, true);
55+
}
4856
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# bound join query (where in the bind join all variables are bound)
2+
PREFIX ns1: <http://namespace1.org/>
3+
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
4+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
5+
PREFIX owl: <http://www.w3.org/2002/07/owl#>
6+
7+
SELECT ?person ?name WHERE {
8+
?person rdf:type foaf:Person .
9+
?person foaf:age 25 .
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<sparql xmlns='http://www.w3.org/2005/sparql-results#'>
3+
<head>
4+
<variable name='person'/>
5+
<variable name='name'/>
6+
<variable name='publication'/>
7+
</head>
8+
<results>
9+
<result>
10+
<binding name='person'>
11+
<uri>http://namespace1.org/Person_4</uri>
12+
</binding>
13+
</result>
14+
<result>
15+
<binding name='person'>
16+
<uri>http://namespace2.org/Person_6</uri>
17+
</binding>
18+
</result>
19+
</results>
20+
</sparql>

tools/federation/src/test/resources/tests/data/data1.ttl

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
:Person_4 rdf:type foaf:Person .
2525
:Person_4 rdf:type :Person .
2626
:Person_4 foaf:name "Person4" .
27+
:Person_4 foaf:age "25"^^xsd:integer .
2728

2829
:Person_5 rdf:type foaf:Person .
2930
:Person_5 rdf:type :Person .

tools/federation/src/test/resources/tests/data/data2.ttl

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
:Person_6 rdf:type foaf:Person .
1010
:Person_6 rdf:type :Person .
1111
:Person_6 foaf:name "Person6" .
12-
:Person_1 foaf:age "25"^^xsd:integer .
12+
:Person_6 foaf:age "25"^^xsd:integer .
1313

1414
:Person_7 rdf:type foaf:Person .
1515
:Person_7 rdf:type :Person .

0 commit comments

Comments
 (0)