use of org.apache.jena.sparql.exec.RowSetRewindable in project jena by apache.
the class TestSolverTDB method exec.
/**
* Execute in triples and quad forms. Check the algebra expression gets the same
* results
*/
private static RowSet exec(String pattern) {
Op op1 = SSE.parseOp(pattern, pmap);
List<Var> vars = new ArrayList<>();
vars.addAll(OpVars.visibleVars(op1));
Op op2 = Algebra.toQuadForm(op1);
// Execute in triples and quad forms.
QueryIterator qIter1 = Algebra.exec(op1, dataset.asDatasetGraph());
RowSetRewindable rs1 = RowSet.create(qIter1, vars).rewindable();
QueryIterator qIter2 = Algebra.exec(op2, dataset.asDatasetGraph());
RowSetRewindable rs2 = RowSet.create(qIter2, vars).rewindable();
;
equals(rs1, rs2);
rs1.reset();
rs2.reset();
return rs1;
}
use of org.apache.jena.sparql.exec.RowSetRewindable in project jena by apache.
the class AbstractTestAdditional method substitute_1.
/**
* Check substitution into patterns.
*/
@Test
public void substitute_1() {
Dataset dataset = dataset();
String resultsStr = StrUtils.strjoinNL("(resultset (?s ?p ?o)", "(row (?s :s1) (?p :p) (?o :o))", ")");
RowSetRewindable expected = SSE.parseRowSet(resultsStr).rewindable();
Txn.executeWrite(dataset, () -> {
String data = StrUtils.strjoinNL("(dataset", " (:g1 :s1 :p :o)", " (:g1 :s2 :p :o)", " (:g2 :s1 :p :o)", " (:g2 :s2 :p :o)", ")");
DatasetGraph dsg = SSE.parseDatasetGraph(data);
dataset.asDatasetGraph().addAll(dsg);
String qs = PREFIXES + "SELECT * { VALUES ?s { :s1 } GRAPH <" + Quad.unionGraph + "> { ?s ?p ?o } }";
Query query = QueryFactory.create(qs);
try (QueryExec qExec = QueryExec.dataset(dsg).query(query).build()) {
RowSetRewindable rs = qExec.select().rewindable();
testRS(expected, rs);
}
});
}
use of org.apache.jena.sparql.exec.RowSetRewindable in project jena by apache.
the class ResultSetCompare method equalsByTerm.
/**
* See {@link #equalsByTerm(ResultSet, ResultSet)}
*/
public static boolean equalsByTerm(RowSet rs1, RowSet rs2) {
if (!compareHeader(rs1, rs2))
return false;
RowSetRewindable rs1a = rs1.rewindable();
RowSetRewindable rs2a = rs2.rewindable();
// Aligned rows
if (equivalent(convert(rs1a), convert(rs2a), new BNodeIso(NodeUtils.sameNode)))
return true;
rs1a.reset();
rs2a.reset();
return isomorphic(rs1a, rs2a);
}
Aggregations