use of org.apache.jena.sparql.exec.RowSetRewindable in project jena by apache.
the class TestSolverTDB method same.
private static void same(RowSet rs1, RowSet rs2, boolean result) {
RowSetRewindable rsw1 = rs1.rewindable();
RowSetRewindable rsw2 = rs2.rewindable();
boolean b = ResultSetCompare.equalsByValue(rsw1, rsw2);
if (b != result) {
System.out.println("Different: ");
rsw1.reset();
rsw2.reset();
RowSetOps.out(rsw1);
RowSetOps.out(rsw2);
System.out.println();
}
assertTrue(b == result);
}
use of org.apache.jena.sparql.exec.RowSetRewindable in project jena by apache.
the class TestSolverTDB method same.
private static void same(RowSet rs1, RowSet rs2, boolean result) {
RowSetRewindable rsw1 = rs1.rewindable();
RowSetRewindable rsw2 = rs2.rewindable();
boolean b = ResultSetCompare.equalsByValue(rsw1, rsw2);
if (b != result) {
System.out.println("Different: ");
rsw1.reset();
rsw2.reset();
RowSetOps.out(rsw1);
RowSetOps.out(rsw2);
System.out.println();
}
assertTrue(b == result);
}
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 RowSetWriterText method output$.
private static void output$(AWriter out, RowSet rowSet, String colStart, String colSep, String colEnd, Context cxt) {
Prologue prologue = choosePrologue(rowSet, cxt);
SerializationContext context = new SerializationContext(prologue);
try {
if (rowSet.getResultVars().size() == 0) {
out.println("==== No variables ====");
}
RowSetRewindable resultSetRewindable = rowSet.rewindable();
int numCols = resultSetRewindable.getResultVars().size();
int[] colWidths = colWidths(resultSetRewindable, context);
String[] row = new String[numCols];
int lineWidth = 0;
for (int col = 0; col < numCols; col++) {
String rVar = rowSet.getResultVars().get(col).getVarName();
row[col] = rVar;
lineWidth += colWidths[col];
if (col > 0)
lineWidth += colSep.length();
}
if (colStart != null)
lineWidth += colStart.length();
if (colEnd != null)
lineWidth += colEnd.length();
for (int i = 0; i < lineWidth; i++) out.print('-');
out.println();
printRow(out, row, colWidths, colStart, colSep, colEnd);
for (int i = 0; i < lineWidth; i++) out.print('=');
out.println();
for (; resultSetRewindable.hasNext(); ) {
Binding rBind = resultSetRewindable.next();
for (int col = 0; col < numCols; col++) {
Var var = rowSet.getResultVars().get(col);
row[col] = getVarValueAsString(rBind, var, context);
}
printRow(out, row, colWidths, colStart, colSep, colEnd);
}
for (int i = 0; i < lineWidth; i++) out.print('-');
out.println();
resultSetRewindable = null;
} finally {
out.flush();
}
}
use of org.apache.jena.sparql.exec.RowSetRewindable in project jena by apache.
the class ResultSetCompare method equalsByValue.
/**
* See {@link #equalsByValue(ResultSet, ResultSet)}
*/
public static boolean equalsByValue(RowSet rs1, RowSet rs2) {
if (!compareHeader(rs1, rs2))
return false;
RowSetRewindable rs1a = rs1.rewindable();
RowSetRewindable rs2a = rs2.rewindable();
if (equivalent(convert(rs1a), convert(rs2a), new BNodeIso(NodeUtils.sameValue)))
return true;
rs1a.reset();
rs2a.reset();
return isomorphic(rs1a, rs2a);
}
Aggregations