use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.
the class BinRDF method writeResultSet.
public static void writeResultSet(TProtocol protocol, ResultSet resultSet, boolean encodeValues) {
List<Var> vars = Var.varList(resultSet.getResultVars());
try (Binding2Thrift b2t = new Binding2Thrift(protocol, vars, encodeValues)) {
for (; resultSet.hasNext(); ) {
Binding b = resultSet.nextBinding();
b2t.output(b);
}
}
//Done by Binding2Thrift.close() -- LibThriftRDF.flush(protocol) ;
}
use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.
the class EvaluatorSimple method filter.
@Override
public Table filter(ExprList expressions, Table table) {
if (debug) {
System.out.println("Restriction");
System.out.println(expressions);
dump(table);
}
QueryIterator iter = table.iterator(execCxt);
List<Binding> output = new ArrayList<>();
for (; iter.hasNext(); ) {
Binding b = iter.nextBinding();
if (expressions.isSatisfied(b, execCxt))
output.add(b);
}
return new TableN(new QueryIterPlainWrapper(output.iterator(), execCxt));
}
use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.
the class EvaluatorSimple method minusWorker.
private Table minusWorker(Table tableLeft, Table tableRight) {
// Minus(Ω1, Ω2) = { μ | μ in Ω1 such that for all μ' in Ω2, either μ and μ' are not compatible or dom(μ) and dom(μ') are disjoint }
TableN results = new TableN();
QueryIterator iterLeft = tableLeft.iterator(execCxt);
for (; iterLeft.hasNext(); ) {
Binding bindingLeft = iterLeft.nextBinding();
boolean includeThisRow = true;
// Find a reason not to include the row.
// That's is not disjoint and not compatible.
QueryIterator iterRight = tableRight.iterator(execCxt);
for (; iterRight.hasNext(); ) {
Binding bindingRight = iterRight.nextBinding();
if (Algebra.disjoint(bindingLeft, bindingRight))
// Disjoint - not a reason to exclude
continue;
if (!Algebra.compatible(bindingLeft, bindingRight))
// Compatible - not a reason to exclude.
continue;
includeThisRow = false;
break;
}
iterRight.close();
if (includeThisRow)
results.addBinding(bindingLeft);
}
iterLeft.close();
return results;
}
use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.
the class OpExecutor method debug.
// Use this to debug evaluation
// Example:
// input = debug(input) ;
private QueryIterator debug(String marker, QueryIterator input) {
List<Binding> x = all(input);
for (Binding b : x) {
System.out.print(marker);
System.out.print(": ");
System.out.println(b);
}
return new QueryIterPlainWrapper(x.iterator(), execCxt);
}
use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.
the class EvaluatorSimple method diffWorker.
// @@ Abstract compatibility
private Table diffWorker(Table tableLeft, Table tableRight) {
QueryIterator left = tableLeft.iterator(execCxt);
TableN r = new TableN();
for (; left.hasNext(); ) {
Binding b = left.nextBinding();
if (tableRight.contains(b))
r.addBinding(b);
}
tableLeft.close();
tableRight.close();
return r;
}
Aggregations