Package se.liu.ida.hefquin.engine
Class ValuesServiceQueryResolver
java.lang.Object
se.liu.ida.hefquin.engine.ValuesServiceQueryResolver
Queries with a WHERE clause of a form such as the following one need to be
rewritten, which is what this class does.
PREFIX ex: <http://example.org/>
SELECT * WHERE {
VALUES (?s1 ?s2) {
(ex:endpoint1 ex:endpoint2)
(ex:endpoint1 ex:endpoint3)
}
SERVICE ?s1 { .. some pattern (that neither mention ?s1 nor ?2) .. }
SERVICE ?s2 { .. also some pattern (that also doesn't mention ?s1 or ?2) .. }
}
The rewriting that is applied to such query patterns is to apply the
solution mappings of the VALUES clause to the SERVICE clauses and, then
remove the VALUES clause. If the VALUES clause contains multiple solution
mappings (as in the example above), than the group of SERVICE clauses is
copied for each of these solution mappings, and the resulting groups are
combined via UNION. For instance, the result of rewriting the example query
above is given as follows.
PREFIX ex: <http://example.org/>
SELECT * WHERE {
{
SERVICE ex:endpoint1 { .. some pattern (that neither mention ?s1 nor ?2) .. }
SERVICE ex:endpoint2 { .. also some pattern (that also doesn't mention ?s1 or ?2) .. }
}
UNION
{
SERVICE ex:endpoint1 { .. some pattern (that neither mention ?s1 nor ?2) .. }
SERVICE ex:endpoint3 { .. also some pattern (that also doesn't mention ?s1 or ?2) .. }
}
}
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classprotected static classprotected static classCollects all variables in a givenElementexcept for variables that occur *only* as the variable of SERVICE clauses.protected static class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidexpandValuesPlusServicePattern(org.apache.jena.query.Query q) If the WHERE clause of the given query is of a form that should be rewritten (as is checked by usingisQueryToBeExpanded(Query)), then this method replaces the WHERE clause of the query by the rewritten one.static booleanisQueryToBeExpanded(org.apache.jena.query.Query q) Returnstrueif the WHERE clause of the given query is of a form that should be rewritten.protected static org.apache.jena.sparql.syntax.Elementrewrite(Iterator<org.apache.jena.sparql.syntax.Element> it, org.apache.jena.sparql.engine.binding.Binding solmap) protected static org.apache.jena.sparql.syntax.Elementrewrite(org.apache.jena.sparql.syntax.ElementGroup eg, org.apache.jena.sparql.engine.binding.Binding solmap)
-
Constructor Details
-
ValuesServiceQueryResolver
public ValuesServiceQueryResolver()
-
-
Method Details
-
expandValuesPlusServicePattern
public static void expandValuesPlusServicePattern(org.apache.jena.query.Query q) If the WHERE clause of the given query is of a form that should be rewritten (as is checked by usingisQueryToBeExpanded(Query)), then this method replaces the WHERE clause of the query by the rewritten one. Otherwise, the WHERE clause of the query is not changed. -
isQueryToBeExpanded
public static boolean isQueryToBeExpanded(org.apache.jena.query.Query q) Returnstrueif the WHERE clause of the given query is of a form that should be rewritten. That is, the WHERE clause must begin with a VALUES clause, none of the variables bound by the VALUES clause is mentioned anywhere else except as the variable of a SERVICE clause, the VALUES clause must mention every variable that is a variable of a SERVICE clause, there must be at least one SERVICE clause with a variable, and there must not be any other VALUES clause in the WHERE clause. -
rewrite
protected static org.apache.jena.sparql.syntax.Element rewrite(org.apache.jena.sparql.syntax.ElementGroup eg, org.apache.jena.sparql.engine.binding.Binding solmap) -
rewrite
protected static org.apache.jena.sparql.syntax.Element rewrite(Iterator<org.apache.jena.sparql.syntax.Element> it, org.apache.jena.sparql.engine.binding.Binding solmap)
-