Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
abrokenjester committed Jan 20, 2023
1 parent 818fe45 commit 33ce6d6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public void meet(Filter node) throws RuntimeException {
public void meet(LeftJoin leftJoin) {
leftJoin.getLeftArg().visit(this);
// we can not pre-bind values for the optional part of the left-join

// in a left-join, we can pre-bind variables in the RHS _if_, after pre-binding in the LHS, those variables
// are now fixed.
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
import java.util.List;

import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
import org.eclipse.rdf4j.query.algebra.BindingSetAssignment;
import org.eclipse.rdf4j.query.algebra.Extension;
import org.eclipse.rdf4j.query.algebra.Join;
import org.eclipse.rdf4j.query.algebra.Order;
import org.eclipse.rdf4j.query.algebra.Projection;
import org.eclipse.rdf4j.query.algebra.Service;
Expand Down Expand Up @@ -82,6 +84,29 @@ public void testAskQuerySolutionModifiers() {

}

@Test
public void testValuesOptionalQuery() throws Exception {
String query = "select ?parent ?child\n"
+ "where {\n"
+ " values ?type {<owl:Class>}\n"
+ " ?parent <rdf:type> ?type .\n"
+ " optional {\n"
+ " ?child <rdfs:subClassOf> ?parent ;\n"
+ " <rdf:type> ?type .\n"
+ " }\n"
+ "}";

TupleExprBuilder builder = new TupleExprBuilder(SimpleValueFactory.getInstance());
ASTQueryContainer qc = SyntaxTreeBuilder.parseQuery(query);
TupleExpr result = builder.visit(qc, null);

assertThat(result).isInstanceOf(Projection.class);
Join topJoin = (Join) ((Projection) result).getArg();

assertThat(topJoin.getLeftArg()).isInstanceOf(BindingSetAssignment.class);

}

@Test
public void testNegatedPathWithFixedObject() {
String query = "ASK WHERE { ?s !<http://example.org/p> <http://example.org/o> . }";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,19 @@ public void afterClass() {
@Benchmark
public long valuesOptionalQuery() {
try (SailRepositoryConnection connection = repository.getConnection()) {
//
// System.out.println("ONLY PARSED:");
// System.out.println(connection.prepareTupleQuery(query_with_values_clause));
// System.out.println("\nUNOPTIMIZED:");
// System.out.println(
// connection.prepareTupleQuery(query_with_values_clause).explain(Explanation.Level.Unoptimized));
//
// System.out.println();
// System.out.println("OPTIMIZED:");
// System.out.println(
// connection.prepareTupleQuery(query_with_values_clause).explain(Explanation.Level.Optimized));

// return 0L;
return connection
.prepareTupleQuery(query_with_values_clause)
.evaluate()
Expand All @@ -164,6 +177,7 @@ public long valuesOptionalQuery() {
@Benchmark
public long simpleEquivalentQuery() {
try (SailRepositoryConnection connection = repository.getConnection()) {

return connection
.prepareTupleQuery(query_without_values_clause)
.evaluate()
Expand Down

0 comments on commit 33ce6d6

Please sign in to comment.