use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.
the class QueryTest method convertToStrings.
private ResultSetRewindable convertToStrings(ResultSetRewindable resultsActual) {
List<Binding> bindings = new ArrayList<>();
while (resultsActual.hasNext()) {
Binding b = resultsActual.nextBinding();
BindingMap b2 = BindingFactory.create();
for (String vn : resultsActual.getResultVars()) {
Var v = Var.alloc(vn);
Node n = b.get(v);
String s;
if (n == null)
s = "";
else if (n.isBlank())
s = "_:" + n.getBlankNodeLabel();
else
s = NodeFunctions.str(n);
b2.add(v, NodeFactory.createLiteral(s));
}
bindings.add(b2);
}
ResultSet rs = new ResultSetStream(resultsActual.getResultVars(), null, new QueryIterPlainWrapper(bindings.iterator()));
return ResultSetFactory.makeRewindable(rs);
}
use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.
the class SQLBridgeBase method assembleResults.
@Override
public final QueryIterator assembleResults(ResultSetJDBC rs, Binding binding, ExecutionContext execCxt) {
if (execCxt == null || execCxt.getContext().isTrueOrUndef(SDB.jdbcStream)) {
// Stream
return new QueryIterSQL(rs, binding, execCxt);
}
// Debugging or problems with unreleasing JDBC ResultSets - read all in now.
QueryIterator qIter = new QueryIterSQL(rs, binding, execCxt);
List<Binding> results = new ArrayList<Binding>();
for (; qIter.hasNext(); ) results.add(qIter.nextBinding());
qIter.close();
return new QueryIterPlainWrapper(results.iterator(), execCxt);
}
use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.
the class TableBase method equals.
@Override
public boolean equals(Object other) {
if (this == other)
return true;
if (!(other instanceof Table))
return false;
Table table = (Table) other;
if (table.size() != this.size())
return false;
QueryIterator qIter1 = iterator(null);
QueryIterator qIter2 = table.iterator(null);
try {
for (; qIter1.hasNext(); ) {
Binding bind1 = qIter1.nextBinding();
Binding bind2 = qIter2.nextBinding();
if (!BindingBase.equals(bind1, bind2))
return false;
}
return true;
} finally {
qIter1.close();
qIter2.close();
}
}
use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.
the class TableBase method hashCode.
@Override
public int hashCode() {
int hash = 0;
QueryIterator qIter = iterator(null);
try {
for (; qIter.hasNext(); ) {
Binding binding = qIter.nextBinding();
hash ^= binding.hashCode();
}
return hash;
} finally {
qIter.close();
}
}
use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.
the class NodeTransformLib method transform.
public static Table transform(Table table, NodeTransform transform) {
// Non-streaming rewrite
List<Var> vars = transformVars(transform, table.getVars());
Iterator<Binding> iter = table.rows();
List<Binding> newRows = new ArrayList<>();
for (; iter.hasNext(); ) {
Binding b = iter.next();
Binding b2 = transform(b, transform);
newRows.add(b2);
}
return new TableData(vars, newRows);
}
Aggregations