use of org.apache.jena.sparql.engine.QueryExecutionBase in project jena by apache.
the class QueryTestTDB method runTestForReal.
@Override
protected void runTestForReal() {
if (skipThisTest) {
log.info(this.getName() + " : Skipped");
return;
}
Query query = QueryFactory.read(queryFile);
Dataset ds = DatasetFactory.create(defaultGraphURIs, namedGraphURIs);
// ---- First, get the expected results by executing in-memory or from a results file.
ResultSetRewindable rs1 = null;
String expectedLabel = "";
if (results != null) {
rs1 = ResultSetFactory.makeRewindable(results.getResultSet());
expectedLabel = "Results file";
} else {
QueryEngineFactory f = QueryEngineRef.getFactory();
try (QueryExecution qExec1 = new QueryExecutionBase(query, ds, null, f)) {
rs1 = ResultSetFactory.makeRewindable(qExec1.execSelect());
}
expectedLabel = "Standard engine";
}
// ---- Second, execute in persistent graph
//DatasetFactory.create(model) ;
Dataset ds2 = dataset;
QueryExecution qExec2 = QueryExecutionFactory.create(query, ds2);
ResultSet rs = qExec2.execSelect();
ResultSetRewindable rs2 = ResultSetFactory.makeRewindable(rs);
// See if the same.
boolean b = ResultSetCompare.equalsByValue(rs1, rs2);
if (!b) {
rs1.reset();
rs2.reset();
System.out.println("------------------- " + this.getName());
System.out.printf("**** Expected (%s)", expectedLabel);
ResultSetFormatter.out(System.out, rs1);
System.out.println("**** Got (TDB)");
ResultSetFormatter.out(System.out, rs2);
}
assertTrue("Results sets not the same", b);
}
use of org.apache.jena.sparql.engine.QueryExecutionBase in project jena by apache.
the class QueryExecutionFactory method make.
protected static QueryExecution make(Query query, Dataset dataset, Context context) {
query.setResultVars();
if (context == null)
// .copy done in QueryExecutionBase -> Context.setupContext.
context = ARQ.getContext();
DatasetGraph dsg = null;
if (dataset != null)
dsg = dataset.asDatasetGraph();
QueryEngineFactory f = findFactory(query, dsg, context);
if (f == null) {
Log.warn(QueryExecutionFactory.class, "Failed to find a QueryEngineFactory");
return null;
}
return new QueryExecutionBase(query, dataset, context, f);
}
use of org.apache.jena.sparql.engine.QueryExecutionBase in project jena by apache.
the class QueryTestSDB method runTestForReal.
@Override
public void runTestForReal() {
if (skipThisTest) {
log.info(this.getName() + " : Skipped");
return;
}
if (store == null)
fail("No store");
// if ( item.getDefaultGraphURIs().size() != 1 || item.getNamedGraphURIs().size() != 0 )
// fail("Only one data graph supported") ;
Query query = QueryFactory.read(item.getQueryFile());
// If null, then compare to running ARQ in-memory
if (VERBOSE) {
System.out.println("Test: " + this.getName());
System.out.println(query);
}
// Make sure a plain, no sameValueAs graph is used.
SystemARQ.UsePlainGraph = true;
Dataset ds = DatasetFactory.create(item.getDefaultGraphURIs(), item.getNamedGraphURIs());
// ---- First, get the expected results by executing in-memory or from a results file.
ResultSet rs = null;
if (item.getResults() != null)
rs = item.getResults().getResultSet();
ResultSetRewindable rs1 = null;
String expectedLabel = "";
if (rs != null) {
rs1 = ResultSetFactory.makeRewindable(rs);
expectedLabel = "Results file";
} else {
QueryEngineFactory f = QueryEngineRef.getFactory();
try (QueryExecution qExec1 = new QueryExecutionBase(query, ds, null, f)) {
rs1 = ResultSetFactory.makeRewindable(qExec1.execSelect());
}
expectedLabel = "Standard engine";
}
// ---- Second, execute in DB
QueryEngineFactory f2 = QueryEngineSDB.getFactory();
ds = DatasetStore.create(store);
try (QueryExecution qExec2 = new QueryExecutionBase(query, ds, null, f2)) {
SDBConnection.logSQLExceptions = true;
rs = qExec2.execSelect();
ResultSetRewindable rs2 = ResultSetFactory.makeRewindable(rs);
boolean b = ResultSetCompare.equalsByTerm(rs1, rs2);
if (!b) {
rs1.reset();
rs2.reset();
System.out.println("------------------- " + this.getName());
System.out.printf("**** Expected (%s)", expectedLabel);
ResultSetFormatter.out(System.out, rs1);
System.out.println("**** Got (SDB engine)");
ResultSetFormatter.out(System.out, rs2);
}
assertTrue("Results sets not the same", b);
} finally {
SDBConnection.logSQLExceptions = false;
}
}
Aggregations